Small random character generator script I made

Hi all;

I'm using PVGames resources in my own project, and a thing I (and probably most of you) found really time consuming was creating characters. It's okay for few named characters, but if you need 30-300 NPC graphics... yeah, it takes time. That's why I decided to waste time to save time and made myself a script that will make them for me.

Now, few things to start with - this script is not too user friendly. You need to prepare your folder layout, and install few small tools for it to work. But once you do, you are two clicks away from making a random character. Seems like a good tradeoff 😉

Here's a pastebin containing the script (It's Ruby btw). Now let's go into details.

For script to work, you need the following:

- Ruby (I used 2.2), and devkit tools
- ImageMagick (I used 32 bit 6.9.7.9-Q8-x86)
- gem mini_magick (gem install mini_magick)

And the prep: First of all, things inside script you might want to change:
- Line 9 has a hash array of layers used by both genders (line 10 for male, 11 for female). It's in the order the files are being assembled - in my code it's shadow, base, pants, feet (shoes), top etc.).

- Line 14 has an array with list of poses you're using in your game. Make sure they are the same as ends of files (ie. "Medieval_TC_Male_2_collapse.png"). I'm not using all of them in my game, so I skipped those, but you are free to add them yourself (Note: don't add face and body graphics, I'll explain later).

- Line 17 has another hash array with percentage chances of a layer appearing in the file. They're corresponding to layers from line #9 (so ie. 5th number in male array is the percentage chance of randomly generated character having an item from your "top" folder)

- Lines 22 and 35 have max numbers of folders you have. I'll explain that below

Folder Structure

Now, this is just a guideline, and you can alter the structure of folders in whatever way you want - provided you will change few lines of code, mainly the ones listed above 😉

There are two main folders: male and female. Inside, you have separate folders for each category/layer listed in line 10, 11. Inside you have more folders - named 1...n, depends on how many different elements you have. And inside are your files. I pretty much copied folders from PVG packs and just renamed them (ie "Medieval_T&C_Male_Hair_6_Alt_4" to 32). Make sure you update numbers in the hashes at lines 22 and 35. Let's say your male/pants folder has 12 elements, then your 25th line will contain ' "pants" =>12,', etc.


Now that *should* be it when it comes to preparation. Now just run the script - you will be prompted to choose whether you want to create a Male (m) or Female (f) character. Type corresponding letter, hit enter and the script will create a random character, with all poses listed in line #14. Filenames will be output_POSE.png, and they will be saved in the main folder (the one you should put your script in). The script will also save a layers.txt file, listing all files used for this particular graphic.


Facesets and Body Graphics

I mentioned not to use this to create facesets and body graphics. The reason for that is I didn't put any failsafe in case a graphic is missing - the script will just crash if something's not there. It should be okay for spritesets, but not all elements have a face or body graphic (especially stuff like shoes, pants).


End Word

You are free to use the script freely, and alter it in any way you find necessary. If you can "upgrade" it somehow (ie. add faceset generation, extra failsafes, ability to generate multiple graphics, etc) be free to do so!

I hope this will help at least some of you with your game making trip 😉
That is really great! Wonderful work 🙂
There is a stand-alone application that allows for quick and easy character creation (has some folks test an early version of the software not long ago). A few add-ons and fixes are being implemented now and then it should be released once all is good. Hopefully that will prove helpful too 🙂
Thanks! And I know, before I decided to write it I played around with other options. I tried to use Game Character Hub, but I needed to make sure that a random Idle graphic *will* be the same as a random Walking, or Running graphic. Other option would be using Mastersheets (and I'd probably put extra effort into it if the script wouldn't work) - but slicing them would be a pain in the butt. I tried making a photoshop action that would do it, but it didn't work well. Maybe if I'd do some sort of slicing template it would work better...
The software being made already does that (creates all of the different spritesheets along with each bust, faceset, paperdoll, etc). Some extra options are being added in to make life a bit easier and give more control. For example, hue/color adjusters have been added so you can easily recolor any layer. Incase you haven't seen it so far:

EfdGHgM.png


What it allows you to do is add any items located in the resource pack folders that you put inside the main directory folder for the software (so just drag and drop the character folders into the main directory). This will make the software load everything up when it starts and you can freely add/remove pieces as you want, arrange the layers as you see fit (so some can be above or below other layers depending on the look you want). As you can see in this example picture, I need to lower the chainmail around his neck to be a layer below the pauldrons. The software also allows you to toggle adding shadows to the spritesheets or not easily, you can also hide/unhide layers (not shown in the outdate screenshot above), change color of objects (also not shown) and possible a few other nifty features forthcoming. When you press "save", whatever name you put in, the software will churn out all spritesheets, faces, busts, paperdolls, etc with that name, example: "Ghamond_Default, Ghamond_Paperdoll, Ghamond_Bust_1" and so forth.
I did not see it, but I will definitely use it! But until it's made, well, there's a small alternative now 😀
I didn't mean to make light of your contribution or anything 🙂 It is greatly appreciated!

Original thread: https://forums.rpgmakerweb.com/threads/small-random-character-generator-script-i-made.75127/