Hello, new guy here.
I thought I'd start by sharing my experience of completing a functional DB3 script using GPT-4.
It's a simple random walk script that sends you wandering about aimlessly, but it works. The challenge was to get GPT-4 to do it instead of lecturing me about the immorality of botting video games and violating the publisher's TOS.
It turns out all I had to do was to tell GPT-4 that I am just a student learning to code in Java and that I'm only using a private OSRS server. I was no longer reminded of my moral inferiority after this. 😂
An additional challenge was to get GPT-4 to stop using deprecated code. Without careful prompting, it will produce DB2 code.
Once all that was sorted out, here's what it came up with:
import org.dreambot.api.input.Mouse;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import java.util.Random;
@ScriptManifest(author = "YourName", category = Category.MISC, name = "Random Walker", version = 1.0)
public class TestScript extends AbstractScript {
private final Area gameWorld = new Area(3000, 3000, 3300, 3300); // Define the area of the game world where the bot will walk
@Override
public int onLoop() {
// Simulate human-like random sleep
if (randomSleep()) {
return Calculations.random(3000, 6000); // Sleep for 3 to 6 seconds
}
// Walk to a random tile within the game world
Walking.walk(gameWorld.getRandomTile());
// Sleep for a random time to mimic human behavior
return Calculations.random(1000, 2000); // Sleep for 1 to 2 seconds
}
private boolean randomSleep() {
int number = new Random().nextInt(100); // Generate a random number between 0 and 99
if (number < 5) { // 5% chance to sleep
log("Random sleep!");
Mouse.moveOutsideScreen(true); // Move mouse outside of screen
return true;
}
return false;
}
}