#Bot Lifecycle
#Match Flow (FC24 / FC25)
The football bots follow this lifecycle for each match:
#Phase 1: Initialization
Script starts → Connects to WebSocket server
→ Connects to OBS WebSocket
→ Stops existing stream
→ Fetches RTMP server URL from API
→ Configures OBS stream settings
→ Starts OBS stream
→ Loads screen templates
→ Starts screen monitoring
→ Emits "waiting" event to server
→ Emits "myid" event
→ Enters sio.wait() loop#Phase 2: Match Setup (on "new-match" or "starting-match" event)
Receives match data (home, away, league, all_95)
│
▼
Stops current OBS stream
│
▼
Waits for stream to restart
│
▼
Plays pre-recorded sequences:
1. check_for_internet.json → Dismiss popups
2. check_for_outdated.json → Dismiss popups
3. league3.json → Navigate to team selection
│
▼
random_left_arrow() callback handles:
- custom #1: Select home league + set "All 95" rating
- custom #2: Select home team (OCR matching)
- custom #3: Select away league
- custom #4: Select away team (OCR matching)
│
▼
Press Enter to confirm and start match
│
▼
Reset ball address in memory
│
▼
Start memory_listener_thread()#Phase 3: Match Running
memory_listener_thread() runs every 0.5 seconds:
- Read goals, ball position, match time
- Detect match start (ball at 0.5, time=0, score=0-0)
- Emit "start-match" event when detected
- Read statistics (shots, fouls, cards, etc.)
- Emit "match-data" continuously
- Detect halftime via time threshold#Phase 4: Match Events
ScreenComparator detects state changes:
- "pause_screen" → Resume game (press keys)
- "draw_screen" → Handle draw result
- "finished" → Trigger end-of-match flow#Phase 5: End of Match
on_end_stream() triggered:
- Emit "end-match" to server
- Stop memory listener thread
- Play "end-league.json" to navigate back
- Reset flags → ready for next match#Match Flow (Undisputed Boxing)
The boxing bot has a different flow:
#Phase 1: Initialization
Same as football bots, plus:
- Starts
_auto_focus_loop()thread (focuses game window every 1 second) - Loads
coord_pickermodule for coordinate-based detection
#Phase 2: Fight Setup (on "new-match" / "starting-match")
Receives match data (player_1, player_2, weight)
│
▼
Stops OBS stream → Starts new stream
│
▼
Navigates game menus:
1. Press F to start
2. Press R to enter fight setup
3. Handle P1 stuck detection
4. startMatch1() → Select fighters via OCR
│
▼
Weight selection:
- Maps weight class (1-10) to Key.2 presses
│
▼
Fighter selection (Red corner):
- OCR reads first name, last name, player name
- Fuzzy matching with rapidfuzz
- Special cases for known OCR errors
│
▼
Fighter selection (Blue corner):
- Same OCR + fuzzy matching process
│
▼
Set difficulty → Confirm fight
│
▼
Start memory_listener_thread()#Phase 3: Fight Running
memory_listener_thread() runs every 0.5 seconds:
- Read game time and current round
- Detect match start (game_time > 0)
- Read boxer scorecard data
- Detect break time (game_time == 0)
→ Read damage stats from screen pixels
→ Emit "round-break-stats"
- Emit "match-data" continuously#Phase 4: Winner Detection
ScreenComparator detects "winniewinner" screen
│
▼
detect_color_name() reads winner side:
- Red (#8d0000) → player1 wins
- Blue (#0d60c1) → player2 wins
- Grey (#2a2a2a) → draw
│
▼
Emit "winner-detected" + "match-score"
│
▼
Navigate score board → return to main menu
│
▼
Ready for next match