cetteup / bf2autospectator Goto Github PK
View Code? Open in Web Editor NEWAn automated spectator for Battlefield 2 written in Python
License: MIT License
An automated spectator for Battlefield 2 written in Python
License: MIT License
When the round end screen is visible between two rounds on the same map, the bot sometimes performs a map rotation reset because it determined that the map is loading. Due to the map reset, it then tries to spawn with random coordinates.
2022-11-15 12:41:19,090 INFO Game is on round finish screen
2022-11-15 12:41:23,291 INFO Game is on round finish screen
2022-11-15 12:41:27,493 INFO Game is on round finish screen
2022-11-15 12:41:31,675 INFO Game is on round finish screen
2022-11-15 12:41:35,842 INFO Game is on round finish screen
2022-11-15 12:41:40,090 INFO Map is loading
2022-11-15 12:41:40,091 INFO Performing map rotation reset
2022-11-15 12:41:47,370 INFO Enabling hud
2022-11-15 12:41:51,186 INFO Determining team
2022-11-15 12:41:51,254 INFO Spawning once
2022-11-15 12:41:51,474 WARNING Spawn point coordinates not available current combination of map/size/game mode (None/-1/None), switching to spawn point coordinate randomization
It may make sense to base the map loading detection on histograms of the header icons/buttons instead of the current OCR approach.
When conman is not available (e.g. because it was removed based on an AV detection false positive), the bot crashes due to an unhandled exception.
2022-12-03 00:51:47,107 INFO Starting new game instance
Traceback (most recent call last):
File "BF2AutoSpectator\spectate.py", line 636, in <module>
File "BF2AutoSpectator\spectate.py", line 225, in run
File "BF2AutoSpectator\game\instance_manager.py", line 91, in launch_instance
File "BF2AutoSpectator\game\instance_manager.py", line 77, in prepare_game_launch
File "BF2AutoSpectator\common\utility.py", line 428, in run_conman
File "subprocess.py", line 503, in run
File "subprocess.py", line 971, in __init__
File "subprocess.py", line 1440, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
[7532] Failed to execute script 'spectate' due to unhandled exception
The most recent version does not detect game freezes ("Not responding") anymore.
This issue is an 0.6.5 regression caused by Use psutil to check process status and kill processes.
Since the game is running in windowed mode, the bot can move the cursor anywhere on screen if it's in the menu/on the loading screen. In rare cases, it does move the mouse outside the game windows and clicks there. At least I noticed the bot being paused due to text in Powershell being highlighted without any recent user login on a headless VM.
Possible solution: ensure cursor is within game window rectangle before executing any clicks.
The recently updated end of round screen detection based on histograms (Detect map loading based on eor screen item histograms) is leading to some false positives. The eor screen is randomly detected mid game, leading to a map rotation reset followed by a random-based spawn (map info is reset by rotation reset and thus not available).
Related to #31
2022-11-24 15:14:18,759 INFO Nothing to do, stay on player
2022-11-24 15:14:21,521 INFO Rotating to next player
2022-11-24 15:14:22,497 INFO Game is on round finish screen
2022-11-24 15:14:29,336 INFO Enabling hud
2022-11-24 15:14:33,318 INFO Determining team
2022-11-24 15:14:33,384 DEBUG Detected team is 1
2022-11-24 15:14:33,384 DEBUG Current team index is 1 (MEC/CHINA/...)
2022-11-24 15:14:33,384 INFO Spawning once
2022-11-24 15:14:33,589 WARNING Spawn point coordinates not available current combination of map/size/game mode (None/-1/None), switching to spawn point coordinate randomization
2022-11-24 15:14:33,589 INFO Attempting to spawn by selecting randomly generated spawn point coordinates
This issue is a 0.6.5 regression.
Normal gameplay is sometimes detected as the default camera view, causing additional switches between players. This is most common on maps with very strong/uniform color schemes (Operation Smoke Screen, Mignight Sun). Due to the uniform colors, random gameplay screenshot's histograms are often very similar to the default camera view histogram.
Possible solutions/improvements
When the server switches to the next level and that next level happens to also be the current level, the map rotation reset removes details required for non-random spawning. However, since the game is staying on the same map, it does not reload it. Thus, the end of screen stays stays on the score list before entering the game again. The map briefing never becomes visible.
Possible fix: Actively open map briefing if on eor screen and join game button is visible.
If the bot continuously fails to disconnect (e.g. because the disconnect/join now button area is blocked by something like the cursor), it never recovers and just keeps trying to disconnect.
Possible solution: Restart game after 1-2 disconnect attempts.
The bot sometimes gets stuck on the spawn menu because the cursor stops moving. It is completely unclear what is causing this, it could be that the game window is not focused properly. Or the cursor get's stuck somehow.
Possible workaround: Check whether cursor is desired position after issuing the move command. If not, restart the game (after a few tries).
I installed the latest stand-alone version. After starting the controller, it is starting BF2 with the correct username, it selects the multplayer server list and from there it keeps telling "connecting to server, re-connecting to server etc
It is not connecting to the gameserver.
The controller currently has extremely limited information about what the bot is doing. In order to e.g. be able to run ads during map loads, the bot needs to send details about the current state to the controller.
It should at least send details about:
If the bot sets switches to radomizing spawn coordinates and does not spawn before the next map loads, the randomize flag is never reset.
The map rotation reset, which resets the flag, is not triggered in such cases.
BF2AutoSpectator/BF2AutoSpectator/spectate.py
Lines 416 to 422 in c402a88
The map rotation reset should probably be run when the map changes without ever entering it.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/release.yaml
actions/checkout v4
actions/setup-python v5
softprops/action-gh-release v1
requirements.txt
Pillow ==10.1.0
PyAutoGUI ==0.9.54
numpy ==1.26.1
opencv_python ==4.8.1.78
pytesseract ==0.3.10
requests ==2.31.0
pywin32 ==306
psutil ==5.9.6
python-socketio ==5.10.0
jellyfish ==1.0.1
obsws-python ==1.6.2
Add a simple controller command to post a message to in-game chat.
If the bot respawns while the player rotation is paused, it stays on itself after the spawn-suicide.
Instead, it should either:
Map loading detection sometimes fails when the game is loading due to the server rotating to the next map. This seems to happen due to an OCR issue when the game shows the different EOR screens (score list, top players, etc).
In theses games, the bot will try to spawn. Due to the recent change in this commit Check if console commands are entered successfully, the bot will restart the game as the console command cannot be entered.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.