Drafting Random Actors to Join your Party

Hi Folks, 


I am trying to streamline the process of drafting a new actor to join my party from a pool of applicants. I have approximately 100 actors in the database from which I want events throughout the game to randomly select actors, one at a time, to ask to join. Basically, I believe I need a random number variable to tie directly to the actor's number. Additionally, I would like the script to filter out actors that have already been drafted. Is this possible? Right now my solution is hundreds of conditional branches, but before diving into that, I thought I'd give the forum a try.


Thanks for your thoughts and expertise.
You don't really need a script for this.


All you need is an event based procedure to do that. But will require some ruby script calls to build up that chosen database (array).


You will require at least 1 game variable for the database and one game variable to do the random actor choosing.


Simply compare database with the current random number chooser and redo a choose sequence if the number exist.


eg.
Game Variable [1] = [1, 4, 6, 7, 10, 99]
means V1 contains the a series of numbers for the chosen actors in the format of an array.

Game Variable [2] = random number 1 - 100
Condition branch: If Game Variable [1] include Game Variable [2], redo random number until it gets a new number not in the database.

Proceed to Confirmation of Yes or No to add that actor to the party.
If Yes, add that number to database too.




Script calls to manipulate Game Variables:


adding numbers to array using event script box:


$game_variables[ID_for_database].push(number)


ID_for_database = the game variable id you wish to use


number = the new actor id to add to database


comparing numbers in array for conditional branch script box:


$game_variables[ID_for_database].include?($game_variables[ID_for_random_chooser])


ID_for_database = the game variable id you wish to use


ID_for_random_chooser = the game variable id for random chooser
Brilliant. It will take me some time to sort it, I am sure, but I have my head wrapped around the concept. Thanks for taking the time!
So I understand the principle, but the execution on my part is lacking. I tried using the script calls in a simple event to draft an actor and I get an undefined method error for 'include'. See images below:  


My guess is I am not entering the call in the right place or that I am using a single variable as opposed to an array. My understanding was that a variable could become an array with the push script. 


Forgive me if my jargon is completely off. I am exploring coding for the first time.


Thanks

event.JPG

error.JPG
use 1 and not 0001 
use 1 and not 0001 



I adjusted those, but I still get the same error. 


Thanks for your thoughts.
Well, i am not sure what you put in the later part of the code as the snapshot gets cut-off there. Assuming it's game variable 2 so you should be using something like this:


$game_variables[1].include?($game_variables[2])


if that's the code you use and you are still getting the error.


they try add this somewhere before anything runs, and note that you only need to run this once.

Code:
$game_variables[1] = [ ]
Victory! Thanks for the help 🙂
You're welcome!

Original thread: https://forums.rpgmakerweb.com/threads/drafting-random-actors-to-join-your-party.57477/