mirror of
https://github.com/bdnugget/rs-sdk.git
synced 2026-11-07 09:07:30 +00:00
Fix bot loc interaction: walk-to-loc before OPLOC (274 client-routefinder)
274's clientRoutefinder mode makes the server expect the *client* to send the movement path to an interaction target; it no longer pathfinds to locs itself. The bot's Client.interactLoc() sent only the OPLOC packet with no movement, so the player never walked and the server replied "I can't reach that!" whenever it wasn't already adjacent. This broke every bot.* action that walks-then- interacts with a loc (chopTree, mine, openDoor, openBank-from-afar, etc.). Mirror the existing useItemOnLoc(): convert world->scene coords and call tryMove(...type=2) with the loc footprint before writing OPLOC, so the client routefinder emits the path. Verified locally (clientRoutefinder=true): a bot 4 tiles from a tree now auto-walks adjacent and chops it (+625 wc xp), where it previously failed with "I can't reach that!". Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
00aa39a318
commit
d3c390330b
1 file changed
+15
-1
@@ -2093,10 +2093,24 @@ export class Client extends GameShell {
|
||||
* Interact with a location/object in the world (doors, trees, etc.)
|
||||
*/
|
||||
interactLoc(worldX: number, worldZ: number, locId: number, optionIndex: number): boolean {
|
||||
if (!this.ingame || !this.out || optionIndex < 1 || optionIndex > 5) {
|
||||
if (!this.ingame || !this.out || !this.localPlayer || optionIndex < 1 || optionIndex > 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Walk to the loc first so the server receives a movement path. In 274's
|
||||
// client-routefinder mode (Environment.node.clientRoutefinder) the server does
|
||||
// NOT pathfind to interaction targets itself — it expects the client to send the
|
||||
// route. Sending OPLOC alone never moves the player, so the server replies
|
||||
// "I can't reach that!" whenever we aren't already adjacent. Mirrors useItemOnLoc.
|
||||
const destSceneX = worldX - this.mapBuildBaseX;
|
||||
const destSceneZ = worldZ - this.mapBuildBaseZ;
|
||||
if (destSceneX >= 0 && destSceneX <= 103 && destSceneZ >= 0 && destSceneZ <= 103) {
|
||||
const loc = LocType.list(locId);
|
||||
if (loc) {
|
||||
this.tryMove(this.localPlayer.routeX[0], this.localPlayer.routeZ[0], destSceneX, destSceneZ, false, loc.width, loc.length, 0, 0, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
const opcodes = [
|
||||
ClientProt.OPLOC1,
|
||||
ClientProt.OPLOC2,
|
||||
|
||||
Reference in new issue
Block a user