|
|
|
@ -1,29 +1,13 @@ |
|
|
|
|
#include <string.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
|
#include "chargen.h" |
|
|
|
|
#include <math.h> |
|
|
|
|
#include "character.h" |
|
|
|
|
|
|
|
|
|
unsigned long profs; |
|
|
|
|
unsigned long languages; |
|
|
|
|
char otherprofs[100]; |
|
|
|
|
char* background; |
|
|
|
|
char* race; |
|
|
|
|
char* class; |
|
|
|
|
|
|
|
|
|
char* classes[] = {"Barbarian", "Bard", "Cleric", "Druid", "Fighter", "Monk", "Paladin", "Ranger", "Rogue", "Sorcerer", "Warlock", "Wizard" }; |
|
|
|
|
char* races[] = { "Dragonborn", "Dwarf", "Elf", "Gnome", "Half-Elf", "Halfling", "Half-Orc", "Human", "Tiefling" }; |
|
|
|
|
char* backgrounds[] = { "Acolyte", "Charlatan", "Criminal", "Entertainer", "Folk Hero", "Guild Artisan", "Hermit", "Noble", "Outlander", "Sage", "Sailor", "Soldier", "Urchin" }; |
|
|
|
|
int stats[6]; |
|
|
|
|
int mods[6]; |
|
|
|
|
int hp; |
|
|
|
|
|
|
|
|
|
int dieroll(int num,int sides){ |
|
|
|
|
int total = 0; |
|
|
|
|
while (num > 0) { |
|
|
|
|
for(num;num>0;num--){ |
|
|
|
|
total = total + arc4random_uniform(sides)+1; |
|
|
|
|
num--; |
|
|
|
|
} |
|
|
|
|
return total; |
|
|
|
|
} |
|
|
|
@ -32,7 +16,7 @@ void addLanguage(long lang){ |
|
|
|
|
if((lang & languages ) == 0){ |
|
|
|
|
languages = languages + lang; |
|
|
|
|
}else{ |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -40,7 +24,7 @@ void addProf(long prof){ |
|
|
|
|
if((prof & profs) == 0){ |
|
|
|
|
profs = profs + prof; |
|
|
|
|
}else{ |
|
|
|
|
addProf(1lu << arc4random_uniform(18)); |
|
|
|
|
addProf(exp2l(arc4random_uniform(18))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -61,9 +45,10 @@ void classProfs(unsigned long* classprofs, int count, int num){ |
|
|
|
|
classprofs[i]=local; |
|
|
|
|
} |
|
|
|
|
//Grab the first N elements, based on the class's value, but first, if we have more profs than available profs, get some random ones
|
|
|
|
|
while (num > count){ |
|
|
|
|
addProf(1lu << arc4random_uniform(18)); |
|
|
|
|
count--; |
|
|
|
|
if(num > count){ |
|
|
|
|
for(count;num > count;count--){ |
|
|
|
|
addProf(exp2l(arc4random_uniform(18))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for(int i=0;i<=num;i++){ |
|
|
|
|
addProf(classprofs[num]); |
|
|
|
@ -80,9 +65,9 @@ void genClass(){ |
|
|
|
|
classProfs(barbskills, 6, 2); |
|
|
|
|
break; |
|
|
|
|
case BARD:; |
|
|
|
|
addProf(1lu << arc4random_uniform(18)); |
|
|
|
|
addProf(1lu << arc4random_uniform(18)); |
|
|
|
|
addProf(1lu << arc4random_uniform(18)); |
|
|
|
|
addProf(exp2l(arc4random_uniform(18))); |
|
|
|
|
addProf(exp2l(arc4random_uniform(18))); |
|
|
|
|
addProf(exp2l(arc4random_uniform(18))); |
|
|
|
|
strlcat(otherprofs, "Three Musical Instruments, ", sizeof(otherprofs)); |
|
|
|
|
hp = 8 + mods[CON]; |
|
|
|
|
break; |
|
|
|
@ -175,7 +160,7 @@ void genRace(){ |
|
|
|
|
if(subrace == 0){ |
|
|
|
|
race = "High Elf"; |
|
|
|
|
stats[INT]+=1; |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
}else if(subrace == 1){ |
|
|
|
|
race = "Wood Elf"; |
|
|
|
|
stats[WIS]+=1; |
|
|
|
@ -201,9 +186,9 @@ void genRace(){ |
|
|
|
|
stats[CHA]+=2; |
|
|
|
|
stats[arc4random_uniform(4)]+=1; |
|
|
|
|
stats[arc4random_uniform(4)]+=1; |
|
|
|
|
addProf(1lu << arc4random_uniform(18)); |
|
|
|
|
addProf(1lu << arc4random_uniform(18)); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addProf(exp2l(arc4random_uniform(18))); |
|
|
|
|
addProf(exp2l(arc4random_uniform(18))); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
addLanguage(ELVISH); |
|
|
|
|
break; |
|
|
|
|
case HALFLING: |
|
|
|
@ -231,7 +216,7 @@ void genRace(){ |
|
|
|
|
stats[INT]+=1; |
|
|
|
|
stats[WIS]+=1; |
|
|
|
|
stats[CHA]+=1; |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
break; |
|
|
|
|
case TIEFLING: |
|
|
|
|
stats[INT]+=1; |
|
|
|
@ -251,8 +236,8 @@ void genBackground(){ |
|
|
|
|
case ACOLYTE: |
|
|
|
|
addProf(INSIGHT); |
|
|
|
|
addProf(RELIGION); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
break; |
|
|
|
|
case CHARLATAN: |
|
|
|
|
addProf(DECEPTION); |
|
|
|
@ -281,32 +266,32 @@ void genBackground(){ |
|
|
|
|
case GUILDARTISAN: |
|
|
|
|
addProf(INSIGHT); |
|
|
|
|
addProf(PERSUASION); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
strlcat(otherprofs, "Artisan's Tools, ", sizeof(otherprofs)); |
|
|
|
|
break; |
|
|
|
|
case HERMIT: |
|
|
|
|
addProf(MEDICINE); |
|
|
|
|
addProf(RELIGION); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
strlcat(otherprofs, "Herbalism Kit, ", sizeof(otherprofs)); |
|
|
|
|
break; |
|
|
|
|
case NOBLE: |
|
|
|
|
addProf(HISTORY); |
|
|
|
|
addProf(PERSUASION); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
strlcat(otherprofs, "Gaming Set, ", sizeof(otherprofs)); |
|
|
|
|
break; |
|
|
|
|
case OUTLANDER: |
|
|
|
|
addProf(ATHLETICS); |
|
|
|
|
addProf(SURVIVAL); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
strlcat(otherprofs, "Musical Instrument, ", sizeof(otherprofs)); |
|
|
|
|
break; |
|
|
|
|
case SAGE: |
|
|
|
|
addProf(ARCANA); |
|
|
|
|
addProf(HISTORY); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(1lu << arc4random_uniform(15)); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
addLanguage(exp2l(arc4random_uniform(15))); |
|
|
|
|
break; |
|
|
|
|
case SAILOR: |
|
|
|
|
addProf(ATHLETICS); |
|
|
|
@ -332,125 +317,127 @@ void genBackground(){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
size_t genChar(char* output, size_t maxlen){ |
|
|
|
|
int i; |
|
|
|
|
char * genChar(char* output){ |
|
|
|
|
profs = 0; |
|
|
|
|
languages = 0; |
|
|
|
|
otherprofs[0] = '\0'; |
|
|
|
|
for(i=0; i < 6; i++){ |
|
|
|
|
stats[i] = dieroll(3,6); |
|
|
|
|
mods[i] = (stats[i]/2)-5; |
|
|
|
|
for(int i = 0; i <= 100; i++){ |
|
|
|
|
otherprofs[i] = '\0'; |
|
|
|
|
} |
|
|
|
|
int i; |
|
|
|
|
genRace(); |
|
|
|
|
genClass(); |
|
|
|
|
genBackground(); |
|
|
|
|
snprintf(output, maxlen, "Race = %s\r\nBackground = %s\r\nClass = %s\r\nStr = %d %d\r\nDex = %d %d\r\nCon = %d %d\r\nInt = %d %d\r\nWis = %d %d\r\nCha = %d %d\r\n\r\nHP: %d\r\n", race, background, class, stats[STR], mods[STR], stats[DEX], mods[DEX], stats[CON], mods[CON], stats[INT], mods[INT], stats[WIS], mods[WIS], stats[CHA], mods[CHA], hp); |
|
|
|
|
for(i=0; i < 6; i++){ |
|
|
|
|
stats[i] = dieroll(3,6); |
|
|
|
|
mods[i] = floor((stats[i]/2)-5); |
|
|
|
|
} |
|
|
|
|
snprintf(output, 512, "Race = %s\r\nBackground = %s\r\nClass = %s\r\nStr = %d %d\r\nDex = %d %d\r\nCon = %d %d\r\nInt = %d %d\r\nWis = %d %d\r\nCha = %d %d\r\n\r\nHP: %d\r\n", race, background, class, stats[STR], mods[STR], stats[DEX], mods[DEX], stats[CON], mods[CON], stats[INT], mods[INT], stats[WIS], mods[WIS], stats[CHA], mods[CHA], hp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strlcat(output,"Proficiences:\r\n",maxlen); |
|
|
|
|
strlcat(output,"Proficiences:\r\n",512); |
|
|
|
|
if((ATHLETICS & profs) != 0){ |
|
|
|
|
strlcat(output,"Athletics\r\n",maxlen); |
|
|
|
|
strlcat(output,"Athletics\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((ACROBATICS & profs) != 0){ |
|
|
|
|
strlcat(output,"Acrobatics\r\n",maxlen); |
|
|
|
|
strlcat(output,"Acrobatics\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((SLEIGHTOFHAND & profs) != 0){ |
|
|
|
|
strlcat(output,"Sleight of Hand\r\n",maxlen); |
|
|
|
|
strlcat(output,"Sleight of Hand\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((STEALTH & profs) != 0){ |
|
|
|
|
strlcat(output,"Stealth\r\n",maxlen); |
|
|
|
|
strlcat(output,"Stealth\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((ARCANA & profs) != 0){ |
|
|
|
|
strlcat(output,"Arcana\r\n",maxlen); |
|
|
|
|
strlcat(output,"Arcana\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((HISTORY & profs) != 0){ |
|
|
|
|
strlcat(output,"History\r\n",maxlen); |
|
|
|
|
strlcat(output,"History\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((INVESTIGATION & profs) != 0){ |
|
|
|
|
strlcat(output,"Investigation\r\n",maxlen); |
|
|
|
|
strlcat(output,"Investigation\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((NATURE & profs) != 0){ |
|
|
|
|
strlcat(output,"Nature\r\n",maxlen); |
|
|
|
|
strlcat(output,"Nature\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((RELIGION & profs) != 0){ |
|
|
|
|
strlcat(output,"Regligion\r\n",maxlen); |
|
|
|
|
strlcat(output,"Regligion\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((ANIMALHANDLING & profs) != 0){ |
|
|
|
|
strlcat(output,"Animal Handling\r\n",maxlen); |
|
|
|
|
strlcat(output,"Animal Handling\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((INSIGHT & profs) != 0){ |
|
|
|
|
strlcat(output,"Insight\r\n",maxlen); |
|
|
|
|
strlcat(output,"Insight\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((MEDICINE & profs) != 0){ |
|
|
|
|
strlcat(output,"Medicine\r\n",maxlen); |
|
|
|
|
strlcat(output,"Medicine\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((PERCEPTION & profs) != 0){ |
|
|
|
|
strlcat(output,"Perception\r\n",maxlen); |
|
|
|
|
strlcat(output,"Perception\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((SURVIVAL & profs) != 0){ |
|
|
|
|
strlcat(output,"Survival\r\n",maxlen); |
|
|
|
|
strlcat(output,"Survival\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((DECEPTION & profs) != 0){ |
|
|
|
|
strlcat(output,"Deception\r\n",maxlen); |
|
|
|
|
strlcat(output,"Deception\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((INTIMIDATION & profs) != 0){ |
|
|
|
|
strlcat(output,"Intimidation\r\n",maxlen); |
|
|
|
|
strlcat(output,"Intimidation\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((PERFORMANCE & profs) != 0){ |
|
|
|
|
strlcat(output,"Performance\r\n",maxlen); |
|
|
|
|
strlcat(output,"Performance\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((PERSUASION & profs) != 0){ |
|
|
|
|
strlcat(output,"Persuaion\r\n",maxlen); |
|
|
|
|
strlcat(output,"Persuaion\r\n",512); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
strlcat(output,"\r\nLanguages:\r\nCommon\r\n",maxlen); |
|
|
|
|
strlcat(output,"\r\nLanguages:\r\nCommon\r\n",512); |
|
|
|
|
if((ABYSSAL & languages) != 0){ |
|
|
|
|
strlcat(output,"Abyssal\r\n",maxlen); |
|
|
|
|
strlcat(output,"Abyssal\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((CELESTIAL & languages) != 0){ |
|
|
|
|
strlcat(output,"Celestial\r\n",maxlen); |
|
|
|
|
strlcat(output,"Celestial\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((DRACONIC & languages) != 0){ |
|
|
|
|
strlcat(output,"Draconic\r\n",maxlen); |
|
|
|
|
strlcat(output,"Draconic\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((DEEPSPEECH & languages) != 0){ |
|
|
|
|
strlcat(output,"Deep Speech\r\n",maxlen); |
|
|
|
|
strlcat(output,"Deep Speech\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((INFERNAL & languages) != 0){ |
|
|
|
|
strlcat(output,"Infernal\r\n",maxlen); |
|
|
|
|
strlcat(output,"Infernal\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((PRIMORDIAL & languages) != 0){ |
|
|
|
|
strlcat(output,"Primordial\r\n",maxlen); |
|
|
|
|
strlcat(output,"Primordial\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((SYLVAN & languages) != 0){ |
|
|
|
|
strlcat(output,"Sylvan\r\n",maxlen); |
|
|
|
|
strlcat(output,"Sylvan\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((UNDERCOMMON & languages) != 0){ |
|
|
|
|
strlcat(output,"Undercommon\r\n",maxlen); |
|
|
|
|
strlcat(output,"Undercommon\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((DWARVISH & languages) != 0){ |
|
|
|
|
strlcat(output,"Dwarvish\r\n",maxlen); |
|
|
|
|
strlcat(output,"Dwarvish\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((ELVISH & languages) != 0){ |
|
|
|
|
strlcat(output,"Elvish\r\n",maxlen); |
|
|
|
|
strlcat(output,"Elvish\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((GIANT & languages) != 0){ |
|
|
|
|
strlcat(output,"Giant\r\n",maxlen); |
|
|
|
|
strlcat(output,"Giant\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((GNOMISH & languages) != 0){ |
|
|
|
|
strlcat(output,"Gnome\r\n",maxlen); |
|
|
|
|
strlcat(output,"Gnome\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((GOBLIN & languages) != 0){ |
|
|
|
|
strlcat(output,"Goblin\r\n",maxlen); |
|
|
|
|
strlcat(output,"Goblin\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((HALFLISH & languages) != 0){ |
|
|
|
|
strlcat(output,"Halfling\r\n",maxlen); |
|
|
|
|
strlcat(output,"Halfling\r\n",512); |
|
|
|
|
} |
|
|
|
|
if((ORC & languages) != 0){ |
|
|
|
|
strlcat(output,"Orcish\r\n",maxlen); |
|
|
|
|
strlcat(output,"Orcish\r\n",512); |
|
|
|
|
} |
|
|
|
|
strlcat(output,"\r\nOther Profs: ",maxlen); |
|
|
|
|
strlcat(output,otherprofs,maxlen); |
|
|
|
|
strlcat(output,"\r\n",maxlen); |
|
|
|
|
return strlen(output); |
|
|
|
|
strlcat(output,"\r\nOther Profs: ",512); |
|
|
|
|
strlcat(output,otherprofs,512); |
|
|
|
|
strlcat(output,"\r\n",512); |
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|