Incredibly specific issue: I need party members to keep their position in the party when there's less than 4 members

I use a lot of common events to do things the basic editor isn't capable of, such as equipment that heals its wearer each turn, or use invisible status effects for a sort of blue-magic system where a specific character can learn some enemy spells by being hit by them.

Unfortunately, lots of event functions have no option to target a specific actor, only a specific spot in the party. Like one skill is supposed to make its user attack multiple times in a row, but since the Force Action command only lets you choose which space in the party to give an extra action - not which character - that skill stops working properly as soon as that character isn't in his usual spot.

I'm hoping to have moments where your party splits for story reasons, but anytime there's less than 4 party members, only the first spots from the left are filled in. So someone who's normally associated with spot number 4 can't be there, breaking a bunch of mechanics tied to that character. Is there any way for me to make a character leave their spot in the party empty when they're absent?
I have the exact opposite in mind that involves a change in what the event-commands are doing.

From what I get, your game has up to or exactly four actors, correct? If not, we can throw the idea below away since you can't go beyond a choice of four in the affected commands.

The following re-define of Interpreter#iterate_battler should make the commands for animations on battle-screen, thrown-in damage-operations aswell as forced actions access the actors-list instead of party-slots, so if everything is going as planned, you can reference actor on ID 001 by choosing slot 1, etc., up to the fourth.

Code:
#==============================================================================
# ** Redirect Party Iteration in Battle Event Commands to Database Order
#------------------------------------------------------------------------------
#  © 2023 KotatsuAkira
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Iterate Battler
  #--------------------------------------------------------------------------
  def iterate_battler(st, si)
    if st == 0
      iterate_enemy(si) {|se| yield se }
    elsif si == -1
      $game_party.actors.each {|sa| yield sa }
    else
      sa = $game_actors[si + 1]
      yield sa if sa
    end
  end
end

~炬燵あ
This works fantastic, thank you so much! I wasn't even sure this would be possible, but this fixes my problem super smoothly.

Original thread: https://forums.rpgmakerweb.com/threads/incredibly-specific-issue-i-need-party-members-to-keep-their-position-in-the-party-when-theres-less-than-4-members.156118/