File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -227,8 +227,11 @@ void __cdecl My_G_RunFrame(int time) {
227227
228228 G_RunFrame (time );
229229
230- // Agent usercmd is now applied via set_usercmd() in Python
231- // The C functions check skipFrameDispatcher before accessing game state
230+ // Call AfterFrameDispatcher AFTER game logic (including bot AI) has run.
231+ // This allows Python to override view angles that bot AI may have set.
232+ if (!skipFrameDispatcher ) {
233+ AfterFrameDispatcher ();
234+ }
232235}
233236
234237char * __cdecl My_ClientConnect (int clientNum , qboolean firstTime , qboolean isBot ) {
Original file line number Diff line number Diff line change @@ -97,14 +97,16 @@ def __init__(self):
9797 if self .ENABLE_STATE_LOOP :
9898 self .add_hook ("frame" , self .handle_game_frame )
9999 minqlx .console_print ("[ql_agent] Frame hook registered for state publishing" )
100+ # Register after_frame hook for agent input control
101+ # This runs AFTER G_RunFrame (including bot AI), allowing us to override
102+ # any view angles the bot AI may have set
103+ self .add_hook ("after_frame" , self .handle_after_frame )
104+ minqlx .console_print ("[ql_agent] After-frame hook registered for agent input override" )
100105 # CRITICAL: Start DISABLED - only enable after confirming game is ready
101106 # This prevents crashes during initial server startup
102107 self ._safe_to_run = False # Flag to pause state loop during transitions
103108 self ._game_restarting = False # Flag to block commands during restart
104109 self ._startup_check_count = 0 # Counter for startup safety checks
105- # NOTE: after_frame Python hook disabled - inputs now applied directly in C
106- # after G_RunFrame to avoid Python callback crashes during shutdown.
107- # Python sets usercmd via set_usercmd(), C applies it after G_RunFrame.
108110
109111 # Track current input state for the agent (button simulation)
110112 # These persist across frames until changed
You can’t perform that action at this time.
0 commit comments