Drafting Random Actors to Join your Party

volcanobrian

Villager
Member
Joined
Aug 31, 2015
Messages
7
Reaction score
0
First Language
English
Primarily Uses
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.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
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
 

volcanobrian

Villager
Member
Joined
Aug 31, 2015
Messages
7
Reaction score
0
First Language
English
Primarily Uses
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!
 

volcanobrian

Villager
Member
Joined
Aug 31, 2015
Messages
7
Reaction score
0
First Language
English
Primarily Uses
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
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
use 1 and not 0001 
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
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] = [ ]
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
You're welcome!
 

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

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top