Made ScriptFactory work with objects like trapdoors

This commit is contained in:
dginovker
2019-12-31 15:47:52 -05:00
parent 731c4cb08e
commit cd44876739
3 changed files with 22 additions and 2 deletions
@@ -7,6 +7,8 @@ import org.parabot.environment.input.Mouse;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.rev317.min.api.methods.*;
import org.rev317.min.api.wrappers.*;
import org.rev317.min.debug.DSceneObjectsInteractiveObj;
import org.rev317.min.debug.DSceneObjectsWallDec;
import scriptfactory.VarsMethods;
import java.awt.event.KeyEvent;
@@ -147,6 +149,10 @@ public class ActionHandler {
private void interactWithEntity(final int[] id, String option)
{
SceneObject candidateObject = SceneObjects.getClosest(id);
if (candidateObject == null)
{
candidateObject = customGetSceneObject(id[0]); //Try harder- just in case.
}
Npc candidateNpc = Npcs.getClosest(new Filter<Npc>() {
@Override
public boolean accept(Npc o) {
@@ -170,8 +176,9 @@ public class ActionHandler {
}
});
SceneObject candidateObject = null;
if (sos.length > 0)
if (sos.length > 0) {
candidateObject = sos[0];
}
Npc[] npca = Npcs.getNearest(new Filter<Npc>() {
@Override
public boolean accept(Npc o) {
+1 -1
View File
@@ -21,7 +21,7 @@ import static scriptfactory.VarsMethods.log;
* Welcome to AIO AIO - ScriptFactory. Make your own scripts!
*/
@ScriptManifest(author = "Before", name = "Script Factory 1.16", category = Category.OTHER, version = 1.16, description = "Create your own scripts!", servers = "All")
@ScriptManifest(author = "Before", name = "Script Factory 1.16", category = Category.OTHER, version = 1.17, description = "Create your own scripts!", servers = "All")
public class Core extends Script implements Paintable {
private ArrayList<Action> actions = new ArrayList<>();
@@ -5,6 +5,8 @@ import org.parabot.core.ui.BotUI;
import org.parabot.core.ui.Logger;
import org.rev317.min.accessors.Client;
import org.rev317.min.api.methods.*;
import org.rev317.min.api.wrappers.SceneObject;
import org.rev317.min.api.wrappers.Tile;
import scriptfactory.Actions.Action;
import scriptfactory.Actions.Logic.Endif;
import scriptfactory.Actions.Logic.If;
@@ -207,4 +209,15 @@ public class VarsMethods {
}
gainedXP -= baseXP;
}
public static SceneObject customGetSceneObject(int id) {
//Sometimes finds things like trapdoors that aren't otherwise found
for (SceneObject object : SceneObjects.getAllSceneObjects()) {
if (object != null && object.getId() == id)
{
return object;
}
}
return null;
}
}