Lead Actor Swapper script error
#20
(09-06-2025, 06:50 AM)kyonides Wrote: That can be done via event commands, but I wouldn't waste the chance to Sculptor craft a script for this purpose.

Code:
# * Kuick Leader Swap XP * #
#   Scripter : Kyonides
#   2025-09-06

class Game_Party
  def change_leader(n)
    if n < 0
      @actors.unshift @actors.pop
    else
      @actors << @actors.shift
    end
  end

  def temp_leader=(n)
    @temp_leader_index = n
    @actors[0], @actors[n] = @actors[n], @actors[0]
    $game_player.refresh
  end

  def restore_leader
    n = @temp_leader_index
    @actors[0], @actors[n] = @actors[n], @actors[0]
    @temp_leader_index = nil
    $game_player.refresh
  end

  def leader
    @actors[0]
  end
end

class Game_Player
  alias :kyon_kuick_leader_swap_gm_plyr_up :update
  def update
    kyon_kuick_leader_swap_gm_plyr_up
    if Input.trigger?(Input::L)
      $game_party.change_leader(-1)
      refresh
      return
    elsif Input.trigger?(Input::R)
      $game_party.change_leader(1)
      refresh
    end
  end
end

Temporarily Change the Leader:

Code:
$game_party.temp_leader = Index

Restore the Original Leader to his rightful place:

Code:
$game_party.restore_leader

SIDE NOTE

I think Dog Wulfo inverted the order of how the actors should cycle and that's why Ace_V got an unexpected result there. Yet, it's interesting to learn that it duplicated actors the more he used the swap feature.

Oh SWEET! Thank you! I'll test this out. So Aluxes = index value of of 1, correct? (I assume when I do a script call to make Aluxes the lead, it'll be  $game_party.temp_leader = 1)
EDIT: seems putting 1 just swaps the current 2nd (actor1?) in the caterpillar with the lead (actor0?), so I don't know how to swap the specific character (Dorothy--regardless of her position on the caterpillar--into the lead to swap with the current leader, for example)

My plan is to use conditional branches to first check if a character is in the party (there are more than 4 characters in my game, so most will be in reserve), then run your script call to make that character the lead. I try to ensure the right characters are in the party for specific cutscenes, but in case said character isn't in the party for some reason, then I won't run the script call.


Some questions:

1. The code notes a temporary leader and storing that value. What if I don't intend to restore that leader at all (the player is free to swap back or to some other character entirely after the cutscene) but then the player goes to another cutscene that requires a different character as the lead, and I run a script call for that character, does it replace the value stored without any issues? (From my limited script knowledge, I assume it'll be fine.)

2. What happens if in between those two cutscenes, the player accesses party change and removes the "original" leader from the party (moving them into the reserve) and I call the restore leader script? (I'll probably never call the restore script anyway, but I wanted to know in the off chance that I do.  Laughing )

Quote:it's interesting to learn that it duplicated actors the more he used the swap feature.

I didn't word that properly, sorry! I meant that it moved the original lead further down the caterpillar, but only the caterpillar (the leader remains that same duplicate).

So it went from
Quote:1. Aluxes
2. Basil
3. Cyrus
4. Dorothy

to
Quote:1. Aluxes
2. Aluxes
3. Cyrus
4. Dorothy

to
Quote:1. Aluxes
2. Cyrus
3. Aluxes
4. Dorothy

to
Quote:1. Aluxes
2. Cyrus
3. Dorothy
4. Aluxes

And Basil just disappears from the caterpillar altogether without a way to bring him back (even though he's still in the party when you check status / equipment)
[Image: SP1-Writer.png]
[Image: SP1-PixelArtist.png]
Reply


Messages In This Thread
Lead Actor Swapper script error - by Ace_V - 08-29-2025, 07:32 AM
RE: Lead Actor Swapper script error - by kyonides - 08-30-2025, 05:01 AM
RE: Lead Actor Swapper script error - by kyonides - 08-30-2025, 10:01 PM
RE: Lead Actor Swapper script error - by Ace_V - 08-31-2025, 07:44 AM
RE: Lead Actor Swapper script error - by kyonides - 08-31-2025, 10:11 AM
RE: Lead Actor Swapper script error - by Ace_V - 09-02-2025, 09:33 AM
RE: Lead Actor Swapper script error - by kyonides - 09-02-2025, 10:55 AM
RE: Lead Actor Swapper script error - by kyonides - 09-02-2025, 04:10 PM
RE: Lead Actor Swapper script error - by Ace_V - 09-04-2025, 03:09 AM
RE: Lead Actor Swapper script error - by Ace_V - 09-05-2025, 06:30 AM
RE: Lead Actor Swapper script error - by Ace_V - 09-05-2025, 08:41 AM
RE: Lead Actor Swapper script error - by kyonides - 09-05-2025, 03:10 PM
RE: Lead Actor Swapper script error - by Ace_V - 09-06-2025, 05:49 AM
RE: Lead Actor Swapper script error - by kyonides - 09-06-2025, 06:50 AM
RE: Lead Actor Swapper script error - by Ace_V - 09-06-2025, 07:39 AM
RE: Lead Actor Swapper script error - by kyonides - 09-06-2025, 08:25 AM
RE: Lead Actor Swapper script error - by Ace_V - 09-06-2025, 09:47 AM
RE: Lead Actor Swapper script error - by kyonides - 09-06-2025, 10:42 AM
RE: Lead Actor Swapper script error - by Ace_V - Yesterday, 04:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Actor Voices by diamondandplatinum3, note-tag commands not working! Starmage 1 524 08-04-2025, 09:02 AM
Last Post: Starmage
   Plugin or Script help with Item menu, SKill menu, and Equip menu JayRay 3 2,796 11-22-2024, 07:02 PM
Last Post: JayRay
   Atoa ACBS, Equipment Set Add-on Error Solitaire 10 5,895 10-13-2024, 11:41 PM
Last Post: Solitaire
   Personal graph by actor zlsl 4 7,898 10-23-2021, 06:43 AM
Last Post: zlsl
   Script compatibility help Lord Vectra 3 7,111 07-25-2021, 11:42 PM
Last Post: DerVVulfman
   Adding face script on Cogwheel's RTAB Battle Status rekkatsu 15 22,382 08-25-2020, 03:09 AM
Last Post: DerVVulfman
   "Wait" in the script Whisper 13 21,683 04-28-2020, 04:06 PM
Last Post: Whisper
   Skill Cooldown script Fenriswolf 11 21,617 12-10-2019, 11:10 AM
Last Post: Fenriswolf
   (RMVXace) Battle error with Tankentai's battle system, help. x( Starmage 0 5,059 02-14-2018, 04:25 PM
Last Post: Starmage
   Help iwth script (RGSS Player crash) Whisper 3 10,488 06-17-2017, 05:03 PM
Last Post: Whisper



Users browsing this thread: 1 Guest(s)