Keeps the repo root clean - only README.md visible on landing page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
97 lines
2.8 KiB
C#
97 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
// Globale Variablen für den State
|
|
bool isBusy = false;
|
|
Dictionary<int, int> userMap = new Dictionary<int, int>();
|
|
|
|
Log("Heal-Script gestartet. Bitte einmal den Raum neu betreten!");
|
|
|
|
// 1. Reset beim Raumwechsel
|
|
OnIntercept(In.RoomReady, e => {
|
|
userMap.Clear();
|
|
isBusy = false;
|
|
Log("Raum geladen. Tracking aktiv.");
|
|
});
|
|
|
|
// 2. User-Liste aufbauen (Index zu ID Zuordnung)
|
|
OnIntercept(In.Users, e => {
|
|
try {
|
|
var p = e.Packet;
|
|
int count = p.ReadInt();
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
// Standard Habbo User-Parsing
|
|
int id = p.ReadInt(); // Entity ID (Wichtig für den Klick)
|
|
string name = p.ReadString();
|
|
string motto = p.ReadString();
|
|
string look = p.ReadString();
|
|
int index = p.ReadInt(); // Index (Wichtig für den Chat)
|
|
|
|
// Restliche Daten überspringen (Position etc.)
|
|
p.ReadInt(); // x
|
|
p.ReadInt(); // y
|
|
p.ReadString(); // z
|
|
p.ReadInt(); // dir
|
|
int type = p.ReadInt(); // type
|
|
|
|
// In Map speichern
|
|
userMap[index] = id;
|
|
}
|
|
} catch {
|
|
// Parsing Fehler ignorieren (falls Server-Struktur abweicht)
|
|
}
|
|
});
|
|
|
|
// 3. Auf Chat reagieren
|
|
OnIntercept(In.Chat, async e => {
|
|
// Wenn wir gerade beschäftigt sind, ignorieren wir alles
|
|
if (isBusy) return;
|
|
|
|
var p = e.Packet;
|
|
int index = p.ReadInt();
|
|
string message = p.ReadString();
|
|
|
|
// Trigger-Wort prüfen
|
|
if (message.ToLower().Contains("heal")) {
|
|
|
|
// Prüfen ob wir die ID zum User kennen
|
|
if (userMap.ContainsKey(index)) {
|
|
int targetId = userMap[index];
|
|
|
|
// Ablauf starten (in eigenem Task, damit der Chat nicht laggt)
|
|
_ = RunHealRoutine(targetId);
|
|
} else {
|
|
Log($"[Bot] User Index {index} unbekannt. Bitte Raum neu laden!");
|
|
}
|
|
}
|
|
});
|
|
|
|
// 4. Die Logik zum Senden der Befehle
|
|
async Task RunHealRoutine(int targetId) {
|
|
if (isBusy) return;
|
|
isBusy = true; // Sperren
|
|
|
|
Log($"[Bot] Heile User ID: {targetId}");
|
|
|
|
try {
|
|
// Schritt 1: :offer senden
|
|
Send(Out.Chat, ":offer", 0, -1);
|
|
await Task.Delay(600); // Wartezeit für das Menü (anpassen bei Lag)
|
|
|
|
// Schritt 2: 1 senden
|
|
Send(Out.Chat, "1", 0, -1);
|
|
await Task.Delay(600); // Wartezeit für die Zielauswahl
|
|
|
|
// Schritt 3: User anklicken
|
|
// Header "GetSelectedBadges" ist der Standard-Klick auf einen User
|
|
Send(Out.GetSelectedBadges, targetId);
|
|
|
|
} catch (Exception ex) {
|
|
Log($"Fehler: {ex.Message}");
|
|
} finally {
|
|
// Sperre aufheben
|
|
await Task.Delay(200);
|
|
isBusy = false;
|
|
}
|
|
} |