xabbo-scripts/Scripts/Roller Surf Game Bot.csx
Administrator 7a548130a3 Move all scripts into Scripts/ subfolder
Keeps the repo root clean - only README.md visible on landing page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 09:49:37 +01:00

172 lines
4.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
// ═══════════════════════════════════════════════════════════════════════════════
// ROLLER SURF BOT
// ═══════════════════════════════════════════════════════════════════════════════
const int PILLOW_ID = 893412986;
const int GATE_ID = 2147418143;
const int MARBLE_TILE_ID = 2147418142;
const int TICK_DELAY = 50;
const int MOVE_COOLDOWN = 150;
HashSet<int> greenRollers = new HashSet<int> {
2147418115, 2147418119, 2147418133,
2147418134, 2147418135, 2147418136
};
bool gameStarted = false;
DateTime lastMoveCmd = DateTime.MinValue;
int GetId(dynamic item) { try { return (int)item.Id; } catch { return 0; } }
(int x, int y) GetPillowPos()
{
foreach (var item in FloorItems)
{
if (item == null) continue;
if (GetId(item) == PILLOW_ID)
return (item.Location.X, item.Location.Y);
}
return (-1, -1);
}
(int x, int y) GetMarbleTilePos()
{
foreach (var item in FloorItems)
{
if (item == null) continue;
if (GetId(item) == MARBLE_TILE_ID)
return (item.Location.X, item.Location.Y);
}
return (-1, -1);
}
(int x, int y) GetMyPos()
{
try { return (Self.Location.X, Self.Location.Y); }
catch { return (-1, -1); }
}
bool IsAdjacent(int x1, int y1, int x2, int y2)
{
int dx = Math.Abs(x1 - x2);
int dy = Math.Abs(y1 - y2);
return (dx == 1 && dy == 0) || (dx == 0 && dy == 1);
}
int GetTargetIdAt(int x, int y)
{
foreach (var item in FloorItems)
{
if (item == null) continue;
if (item.Location.X != x || item.Location.Y != y) continue;
int id = GetId(item);
if (id == GATE_ID || greenRollers.Contains(id))
{
return id;
}
}
return -1;
}
(int x, int y, int id) FindAdjacentTarget(int px, int py)
{
int[] dX = { 1, -1, 0, 0 };
int[] dY = { 0, 0, 1, -1 };
for (int i = 0; i < 4; i++)
{
int checkX = px + dX[i];
int checkY = py + dY[i];
int targetId = GetTargetIdAt(checkX, checkY);
if (targetId != -1)
{
return (checkX, checkY, targetId);
}
}
return (-1, -1, -1);
}
Log("═══════════════════════════════════════");
Log(" ROLLER SURF BOT");
Log("═══════════════════════════════════════");
while (Run)
{
Delay(TICK_DELAY);
var pillow = GetPillowPos();
var myPos = GetMyPos();
var marbleTile = GetMarbleTilePos();
if (pillow.x == -1 || myPos.x == -1) continue;
bool onPillow = (myPos.x == pillow.x && myPos.y == pillow.y);
bool onMarbleTile = (marbleTile.x != -1 && myPos.x == marbleTile.x && myPos.y == marbleTile.y);
if (!gameStarted)
{
if (onMarbleTile)
{
Log("Start!");
Send(Out["MoveAvatar"], pillow.x, pillow.y);
gameStarted = true;
lastMoveCmd = DateTime.Now;
continue;
}
if (onPillow)
{
gameStarted = true;
Log("GO!");
continue;
}
if (IsAdjacent(myPos.x, myPos.y, pillow.x, pillow.y))
{
Send(Out["MoveAvatar"], pillow.x, pillow.y);
gameStarted = true;
lastMoveCmd = DateTime.Now;
continue;
}
continue;
}
if (!onPillow)
{
if ((DateTime.Now - lastMoveCmd).TotalMilliseconds > MOVE_COOLDOWN)
{
Send(Out["MoveAvatar"], pillow.x, pillow.y);
lastMoveCmd = DateTime.Now;
}
continue;
}
var target = FindAdjacentTarget(pillow.x, pillow.y);
if (target.id == -1) continue;
if (target.id == GATE_ID)
{
Log("GATE!");
Send(Out["UseFurniture"], GATE_ID, 0);
gameStarted = false;
Delay(300);
continue;
}
Send(Out["MoveAvatar"], target.x, target.y);
Delay(TICK_DELAY);
var newPillow = GetPillowPos();
if (newPillow.x != -1)
{
Send(Out["MoveAvatar"], newPillow.x, newPillow.y);
lastMoveCmd = DateTime.Now;
}
}