Force Actor position in party

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Usually when an actor joins the party, they go at the end of the line e.g. position 4.

However, if I want them to go somewhere else in the line e.g. position 2, I have to go through all the bother of taking the other actors out and then adding them back in.

Is there a script call which can force an actor into a particular follower position?

Thanks.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
Yes, you can use something like the following :

Code:
# @actors cannot be accessed normally; use work-around to gain access
party = $game_party.instance_variable_get(:@actors)
# insert(intPosition, dataToInsert)
# The following will place actor #4 to the first position in the party (leader)
party.insert(0, 4)
# Refresh $game_player and $game_map
$game_player.refresh
$game_map.need_refresh = true


# If you want to remove an existing party member, you can include the following with the above
# delete_at(intPosition)
# The following will delete the second actor in the party list
party.delete_at(1)
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Ossra I may not have used this correctly, but putting it into the event gave me this error message

upload_2017-10-5_20-30-33.png
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
Oh, I think the comments I put in are mucking with everything. Remove those before pasting the scriplet into the Script area in the event.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Ossra I think that must have been it, because everything is fine now.

Thank you very much for your help.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Sorry for late reply, but you can also do it with a single script call, using the formation system's ability to swap actors around.

If you want to ensure the new actor goes into position 4, add them to the party with the Change Party Members command. Then ensure there are MORE than 4 members in the party (otherwise you'll get an error trying to swap them into position 4 if nobody else is already there, or you'll just be swapping them with themselves, which is a waste of time). I think you'd need to do Control Variables for that. Then just do a script call to swap the last member added with the position you want them in:

Code:
Change Party Members (add) Bill
Control Variables [015 Party Size] = Game Data > Other > Party Size
Conditional Branch: Variable [015 Party Size] > 4
  Script: $game_party.swap_order($game_party.members.size - 1, 3)
End
size - 1 is to get the last actor you added.
3 is the 4th position (starting counting at 0)

This does an automatic refresh so you don't need to add that step.

Mmm ... that would actually do a swap, so the person previously in that position would be moved to the end. It's not just an insert, shuffling everyone along one slot, so may not have the result you're after.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
@Shaz That is probably a better solution and less prone to explode, really. I have been away from RPGVXA for so long I have forgotten a lot of the default functions.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Only if you actually want to do a swap - move someone else from that position to the end of the lineup. If you just want to shuffle, my method won't be suitable, and you'll need to delete/insert.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Shaz That's really interesting. I can think of a use for that one for something else. Thanks.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top