How would I give the player a random actor? (RPG Maker MV)

So right now I am playing around with the idea of the player being able to unlock a large amount of actors by collecting items.


What I basically need is one of the following:


A) - An item that can unlock an actor or give the player an actor - How would I do this? 


B ) - A shop which you can pay X amount of gold and you unlock a random actor - How would I do this?


In both of these I need to make sure they cannot get the same actor twice.


I've been trying to figure out how to do it with events but I can't get my head around it, Anyone got any tips? 
common events - either called by an item or triggered by one of the common event shop plugins/scripts.


In all cases, the common event will then use control variables to get a random number, then conditional branches to check which number that is and then again conditional branches to see if the actor is in the party or if it needs to be added.
common events - either called by an item or triggered by one of the common event shop plugins/scripts.


In all cases, the common event will then use control variables to get a random number, then conditional branches to check which number that is and then again conditional branches to see if the actor is in the party or if it needs to be added.



Thanks I'll give this a bash!
This script call will allow you to add an actor by a variable:


$gameParty.addActor(actorId), specify a number or use $gameVariables.value(id) with id being the number of the variable.


$gameParty.removeActor(actorId) to remove.


Checking if an actor is in party by id is a little more complicated but here is the code:


var i = 0
var list = []
while (i < $gameParty.size()) {
list.push($gameParty.members().actorId())
i++
}
//list is now an array containing the id of every party member.
$gameVariables.setValue(1,list)
//variable 1 is now equal to list
//Use the following code in condition: script to check if member is in party
$gameVariables.value(1).contains(actorId)





So, like the above poster said, make the item trigger a common event, then use the above script calls to add the party member you want to add (or set a variable to a random number and then use the above script calls) and check if it's present in the party or not.


It's going to save you a lot of conditions checks to do it via those script call 🙂


Hope i helped!

Original thread: https://forums.rpgmakerweb.com/threads/how-would-i-give-the-player-a-random-actor-rpg-maker-mv.62986/