Jump to content

RPG attributes generator: Difference between revisions

→‎{{header|Commodore BASIC}}: Standardize line numbering; switch to 0-basis for arrays to avoid wasting entries; use chr$ for cursor movement; change DS to DT so it works on C-128 where DS is a reserved word..
m (→‎{{header|R}}: Syntax highlighting.)
(→‎{{header|Commodore BASIC}}: Standardize line numbering; switch to 0-basis for arrays to avoid wasting entries; use chr$ for cursor movement; change DS to DT so it works on C-128 where DS is a reserved word..)
Line 1,212:
Except for screen control codes, this is generic enough it could be used for many other 8-bit interpreted BASICs as well. (Applesoft, ZX Spectrum, etc.). Should work on all Commodore models. (Adjustment for screen width may be necessary on VIC-20.)
 
<lang gwbasic>100 rem rpg character roller
20110 rem rosetta code - commodore basic
10 rem rpg character roller
165120 dim ds=0di(3):rem dice sum
20 rem rosetta code - commodore basic
100130 dim diat(45),at$(5):rem diceattributes as follows:
135140 at$(60)="CharismaStrength"
105 dim at(6),at$(6):rem attributes as follows:
110150 at$(1)="StrengthDexterity"
115160 at$(2)="DexterityConstitution"
120170 at$(3)="ConstitutionIntelligence"
125180 at$(4)="IntelligenceWisdom"
130190 at$(5)="WisdomCharisma"
140200 pt=0:sa=0:rem points total and number of strong attributes (15+)
135 at$(6)="Charisma"
145210 print chr$(147);chr$(14);chr$(29);chr$(17);"{right}{down}Rolling..."
140 pt=0:sa=0:rem points total and number of strong attributes (15+)
220 for ai=0 to 5:rem attribute index
145 print chr$(147);chr$(14);"{right}{down}Rolling..."
150230 for aii=10 to 3:di(i)=int(rnd(.)*6)+1:rem attributenext indexi
160 240 gosub 2000450
155 for i=1 to 4:di(i)=int(rnd(1)*6)+1:next i
250 dt=0:rem dice total
160 gosub 2000
170 260 for i=10 to 32:dsdt=dsdt+di(i):next i:rem take top 3
165 ds=0:rem dice sum
175 270 at(ai)=dsdt:pt=pt+dsdt
170 for i=1 to 3:ds=ds+di(i):next i:rem take top 3
180 280 if dsdt>=15 then sa=sa+1
175 at(ai)=ds:pt=pt+ds
185290 next ai
180 if ds>=15 then sa=sa+1
190300 if pt<75 or sa<2 then goto 140200
185 next ai
195310 print chr$(147);"Character Attributes:"
190 if pt<75 or sa<2 then goto 140
200320 print
195 print chr$(147);"Character Attributes:"
205330 for ai=10 to 65
200 print
210 340 print spc(13-len(at$(ai)));at$(ai);":";tab(14);at(ai)
205 for ai=1 to 6
215350 next ai
210 print spc(13-len(at$(ai)));at$(ai);":";tab(14);at(ai)
220360 print
215 next ai
225370 print " Total:";tab(14);pt
220 print
245380 print k$
225 print " Total:";tab(14);pt
230390 print "Do you accept? ";
240400 get k$:if k$<>"y" and k$<>"n" then 240400
235 print "Do you accept? ";
410 print k$
240 get k$:if k$<>"y" and k$<>"n" then 240
250420 if k$="n" then goto 140200
245 print k$
255430 print:print "Excellent. Good luck on your adventure!"
250 if k$="n" then goto 140
260440 end
255 print:print "Excellent. Good luck on your adventure!"
2000450 rem sort dice
260 end
2005460 for x=10 to 32:for y=x+1 to 43
 
2010 470 if di(x)<di(y) then di(0)=di(x):di(x)=di(y):di(y)=di(0)
2000 rem sort dice
2015480 next y,x
2005 for x=1 to 3:for y=x+1 to 4
490 return</lang>
2010 if di(x)<di(y) then di(0)=di(x):di(x)=di(y):di(y)=di(0)
2015 next y,x
2020 return
</lang>
 
{{out}}
1,480

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.