• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM HELP NEEDED! Random Character Name For Each Created Instance

W

wicked_lizard

Guest
I am Building an RTS Type game and was hoping someone could help,

I want it so that every time an instance of obj_fighter is created, that fighter has a unique name that will be displayed when clicked on or above their head. I can imagine this is quite simple but cant figure it out.

eventually I would like each Instance to have its own stats and what not, can this be done with instances or is it better to create individual objects for each fighter, Keeping in mind their could be over 50 fighters on the map.

I Hope someone can help with this.
 
L

Linkforce

Guest
In the create event of obj_fighter, you could set a variable:

name=choose("ryan","carter","luke")

This would make each instance of fighter have variable with a name chosen from one of those.
You could also have name equal a random number, then do a switch statement based the number chosen.
Hope this helped.
 
Last edited:
F

Flip

Guest
Or you could fill a ds_list with names, and remove the name from the top of the list. That could help make it so a name can't be chosen again.
 
W

wicked_lizard

Guest
That's perfect I never thought of that simple solution, I guess going further I would like to expand on the Instance and understand how that variable is stored. for example what if I wanted to change that name manually mid-game. or make each fighter have stats that can be upgraded over time.

I wonder what the best solution to this is

Thanks for your help though
 
Do you want 'normal' names - or are you ok with strange 'fantasy' sounding names. You could have a bunch of starting, middle and end pieces that randomize.

Like (but make these lists really long with tons and tons of choices.
start = choose('Da','Ma','La','De','Me','Le');
middle = choose('ra','ze','bo','ru','ma','ko');
start = choose('rud','qid,'zar','po','jep','bop');

name = start + middle + end; // psuedo code here...

Name would be stuff like Dararud or Merubop... (all depending on your various 'parts').

And if you want to guarantee no duplicates, add to a list and check against... But, if you have enough choices, I doubt duplicates will be common.
 
Last edited:
That's perfect I never thought of that simple solution, I guess going further I would like to expand on the Instance and understand how that variable is stored. for example what if I wanted to change that name manually mid-game. or make each fighter have stats that can be upgraded over time.

I wonder what the best solution to this is

Thanks for your help though
This stuff is all possible, but you need to create an interface to interact with the final variables that stores that name (and stats, etc...).
 
W

wicked_lizard

Guest
Thanks again, I think I have an Idea how to implement what I need to, Ill have a blast when I am home from work. and post again if I get stuck, this can be set as solved if needs be.
 
Top