Why is the command window shifted over? (VX Ace)

I recently made a script that instantly casts a spell on selection, and then gives the caster their turn back. While the code does work, immediately after it triggers, selecting either the “attack” or “skill” commands causes the following visual bugs.

  • “Attack” selected:

  • “Skill” selected:

The command window remains “shifted” over until either the start of the next turn, or I press “x” to make the fight/escape menu options appear. I have spent the last few days trying to figure out what causes this, to little avail, so any help would be greatly appreciated. The script that triggers the automatic attack is as follows (portions irrelevant to the problem have been excluded):

class Scene_Battle < Scene_Base
def autoSend
item = BattleManager.actor.input.item
return unless item.is_a?(RPG::Skill) && item.canAutoSend
@ subjectsubject = BattleManager.actor
execute_action
process_action_end
process_event #Activate any battle events that may have triggered.

@ status_window.unselect
@ status_window.open
@ subject.input.clear
subject = nil
prior_command #give back turn

end

I’m wondering if the Fight/Escape window is still active even though it’s closed. In the default Scene_Battle, update_info_viewport slides the whole bottom area one way when the party command window is active and the other way when the actor command window is active. If both are active at once, the two moves cancel out every frame and it just stays where it is.

That could explain why it only shows up once you pick Attack or Skill. Picking a command deactivates the actor command window, so the party command window is the only active one left and it pulls everything over to its side. Pressing x sets the party command window up again, and choosing Fight deactivates it the normal way, which would be why that clears it.

If the caster is your first actor, prior_command goes to start_party_command_selection, which activates the party command window. start_actor_command_selection only closes it and never deactivates it, so if your code then hands the caster their actor commands, the party window could stay active in the background.

Try this code, maybe it could stop the issue:

class Scene_Battle < Scene_Base
  alias autosend_start_actor_command_selection start_actor_command_selection
  def start_actor_command_selection
    @party_command_window.deactivate
    autosend_start_actor_command_selection
  end
end

Thank you so much for helping me (again LOL)! This fixed the problem I was having.