xabbo-scripts/Scripts/Roller Gate 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

122 lines
3.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
// ════════════════════════════════════════════════════
// FIXED ROLLER BOT (Ohne Schnickschnack)
// ════════════════════════════════════════════════════
// IDs
int pillowId = 893412986;
int gateId = 2147418143;
List<int> rollers = new List<int> {
2147418115, 2147418119, 2147418133,
2147418134, 2147418135, 2147418136
};
// Einstellungen
int delay = 130; // Wartezeit auf dem Roller (ms)
// Speicher für Koordinaten: Key=ItemID, Value=[x, y]
Dictionary<int, int[]> coords = new Dictionary<int, int[]>();
bool active = false;
Log("Bot gestartet. BITTE RAUM NEU LADEN!");
// 1. Alles scannen beim Raum betreten
OnIntercept(In.RoomReady, e => { coords.Clear(); active = false; });
OnIntercept(In.Users, e => { coords.Clear(); active = false; });
OnIntercept(In.FloorItems, e => {
var p = e.Packet;
int n = p.ReadInt();
for(int i=0; i<n; i++) {
int id = p.ReadInt();
int type = p.ReadInt();
int x = p.ReadInt();
int y = p.ReadInt();
p.ReadInt(); // rot
p.ReadString(); // z
p.ReadString(); p.ReadInt(); p.ReadInt(); p.ReadString(); // skip rest
coords[id] = new int[] { x, y };
}
if (coords.ContainsKey(pillowId)) {
active = true;
Log("Kissen gefunden. Bot bereit.");
}
});
// 2. Bewegung erkennen
OnIntercept(In.SlideObjectBundle, e => {
if (!active) return;
var p = e.Packet;
int oldX = p.ReadInt();
int oldY = p.ReadInt();
int newX = p.ReadInt(); // Ziel X
int newY = p.ReadInt(); // Ziel Y
int count = p.ReadInt();
bool pillowMoved = false;
for(int i=0; i<count; i++) {
int id = p.ReadInt();
p.ReadString(); // z1
p.ReadString(); // z2
// Position updaten
if (coords.ContainsKey(id)) {
coords[id][0] = newX;
coords[id][1] = newY;
}
if (id == pillowId) pillowMoved = true;
}
if (pillowMoved) {
// Logik in separaten Task auslagern damit Packet nicht blockiert
_ = RunLogic(newX, newY);
}
});
// 3. Die Logik
async Task RunLogic(int px, int py) {
// 4 Richtungen prüfen: Oben, Unten, Links, Rechts
int[][] checks = new int[][] {
new int[]{0, 1}, new int[]{0, -1}, new int[]{1, 0}, new int[]{-1, 0}
};
foreach(var offset in checks) {
int cx = px + offset[0];
int cy = py + offset[1];
// Prüfen ob an cx/cy ein erlaubter Roller oder das Gate liegt
int foundId = -1;
foreach(var kvp in coords) {
if (kvp.Value[0] == cx && kvp.Value[1] == cy) {
if (rollers.Contains(kvp.Key) || kvp.Key == gateId) {
foundId = kvp.Key;
break;
}
}
}
if (foundId != -1) {
if (foundId == gateId) {
Log("Gate gefunden! Benutze es.");
Send(Out.UseFurniture, gateId, 0);
return;
} else {
// Es ist ein Roller -> Hin und Zurück
Send(Out.MoveAvatar, cx, cy);
await Task.Delay(delay);
Send(Out.MoveAvatar, px, py);
return;
}
}
}
}