I need help making an NPC Generator in codeblocks. I have gotten the name your NPC part down, I just need help on making random stuff such as numbers and bios or even names. I don't think it will be that hard
Numbers I would recommend using a random number generator. I know there's rand() which takes from <cstdlib> but I think there might be a better true random number generator in C++ I forgot the name of. You could make it so your rand() only generates between a range of 1-20 for initial roll stats. I haven't played in a while so I have no idea what each class's bonuses are and whatnot.
For names, either have an external text file list that you can pull random names/bios from, or store them in an internal vector/array (which I highly recommend against because that would just make your program bigger and slower to run).
You want to look into context-free grammar.
You declare a set of rules which are used to generate end result.
For example:
<human name> = <first name> <last name>
Your program will generate first name by further rules (probably by selecting one randomly from corresponding text file) then last name and put them in that order separated by space. Later you can add other grammars for other names (look for real world examples. Northern and Arabic naming systems, for example, would be a good start).
<north name> = <north first name> <north male first name><gender suffix>
Here you see your given name following by contacenated father name and gender suffix.
The same could be applied to bios. In this case it would look like madlibs:
1 2 3 4 5 6 7 8 9
//General grammar
<bio> = <early ages>\n<start of travels>\n<current occupation>
//One of the early ages entry in some file
Not much known about <human name>.
Some people says that he came from a <region>, but nobody had been able to confirm such claims.
//Another early ages entry
<human name> was born in <small town> in <occupation>'s family.
His father was killed by robbers before he was born, so he grew up with only his mother, <female human name>.
[...]
Hey, CodePotatoe I'm not using CodeBlocks, but I took your question as a challenge for myself and here's what I created. I spent about an hour or so, and it's really just a template. But feel free to use it however you want.
SIMPLE NPC GENERATOR:
(Will randomize Race, Gender, Class and Attributes of Gary Gygax (Lv. 1))
Note: I haven't started writing functions yet (I'm a newbie) and, as you can see, all my variables are all over the place (which I assume will break your code if you start putting everything into functions, so be sure to instantiate the vars at the start of main (if it's like Java)).
Changelog:
* Fixed some incorrect math.
* Removed a redundant if statement (that terminates program).
* Made an initial "Super Duper Notice" headline.
* Added +2 Str and -2 Int modifiers to Barbarian attributes.
* Added some easter eggs to program. * Template program finished. (Still lacking name generator though).
Haha, yeah I've added attribute modifiers to Barbarian now (but not the other classes yet).
Template program finished, CodePotatoes will have to figure out the rest on his own, hopefully with the help of my template.