SRL Archive - Reflection Development

Prison Pete Potential Fix


TRiLeZ

2011-04-26 03:39:57

On December 2/3rd, Jagex released an update to make the IDs of balloon animals shift around every revision or something, and made it so that their model ID would not change…

However, it took some work to figure out how to get the model ID, but I finally found how.

Here is my RSNPCDef class for TRiBot:

package org.tribot.wrappers;

import java.lang.ref.Reference;

import org.tribot.bot.Methods;
import org.tribot.methods.Constants;

public class RSNPCDef {

Object def;
Methods me;

public RSNPCDef(Object def, Methods methods) {
this.def = def;
this.me = methods;
}

public Object getRawObject() {
return this.def;
}

public String getName() {
return this.me.getFieldString(Constants.Hooks.NPCDef.getName, this.def);
}

public String[] getActions() {
return this.me.getFieldStringArray(Constants.Hooks.NPCDef.getActions,
this.def);
}

public int getID() {
return this.me.getFieldInt(Constants.Hooks.NPCDef.getType, this.def);
}

public int[] getChildrenIDs() {
return this.me.getFieldIntArray(Constants.Hooks.NPCDef.getChildrenIDs,
this.def);
}

public int getSettingIndex() {
return this.me.getFieldInt(Constants.Hooks.NPCDef.getSettingIndex,
this.def);
}

public RSNPCDefLoader getLoader() {
Object loader = this.me.getFieldObject(
Constants.Hooks.NPCDef.getDefLoader, this.def);
if (loader == null)
return null;

return new RSNPCDefLoader(loader, this.me);
}

public RSNPCDef getChild() {
int[] childrenIDs = getChildrenIDs();
if (childrenIDs == null)
return null;

RSNPCDefLoader loader = getLoader();
if (loader == null)
return null;

boolean b = false;

int index1 = -1;

if (getSettingIndex() == -1)
b = true;

if (!b)
index1 = this.me.getSetting(getSettingIndex());

if (((index1 ^ 0xFFFFFFFF) > -1) || (index1 >= childrenIDs.length - 1)
|| (childrenIDs[index1] == -1) || b) {
int index2 = childrenIDs[childrenIDs.length - 1];
if (index2 != -1)
return loader.getNPCDef(index2);

return null;
}

return loader.getNPCDef(childrenIDs[index1]);
}

protected Object getRSModel() {
int[] childrenIDs = getChildrenIDs();
if (childrenIDs != null) {
RSNPCDef child = getChild();
if (child != null)
return child.getRSModel();
}

RSNPCDefLoader defLoader = getLoader();
if (defLoader == null)
return null;

Object models = this.me.getFieldObject(
Constants.Hooks.NPCDefLoader.getModels, defLoader.loader);
Object cache = this.me.getFieldObject(
Constants.Hooks.Cache.getHashTable, models);
RSHashTable nodeCache = new RSHashTable(cache, this.me);
int index = this.me
.getFieldInt(Constants.Hooks.GraphicsToolkit.getIndex,
this.me.getFieldObject(
Constants.Hooks.Static.getToolkit, null));

int ID = getID() | index << 16;

RSNode node = this.me.calculations.findNodeByID(nodeCache, ID);

if (node == null) {
this.me.println("NPC Model Node = null... " + (defLoader == null)
+ " " + (models == null) + " " + (cache == null) + " "
+ (nodeCache == null) + " " + index);

return null;
}

Object model = this.me.getFieldObject(
Constants.Hooks.HardReference.getObject, node.getNode());

if (model == null) {

Object referenceObject = this.me.getFieldObject(
Constants.Hooks.SoftReference.getReference, node.getNode());
if (referenceObject == null
|| !(referenceObject instanceof Reference<?>))
return null;

if ((model = ((Reference<?>) referenceObject).get()) == null)
return null;
}

return model;
}

}

There are 2 approaches to making a fix…
  1. This method would allow for less code, but it is less reliable (still very reliable though).
  2. You would go off model IDs. After you get the NPCDef from the child, you would get that NPCDef's ID and that would be the model ID, specific to the balloon animal. Every different type of balloon animal will have a different model ID.
  3. This method would be the most reliable. You would rely on the length of indices the models of the balloon animals. Every different type of balloon animal will have a different length of indices1.

That is how you would go upon identifying the balloon animals. Someone just needs to convert my TRiBot code to srl-reflection/simba format, since I'm very busy these days.

Hooks for revision 645 can be found here: http://tribot.org/gethooks.php?r=645.

pyroryan

2011-04-26 10:28:00

Nexus iBot uses heights to determine the correct balloon. They're also collecting model IDs.
Powerbot uses method #2 or something similar to it (I don't remember).

Edit:
oaa.N is probably int[] modelIDs. Haven't tested anything, but you could loop through it and look for a unique ID that would then allow you to ID the balloon. Using your method #2 though is probably still the most reliable.

Edit 2:
Maybe move this to a public forum so people with time can look at it?

TRiLeZ

2011-04-26 14:41:54

From: pyroryan
Nexus iBot uses heights to determine the correct balloon. They're also collecting model IDs.
Powerbot uses method #2 or something similar to it (I don't remember).

Edit:
oaa.N is probably int[] modelIDs. Haven't tested anything, but you could loop through it and look for a unique ID that would then allow you to ID the balloon. Using your method #2 though is probably still the most reliable.

Edit 2:
Maybe move this to a public forum so people with time can look at it?


iBot NeXus' solver only occasionally works because every balloon animal has a different height, and it can be hard to get an exact range for all the balloon animals… maybe the range also overlaps for different types of animals. Yes, RSBot uses method #2.

oaa.N is the childrenIDs field. For the balloon animals, the children IDs field has about 20 IDs, and it's made up of 4 different IDs. To get the model ID, you'd have to use childrenIDs[settings.getSetting(settingIndex)].

I thought users could view this forum… Oh well, I'll move this to a different forum.

Edit: I'm not a moderator of these forums… do you want to move it to the reflection development forum? Thanks.

pyroryan

2011-04-27 01:14:14

From: TRiLeZ
iBot NeXus' solver only occasionally works because every balloon animal has a different height, and it can be hard to get an exact range for all the balloon animals… maybe the range also overlaps for different types of animals. Yes, RSBot uses method #2.

oaa.N is the childrenIDs field. For the balloon animals, the children IDs field has about 20 IDs, and it's made up of 4 different IDs. To get the model ID, you'd have to use childrenIDs[settings.getSetting(settingIndex)].

I thought users could view this forum… Oh well, I'll move this to a different forum.

Edit: I'm not a moderator of these forums… do you want to move it to the reflection development forum? Thanks.


I've been busy and haven't had too much time to look into it so that was some good info :).
And I'll move it :).

Edit:
There public now. Anyone with time who wants to look at this and try to implement it can :).