09-06-2025, 07:39 AM
(This post was last modified: 09-06-2025, 08:07 AM by Ace_V.
Edit Reason: Added testing results
)
(09-06-2025, 06:50 AM)kyonides Wrote: That can be done via event commands, but I wouldn't waste the chance tocraft 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 thinkWulfo 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.

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]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)