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 😉
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 😉