Atlas   Rules   Resources   Adventures   Stories       FAQ   Search   Links



D&D character generator in Basic

by Sean Meaney

The Microsoft Quick-basic Program Text for Macintosh Plus I created back in 1995.

‘D&D CHARACTER GENERATOR
START:
CLEAR
TEXTSIZE (18)
LOCATE 2, 1: PRINT TAB (2)”DUNGEONS & DRAGONS”
TEXTSIZE (14)
LOCATE 4, 1: PRINT TAB (2)”CHARACTER GENERATOR”
TEXTSIZE (14)
RANDOMIZE TIMER
DIM ABILITY (6)
DIM CLASS (7)
DIM ABILITY$(6)
DIM CLASS$(7)
GOSUB PREPSTAT
GOSUB PREPCLASS
GOSUB GENSTAT
GOSUB GENREST
GOSUB OPTCLASS
GOSUB STATS
GOSUB SELECTCLASS
WINDOW CLOSE (3)
GOSUB HOMETOWN
GOSUB ADJUSTHP
GOSUB CHARACTERSHEET
GOSUB ENDING
END

DATA STRENGTH, INTELLIGENCE, WISDOM, DEXTERITY, CONSTITUTION, CHARISMA
DATA CLERIC, FIGHTER, MAGICUSER, THIEF, ELF, DWARF, HALFLING

ADJUSTHP:
N=5
GOSUB ABILITYBONUS
HPBONUS=ABONUS
HP=HITPOINTS+HPBONUS
IF HP<1 THEN HP=1
RETURN

ABILITYBONUS:
SELECT CASE ABILITY(N)
CASE 3
ABONUS=-3
CASE 4 TO 5
ABONUS=-2
CASE 6 TO 8
ABONUS=-1
CASE 9 TO 12
ABONUS=0
CASE 13 TO 15
ABONUS=1
CASE 16 TO 17
ABONUS=2
CASE 18
ABONUS=3
END SELECT
RETURN

ENDING:
BUTTON 1, 1,”END THE PROGRAM”, (400, 10)-(600, 30), 1
BUTTON 2, 1,”PRINT CHARACTER SHEET”, (400, 40)-(600, 60), 1
BUTTON 3, 1,”GENERATE NEW CHARACTER”, (400, 70)-(600, 90), 1
WHILE DIALOG (0) <>1: WEND
PUSHED = DIALOG(1)
IF PUSHED = 1 THEN END
IF PUSHED = 2 THEN GOSUB PRINTER: GOTO ENDING
IF PUSHED = 3 THEN GOTO SKIP
SKIP:
BUTTON CLOSE (1)
BUTTON CLOSE (2)
BUTTON CLOSE (3)
WINDOW CLOSE (4)
GOTO START
RETURN

CHARACTERSHEET:
WINDOW 4,”CHARACTER SHEET”, (10, 50)-(630,470), 5
PRINT
TEXTSIZE(18): PRINT TAB (2) “CLASS:” CLASS$(CLASSCHOSEN)
PRINT
TEXTSIZE(14): PRINT TAB (2) “ALIGNMENT:”; ALIGNMENT$; “HIT POINTS:”; HP
PRINT
FOR QUIK=1 TO 6
PRINT TAB (2) ABILITY$(QUIK), ABILITY(QUIK)
NEXT QUIK
PRINT
PRINT TAB (2) “STARTING GOLD:” GOLD
PRINT
PRINT TAB (2) “CHARACTER BACKGROUND”
PRINT
PRINT TAB (2) “AGE:” AGE
PRINT
PRINT TAB (2) “FAMILY SOCIAL STANDING:”; SOCIAL$; TAB(40) “FAMILY ORIGIN:”; FAMILY$
PRINT TAB (2) “HOME TOWN:”; TOWN$
TEXTSIZE(12): PRINT
PRINT TAB (25)”CLICK ON THE CHARACTER SHEET TO CONTINUE”
WHILE MOUSE(0)<>1:WEND
RETURN

STATS:
WINDOW 3, “RAW STATISTICS”, (10, 50)-(630,470), 5
PRINT
TEXTSIZE (18): TEXTFONT(27): PRINT TAB(2) ”DUNGEONS & DRAGONS”
TEXTSIZE (18): TEXTFONT(27): PRINT TAB(2) ”CHARACTER GENERATOR”
PRINT
FOR PIK=1 TO 6
PRINT TAB (2) ABILITY$(PIK), ABILITY(PIK)
NEXT PIK
PRINT
PRINT TAB (2) “STARTING GOLD:” GOLD
PRINT
PRINT
PRINT
PRINT
PRINT
TEXTSIZE(14):PRINT TAB (16)”CLICK THE MOUSE TO CONTINUE”
WHILE MOUSE(0)<>1:WEND
RETURN

PRINTER:
OPEN “LPT1:” FOR OUTPUT AS #1
PRINT #1,
PRINT #1, TAB (2) “CLASS:” CLASS$(CLASSCHOSEN)
PRINT #1,
PRINT #1, TAB (2) “ALIGNMENT:”; ALIGNMENT$; “HIT POINTS:”; HP
PRINT #1,
FOR QUIK=1 TO 6
PRINT #1, TAB (2) ABILITY$(QUIK), ABILITY(QUIK)
NEXT QUIK
PRINT #1,
PRINT #1, TAB (2) “STARTING GOLD:” GOLD
PRINT #1,
PRINT #1, TAB (2) “CHARACTER BACKGROUND”
PRINT #1,
PRINT #1, TAB (2) “AGE:” AGE
PRINT #1,
PRINT #1, TAB (2) “FAMILY SOCIAL STANDING:”; SOCIAL$;
PRINT #1, TAB(2) “FAMILY ORIGIN:”; FAMILY$
PRINT #1, TAB (2) “HOME TOWN:”; TOWN$
CLOSE #1
RETURN

GENREST:
GOLD=10*(INT((18-3+1)*RND+3))
ALIGN=INT((6-1+1)*RND+1)
SELECT CASE ALIGN
CASE 1 TO 3
ALIGNMENT$=”LAWFUL”
CASE 4 TO 5
ALIGNMENT$=”NEUTRAL”
CASE 6
ALIGNMENT$=”CHAOTIC”
END SELECT
AGE=13+(INT((6-1+1)*RND +1))
RETURN

GENSTAT:
FOR STAT = 1 TO 6
ABILITY(STAT) = INT((18-3+1)*RND+3)
NEXT STAT
RETURN

OPTCLASS:
CLASS(2)=2
IF ABILITY(2)>8 THEN CLASS(3)=2
IF ABILITY(3)>8 THEN CLASS(1)=2
IF ABILITY(4)>8 THEN CLASS(4)=2
IF ABILITY(2)>8 THEN CLASS(5)=2
IF ABILITY(4)>8 AND ABILITY(5)>8 THEN CLASS(7)=2
RETURN

PREPCLASS:
FOR POSSIBLE=1 TO 7
READ CLASS$(POSSIBLE)
NEXT POSSIBLE
RETURN

PREPSTAT:
FOR POSSIBLE=1 TO 6
READ ABILITY$(POSSIBLE)
NEXT POSSIBLE
RETURN

SELECTCLASS:
WINDOW 2, “SELECT CLASS”,(475,50)-(625,470),5
FOR RANGE=1 TO 7
IF CLASS(RANGE) = 2 THEN BUTTON RANGE, 1, CLASS$(RANGE), (20, 20+ (40*RANGE))-(120, 60+ (40*RANGE))
NEXT RANGE
WHILE DIALOG(0)<>1:WEND
CLASSCHOSEN=DIALOG(1)
WINDOW CLOSE 2
SELECT CASE CLASSCHOSEN
CASE 1
HITPOINTS=INT((6-1+1)*RND+1)
GOSUB SOCIALHUMAN
GOSUB FAMILYHUMAN
CASE 2
HITPOINTS=INT((8-1+1)*RND+1)
GOSUB SOCIALHUMAN
GOSUB FAMILYHUMAN
CASE 3
HITPOINTS=INT((4-1+1)*RND+1)
GOSUB SOCIALHUMAN
GOSUB FAMILYHUMAN
CASE 4
HITPOINTS=INT((4-1+1)*RND+1)
GOSUB SOCIALHUMAN
GOSUB FAMILYHUMAN
CASE 5
HITPOINTS=INT((6-1+1)*RND+1)
GOSUB SOCIALELF
GOSUB FAMILYELF
CASE 6
HITPOINTS=INT((8-1+1)*RND+1)
GOSUB SOCIALDWARF
FAMILY$=”CLAN STRONGHOLLOW”
CASE 7
HITPOINTS=INT((4-1+1)*RND+1)
GOSUB SOCIALHIN
FAMILY$=”FIVE SHIRES”
END SELECT
RETURN

SOCIALHUMAN:
SOCIAL=INT((100-1+1)*RND+1)
SELECT CASE SOCIAL
CASE 1 TO 30
SOCIAL$=”PENNILESS”
CASE 31 TO 60
SOCIAL$=”STRUGGLING”
CASE 61 TO 75
SOCIAL$=”COMFORTABLE”
CASE 76 TO 85
SOCIAL$=”WEALTHY / UNTITLED”
CASE 86 TO 95
SOCIAL$=”WEALTHY / TITLED”
CASE 96 TO 97
SOCIAL$=”VERY WEALTHY / UNTITLED”
CASE 98 TO 99
SOCIAL$=”VERY WEALTHY / TITLED”
CASE 100
SOCIAL$=”ROYAL FAMILY”
END SELECT
RETURN

FAMILYHUMAN:
FAMILY=(INT(SOCIAL/2)+INT((100-1+1)*RND+1)
SELECT CASE FAMILY
CASE 1 TO 30
FAMILY$=”TRALADARAN”
CASE 31 TO 90
FAMILY$=”MIXED”
CASE 1 TO 30
FAMILY$=”THYATIAN”
END SELECT
IF SOCIAL$=”ROYAL FAMILY” THEN FAMILY$=”THYATIAN”
RETURN

SOCIALELF:
SOCIAL=INT((100-1+1)*RND+1)
SELECT CASE SOCIAL
CASE 1 TO 90
SOCIAL$=”COMMON”
CASE 91 TO 100
SOCIAL$=”LORD”
END SELECT
RETURN

FAMILYELF:
FAMILY=INT((100-1+1)*RND+1)
SELECT CASE FAMILY
CASE 1 TO 95
FAMILY$=”CLAN CALLARII”
CASE 96 TO 100
FAMILY$=”CLAN VYALIA”
END SELECT
RETURN

SOCIALDWARF:
SOCIAL=INT((100-1+1)*RND+1)
SELECT CASE SOCIAL
CASE 1 TO 30
SOCIAL$=”STRUGGLING”
CASE 31 TO 60
SOCIAL$=”COMFORTABLE”
CASE 61 TO 95
SOCIAL$=”WEALTHY”
CASE 96 TO 97
SOCIAL$=”VERY WEALTHY”
CASE 98 TO 100
SOCIAL$=”RULING”
END SELECT
RETURN

SOCIALHIN:
SOCIAL=INT((100-1+1)*RND+1)
SELECT CASE SOCIAL
CASE 1 TO 20
SOCIAL$=”PENNILESS”
CASE 21 TO 50
SOCIAL$=”STRUGGLING”
CASE 51 TO 95
SOCIAL$=”COMFORTABLE”
CASE 96 TO 100
SOCIAL$=”WEALTHY / UNTITLED”
END SELECT
RETURN

HOMETOWN:
IF SOCIAL$=”ROYAL FAMILY” THEN TOWN$=”SPECULARUM”: GOTO JUMP
IF CLASS$=”DWARF” THEN TOWN$=”HIGHFORGE”: GOTO JUMP
SOCIALBONUS=0
IF CLASS$(CLASSCHOSEN)=”HALFLING” THEN SOCIALBONUS=3
IF CLASS$(CLASSCHOSEN)=”ELF” THEN SOCIALBONUS=3
IF SOCIAL$=”COMFORTABLE” THEN SOCIALBONUS=2
IF SOCIAL$=”WEALTHY / TITLED” THEN SOCIALBONUS=4
IF SOCIAL$=”VERY WEALTHY / TITLED” THEN SOCIALBONUS=6
IF SOCIAL$=”WEALTHY / UNTITLED” THEN SOCIALBONUS=4
IF SOCIAL$=”VERY WEALTHY / UNTITLED” THEN SOCIALBONUS=6
CLASSBONUS=0
IF CLASS$(CLASSCHOSEN)=”CLERIC” THEN SOCIALBONUS=2
IF CLASS$(CLASSCHOSEN)=”MAGICUSER” THEN SOCIALBONUS=4
TOWN=(SOCIALBONUS+CLASSBONUS+INT((20-1+1)*RND+1))
SELECT CASE TOWN
CASE 1 TO 3
SOCIAL$=”FORT DOOM”
CASE 4
SOCIAL$=”VERGE”
CASE 5
SOCIAL$=”SULESCU”
CASE 6
SOCIAL$=”RUGALOV”
CASE 7
SOCIAL$=”MARILENEV”
CASE 8
SOCIAL$=”RIFLLIAN”
CASE 9
SOCIAL$=”VORLOI”
CASE 10
SOCIAL$=”DMITROV”
CASE 11
SOCIAL$=”LULN”
CASE 12
SOCIAL$=”THRESHOLD”
CASE 13
SOCIAL$=”PENHALIGON”
CASE 14 TO 16
SOCIAL$=”KELVIN”
CASE 17 TO 30
SOCIAL$=”SPECULARUM”
END SELECT
JUMP:
RETURN