using System; using System.Collections.Generic; using System.Linq; const int BIRD_X = 17; const int BIRD_KIND = 9039; const int PIPE_KIND = 5986; const int CONTROL_ID = 630985637; int GetKind(dynamic item) { try { return (int)item.Kind; } catch { return -1; } } void Flap() { Send(Out["UseFurniture"], CONTROL_ID, 0); } int GetBirdY() { foreach (var item in FloorItems) { if (item == null) continue; if (GetKind(item) != BIRD_KIND) continue; if (item.Location.X == BIRD_X) return item.Location.Y; } return -1; } (int gapMin, int gapMax, int pipeX) FindNextPipe() { var pipesByX = new Dictionary>(); foreach (var item in FloorItems) { if (item == null) continue; if (GetKind(item) != PIPE_KIND) continue; int x = item.Location.X, y = item.Location.Y; if (!pipesByX.ContainsKey(x)) pipesByX[x] = new List(); pipesByX[x].Add(y); } var ahead = pipesByX.Keys.Where(x => x >= BIRD_X).OrderBy(x => x).ToList(); if (ahead.Count == 0) return (-1, -1, 99); int closestX = ahead.First(); var wallYs = new HashSet(pipesByX[closestX]); int bestStart = -1, bestEnd = -1, bestSize = 0, gapStart = -1; for (int y = 7; y <= 24; y++) { if (!wallYs.Contains(y)) { if (gapStart < 0) gapStart = y; } else { if (gapStart >= 0) { int size = (y - 1) - gapStart + 1; if (size > bestSize) { bestSize = size; bestStart = gapStart; bestEnd = y - 1; } } gapStart = -1; } } if (gapStart >= 0) { int size = 24 - gapStart + 1; if (size > bestSize) { bestStart = gapStart; bestEnd = 24; } } return (bestStart, bestEnd, closestX); } Log("═══════════════════════════════════════════"); Log(" FLAPPY BOT V7 - CONSERVATIVE CLOSE"); Log("═══════════════════════════════════════════"); long lastFlap = 0; int tick = 0; while (Run) { tick++; int birdY = GetBirdY(); if (birdY < 0) { Delay(30); continue; } var (gapMin, gapMax, pipeX) = FindNextPipe(); int dist = pipeX - BIRD_X; long now = DateTimeOffset.Now.ToUnixTimeMilliseconds(); bool shouldFlap = false; string reason = ""; if (gapMin > 0 && dist <= 15) { int gapCenter = (gapMin + gapMax) / 2; if (dist <= 4) { // VERY CLOSE - ONLY flap if about to hit BOTTOM wall! // Never flap if above center - let gravity do the work if (birdY >= gapMax - 1) { shouldFlap = true; reason = "CLOSE-EMERG"; } else if (birdY <= gapMin + 1) { // Too high - definitely don't flap! shouldFlap = false; reason = "CLOSE-HIGH"; } else { // In gap - DON'T flap, just drift through shouldFlap = false; reason = "CLOSE-DRIFT"; } } else if (dist <= 10) { // MEDIUM - navigate towards center but carefully if (birdY > gapMax - 2) { shouldFlap = true; reason = "MED-LOW"; } else if (birdY < gapMin + 2) { shouldFlap = false; reason = "MED-HIGH"; } else if (birdY > gapCenter + 1) { shouldFlap = true; reason = "MED-ADJ"; } else { reason = "MED-OK"; } } else { // FAR - gentle approach if (birdY > gapCenter + 3) { shouldFlap = true; reason = "FAR-LOW"; } else if (birdY < gapCenter - 3) { shouldFlap = false; reason = "FAR-HIGH"; } else { reason = "FAR-OK"; } } } else { // No pipe - hover if (birdY > 16) { shouldFlap = true; reason = "HOVER"; } } // Emergency ground if (birdY >= 21) { shouldFlap = true; reason = "EMERG"; } // Hard ceiling if (birdY <= 9) shouldFlap = false; if (shouldFlap && (now - lastFlap) >= 100) { Flap(); lastFlap = now; } if (tick % 15 == 0) { string g = gapMin > 0 ? $"gap={gapMin}-{gapMax} d={dist}" : "NO PIPE"; Log($"Y={birdY} | {g} | {reason}"); } Delay(30); }