×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

General Rpg game question

General Rpg game question

General Rpg game question

(OP)
Hey I am attempting to program an Rpg, and it all works well except for the battles, I'm looking for ANY tips that anyone can give me about some numbers about stats, for attack, defense, and stuff. I am trying to get a pretty nice random element in there, but not so random as you don't have a general idea of what to expect, the main values I have been working with are:

   Attack
   Defense
   Luck
   EnemyAttack
   EnemyDefense
   EnemyLuck

  I can use any advice anyone has, thanks!


    King Poncho

RE: General Rpg game question

Goto www.google.com and type in 'qbasic rpg tutorial' the first result that comes up looks promising

If a man says something in the forest and no woman hears it is he still wrong?

RE: General Rpg game question

(OP)
Hey thanks man, this is insanely helpful :)

RE: General Rpg game question

Glad to be of help.

If a man says something in the forest and no woman hears it is he still wrong?

RE: General Rpg game question

you won't find much on battle engines on the net.  only tile engines.  in know.  (i know it's a bit late, but..)

to get a random element, do something like this.

randomize timer

bdamage = int(rnd * (attackpower/10)) + attackpower



bdamage is the base damage, the damage he would do if the enemie didn't have defense.  rnd * (attackpower/10): first of all, it divides the attack power by ten, so the randomness won't be too much in teh beginning, and not too little near the end.  it creates a random number that's about right. attackpower is the attack power of your character.  so say the attack power is 50.   the damage would work out.  then, do some fancy math with the enemy's defense.

RE: General Rpg game question

Hey man, I think I can help! I have been working on a REALLY sorry RPG for like a month, but it may help with your problem. Again, sorry its a bit late:

'*** GAME INFO ***
'
'SUBROUTINES:
'maingrid ............ Draws data grid and titles, no current values.
'cleargrid ........... Clears ONLY graphics box with black.
'monster1 ............ Draws first monster in game.
'correnattack1 ....... Runs corren attack graphics/math.
'correnmagiclist ..... Pulls up magic list and casts selected spell.
'correngriddata ...... Writes Corren's data to appropriate spots.
'levelupclear ........ Clears all boxes, might be useful for "level-up"s.
'clearmgrid .......... Only used for correnice1attack.
'monster1attacks ..... Runs monster1attack sequence.
'
'VARIABLES:
'correnhpfull%
'correnhpcurrent%
'correnmpfull%
'correnmpcurrent%
'correnmagicspellselection%  <--- CAN be in SUB routine
'monster1hpfull%
'monster1hpcurrent%



'GOTO 9999 Skips dumb disk writing warning if enabled

CLS
LOCATE 5, 30, 0
COLOR 4, 0
PRINT "*** Warning ***"
LOCATE 7, 10, 0
COLOR 14, 0
PRINT "Running this game will require writing to the hard drive."
LOCATE 8, 9, 0
PRINT "While no damage will be done to the computer, the directory"
LOCATE 9, 8, 0
PRINT "C:\GAMEDATA will be created. If this directory already exists,"
LOCATE 10, 8, 0
PRINT "this program will overwrite it, eraseing any data stored in it."
LOCATE 11, 7, 0
PRINT "Please make sure this directory does not exist, or is not needed"
LOCATE 12, 29, 0
PRINT "before continuing."
LOCATE 15, 7, 0
COLOR 15, 0
PRINT CHR$(21); " Douglas Landmesser - Game Programmer (May 2003) "; CHR$(21)
LOCATE 20, 10, 0
COLOR 9, 0
PRINT "Press <Enter> to continue..."
INPUT "", Q

9999

softboot:
SHELL "C:"
SHELL "CHDIR C:\"
SHELL "MKDIR C:\GAMEDATA"

'Game Files Creation Center:

correnhpfull$ = "C:\GAMEDATA\CHPFULL.DAT"
OPEN correnhpfull$ FOR OUTPUT AS #1
PRINT #1, "100"
CLOSE #1
CORRENHPCURRENT$ = "C:\GAMEDATA\CHPCURRE.DAT"
OPEN CORRENHPCURRENT$ FOR OUTPUT AS #1
PRINT #1, "100"
CLOSE #1
correnmpfull$ = "C:\GAMEDATA\CMPFULL.DAT"
OPEN correnmpfull$ FOR OUTPUT AS #1
PRINT #1, "25"
CLOSE #1
CORRENMPCURRENT$ = "C:\GAMEDATA\CMPCURRE.DAT"
OPEN CORRENMPCURRENT$ FOR OUTPUT AS #1
PRINT #1, "25"
CLOSE #1
monster1hpfull$ = "C:\GAMEDATA\MON1HPFL.DAT"
OPEN monster1hpfull$ FOR OUTPUT AS #1
PRINT #1, "140"
CLOSE #1
MONSTER1HPCURRENT$ = "C:\GAMEDATA\MON1HPCT.DAT"
OPEN MONSTER1HPCURRENT$ FOR OUTPUT AS #1
PRINT #1, "140"
CLOSE #1
CORRENEXPERIENCE$ = "C:\GAMEDATA\CEXPLEVE.DAT"
OPEN CORRENEXPERIENCE$ FOR OUTPUT AS #1
PRINT #1, "0"
CLOSE #1
cice1attackallow$ = "C:\GAMEDATA\CICE1ALL.DAT"
OPEN cice1attackallow$ FOR OUTPUT AS #1
CLOSE #1
monster1attack$ = "C:\GAMEDATA\MON1ATTA.DAT"
OPEN monster1attack$ FOR OUTPUT AS #1
CLOSE #1


SCREEN 12
LINE (0, 0)-(639, 479), 0, BF

'Corrin's Great Entry

CALL maingrid
CALL correngriddata
SLEEP 5
LINE (2, 2)-(637, 300), 11, BF
LOCATE 5, 7, 0
COLOR 15
SLEEP 2
PRINT " Corren the Great enters the city of Gandor... "
SLEEP 7
LINE (2, 2)-(637, 300), 4, BF
LOCATE 5, 7, 0
COLOR 15
PRINT " Suddenly a monster attacks from nowhere! "
SLEEP 3
LINE (2, 2)-(637, 300), 0, BF

DO
CALL monster1
monster1attack$ = "C:\GAMEDATA\MON1ATTA.DAT"
OPEN monster1attack$ FOR INPUT AS #1
INPUT #1, monster1attack%
CLOSE #1
CORRENHPCURRENT$ = "C:\GAMEDATA\CHPCURRE.DAT"
OPEN CORRENHPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENHPCURRENT%
CLOSE #1
IF CORRENHPCURRENT% <= 1 THEN CALL correndeath: GOTO softboot:
IF monster1attack% = 1 THEN CALL monster1attacks
LOCATE 27, 17, 0
INPUT "", BATTLECOMMAND$
IF BATTLECOMMAND$ = "A" THEN CALL correnattack1
IF BATTLECOMMAND$ = "M" THEN CALL correnmagiclist
OPEN MONSTER1HPCURRENT$ FOR INPUT AS #1
INPUT #1, MONSTER1HPCURRENT%
CLOSE #1
LOOP UNTIL MONSTER1HPCURRENT% <= 0

CALL cleargrid
LOCATE 10, 10, 0
COLOR 15, 0
PRINT "Monster Defeated!"
OPEN CORRENEXPERIENCE$ FOR INPUT AS #1
INPUT #1, correnexperiencecurrent%
CLOSE #1
correnexperiencegain% = correnexperiencecurrent% + 2
OPEN CORRENEXPERIENCE$ FOR OUTPUT AS #1
PRINT #1, correnexperiencegain%
CLOSE #1
LOCATE 5, 10, 0
COLOR 14, 0
PRINT "Corren gained 2 experience points!"
LOCATE 6, 10, 0
COLOR 4, 0
PRINT "Current experience points: "
OPEN CORRENEXPERIENCE$ FOR INPUT AS #1
INPUT #1, correnexperiencecurrent%
CLOSE #1
LOCATE 6, 36, 0
PRINT correnexperiencecurrent%
LOCATE 8, 10, 0
COLOR 14, 0
PRINT "Press <Enter> to continue... "
INPUT "", Q

'Corren Enters Gandor

LINE (0, 0)-(639, 479), 0, BF
CALL maingrid
CALL correngriddata
LINE (2, 2)-(637, 300), 7, BF

SUB cleargrid
LINE (2, 2)-(637, 300), 0, BF
END SUB

SUB clearmgrid
LINE (0, 0)-(639, 302), 0, BF
CALL maingrid
END SUB

SUB correnattack1
FOR A = 2 TO 637 STEP 1
LINE (2, 150)-(A, 150), 14
FOR SLEPT = 0 TO 2500 STEP 1
NEXT SLEPT
NEXT A
LINE (2, 2)-(637, 300), 1, BF
FOR A = 0 TO 3000000
NEXT A
LINE (2, 2)-(637, 300), 0, BF
LINE (637 / 2, 100)-(637 / 2 - 12, 130), 7
LINE (637 / 2, 100)-(637 / 2 + 12, 130), 7
LINE (637 / 2, 100)-(637 / 2, 220), 7
LINE (637 / 2 - 12, 130)-(637 / 2 - 12, 220), 7
LINE (637 / 2 + 12, 130)-(637 / 2 + 12, 220), 7
LINE (637 / 2 - 40, 220)-(637 / 2 + 40, 230), 14, BF
LINE (637 / 2 - 8, 231)-(637 / 2 + 7, 270), 4, BF
FOR A = 0 TO 3000000 STEP 1
NEXT A
CALL cleargrid
CALL maingrid
MONSTER1HPCURRENT$ = "C:\GAMEDATA\MON1HPCT.DAT"
OPEN MONSTER1HPCURRENT$ FOR INPUT AS #1
INPUT #1, MONSTER1HPCURRENT%
CLOSE #1
monster1hploss% = MONSTER1HPCURRENT% - 5
OPEN MONSTER1HPCURRENT$ FOR OUTPUT AS #1
PRINT #1, monster1hploss%
CLOSE #1
END SUB

SUB correndeath
CLS
LOCATE 5, 10, 0
COLOR 4, 0
PRINT "Corren died!"
LOCATE 7, 10, 0
COLOR 14, 0
PRINT "Press <Enter> to try agian..."
INPUT "", Q
END SUB

SUB correngriddata
correnhpfull$ = "C:\GAMEDATA\CHPFULL.DAT"
OPEN correnhpfull$ FOR INPUT AS #1
INPUT #1, correnhpfull%
CLOSE #1
CORRENHPCURRENT$ = "C:\GAMEDATA\CHPCURRE.DAT"
OPEN CORRENHPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENHPCURRENT%
CLOSE #1
correnmpfull$ = "C:\GAMEDATA\CMPFULL.DAT"
OPEN correnmpfull$ FOR INPUT AS #1
INPUT #1, correnmpfull%
CLOSE #1
CORRENMPCURRENT$ = "C:\GAMEDATA\CMPCURRE.DAT"
OPEN CORRENMPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENMPCURRENT%
CLOSE #1
LOCATE 22, 2, 0
COLOR 15
PRINT "Corren"
LOCATE 22, 42, 0
COLOR 4
PRINT CHR$(3); "HP:"
LOCATE 22, 46, 0
COLOR 15
PRINT CORRENHPCURRENT%; "/"; correnhpfull%
LOCATE 22, 60, 0
COLOR 2
PRINT CHR$(4); "MP:"
COLOR 15
LOCATE 22, 64, 0
PRINT CORRENMPCURRENT%; "/"; correnmpfull%
END SUB

SUB correnmagiclist
CALL cleargrid
CALL maingrid
nullmagicinput:
LINE (100, 100)-(201, 300), 0, BF
LINE (100, 109)-(201, 300), 2, B
LINE (100, 129)-(201, 129), 2
LOCATE 8, 14, 0
COLOR 2
PRINT "Magic Spells"
CORRENMPCURRENT$ = "C:\GAMEDATA\CMPCURRE.DAT"
OPEN CORRENMPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENMPCURRENT%
CLOSE #1
IF CORRENMPCURRENT% <= 9 THEN cice1attackallow$ = "C:\GAMEDATA\CICE1ALL.DAT": OPEN cice1attackallow$ FOR OUTPUT AS #1: PRINT #1, "0": CLOSE #1
IF CORRENMPCURRENT% >= 10 THEN cice1attackallow$ = "C:\GAMEDATA\CICE1ALL.DAT": OPEN cice1attackallow$ FOR OUTPUT AS #1: PRINT #1, "1": CLOSE #1
OPEN cice1attackallow$ FOR INPUT AS #1
INPUT #1, cice1attackallow%
CLOSE #1
IF cice1attackallow% = 0 THEN COLOR 2
IF cice1attackallow% = 1 THEN COLOR 10
LOCATE 10, 14, 0
PRINT "1. Ice"
LOCATE 17, 14, 0
COLOR 15
INPUT "Spell:", CORRENMAGICSELECTION$
IF CORRENMAGICSELECTION$ = "1" THEN GOTO correniceattack1:
GOTO nullmagicinput:
correniceattack1:
CORRENMPCURRENT$ = "C:\GAMEDATA\CMPCURRE.DAT"
OPEN CORRENMPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENMPCURRENT%
CLOSE #1
IF CORRENMPCURRENT% <= 9 THEN CALL cleargrid: GOTO endme:
correnmploss% = CORRENMPCURRENT% - 10
OPEN CORRENMPCURRENT$ FOR OUTPUT AS #1
PRINT #1, correnmploss%
CLOSE #1
MONSTER1HPCURRENT$ = "C:\GAMEDATA\MON1HPCT.DAT"
OPEN MONSTER1HPCURRENT$ FOR INPUT AS #1
INPUT #1, MONSTER1HPCURRENT%
CLOSE #1
monster1hploss% = MONSTER1HPCURRENT% - 35
OPEN MONSTER1HPCURRENT$ FOR OUTPUT AS #1
PRINT #1, monster1hploss%
CLOSE #1
CALL cleargrid
CALL monster1
RANDOMIZE TIMER
FOR A = 0 TO 500 STEP 1
B = INT(RND(2) * 637)
C = INT(RND(2) * 300)
D = INT(RND(2) * 637)
E = INT(RND(2) * 300)
LINE (B, C)-(D, E), 11, B
FOR SLEPT = 0 TO 10000 STEP 1
NEXT SLEPT
NEXT A
CALL clearmgrid
CALL correngriddata
endme:
END SUB

SUB levelupclear
LINE (2, 2)-(637, 300), 0, BF
LINE (1, 322)-(319, 429), 0, BF
LINE (319 + 2, 322)-(638, 429), 0, BF
END SUB

SUB maingrid
LINE (0, 0)-(639, 479), 4, B
LINE (0, 302)-(639, 302), 4
LINE (0, 320)-(639, 320), 4
LINE (639 / 2, 302)-(639 / 2, 479), 4
LINE (0, 415)-(639, 415), 4
LINE (0, 432)-(639, 432), 4
LOCATE 20, 2, 0
COLOR 14
PRINT "Characters:"
LOCATE 20, 42, 0
PRINT "Status:"
LOCATE 27, 2, 0
COLOR 14
PRINT "Command Center:"
LOCATE 27, 42, 0
COLOR 14
PRINT "<--- A=Attack M=Magic (use CAPS.)"
END SUB

SUB monster1
monster1attack% = INT(RND(1) * 2) + 1
monster1attack$ = "C:\GAMEDATA\MON1ATTA.DAT"
OPEN monster1attack$ FOR OUTPUT AS #1
PRINT #1, monster1attack%
CLOSE #1
monster1hpfull$ = "C:\GAMEDATA\MON1HPFL.DAT"
OPEN monster1hpfull$ FOR INPUT AS #1
INPUT #1, monster1hpfull%
CLOSE #1
MONSTER1HPCURRENT$ = "C:\GAMEDATA\MON1HPCT.DAT"
OPEN MONSTER1HPCURRENT$ FOR INPUT AS #1
INPUT #1, MONSTER1HPCURRENT%
CLOSE #1
PI = 3.1415926535#
FOR A = 0 TO 360 STEP .1
RADIAN = A * PI / 180
X = 50 * COS(RADIAN)
Y = 50 * SIN(RADIAN)
LINE (300, 150)-(300 + X, 150 + Y), 15
NEXT A
FOR A = 0 TO 360 STEP .1
RADIAN = A * PI / 180
X = 15 * COS(RADIAN)
Y = 15 * SIN(RADIAN)
LINE (300, 150)-(300 + X, 150 + Y), 1
NEXT A
FOR A = 0 TO 360 STEP .1
RADIAN = A * PI / 180
X = 5 * COS(RADIAN)
Y = 5 * SIN(RADIAN)
LINE (300, 150)-(300 + X, 150 + Y), 0
NEXT A
LINE (256, 125)-(266, 135), 4
LINE (266, 135)-(276, 130), 4
LINE (276, 130)-(287, 140), 4
LINE (315, 147)-(322, 140), 4
LINE (322, 140)-(327, 155), 4
LINE (327, 155)-(335, 142), 4
LINE (335, 142)-(349, 138), 4
LINE (298, 200)-(305, 193), 4
LINE (305, 193)-(298, 182), 4
LINE (298, 182)-(302, 170), 4
LINE (302, 170)-(295, 165), 4
LOCATE 18, 2, 0
COLOR 15
PRINT "Monster - "
COLOR 4
LOCATE 18, 12, 0
PRINT CHR$(3); "HP:"
LOCATE 18, 16, 0
COLOR 15
PRINT MONSTER1HPCURRENT%; "/"; monster1hpfull%
END SUB

SUB monster1attacks
LOCATE 10, 15, 0
COLOR 4
PRINT " Monster attacks Corren! "
CORRENHPCURRENT$ = "C:\GAMEDATA\CHPCURRE.DAT"
OPEN CORRENHPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENHPCURRENT%
CLOSE #1
correnhploss% = CORRENHPCURRENT% - 20
OPEN CORRENHPCURRENT$ FOR OUTPUT AS #1
PRINT #1, correnhploss%
CLOSE #1
CALL correngriddata
END SUB

I ported it out of Firstbas, A QBasic compiler, and for some reason the program runs REALLY slow in QB. I think the delays are too hefty for a non-compiled program, but I wanted you to see the code instead of the results. If you speed it up, you could really pimp it out, or simply steal ideas from it, I don't care. Have fun!

Doug

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close