Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General Rpg game question

Status
Not open for further replies.

KingPoncho

Programmer
Aug 19, 2003
8
US
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
 
Goto 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?
 
Glad to be of help.

If a man says something in the forest and no woman hears it is he still wrong?
 
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.
 
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 &quot;*** Warning ***&quot;
LOCATE 7, 10, 0
COLOR 14, 0
PRINT &quot;Running this game will require writing to the hard drive.&quot;
LOCATE 8, 9, 0
PRINT &quot;While no damage will be done to the computer, the directory&quot;
LOCATE 9, 8, 0
PRINT &quot;C:\GAMEDATA will be created. If this directory already exists,&quot;
LOCATE 10, 8, 0
PRINT &quot;this program will overwrite it, eraseing any data stored in it.&quot;
LOCATE 11, 7, 0
PRINT &quot;Please make sure this directory does not exist, or is not needed&quot;
LOCATE 12, 29, 0
PRINT &quot;before continuing.&quot;
LOCATE 15, 7, 0
COLOR 15, 0
PRINT CHR$(21); &quot; Douglas Landmesser - Game Programmer (May 2003) &quot;; CHR$(21)
LOCATE 20, 10, 0
COLOR 9, 0
PRINT &quot;Press <Enter> to continue...&quot;
INPUT &quot;&quot;, Q

9999

softboot:
SHELL &quot;C:&quot;
SHELL &quot;CHDIR C:\&quot;
SHELL &quot;MKDIR C:\GAMEDATA&quot;

'Game Files Creation Center:

correnhpfull$ = &quot;C:\GAMEDATA\CHPFULL.DAT&quot;
OPEN correnhpfull$ FOR OUTPUT AS #1
PRINT #1, &quot;100&quot;
CLOSE #1
CORRENHPCURRENT$ = &quot;C:\GAMEDATA\CHPCURRE.DAT&quot;
OPEN CORRENHPCURRENT$ FOR OUTPUT AS #1
PRINT #1, &quot;100&quot;
CLOSE #1
correnmpfull$ = &quot;C:\GAMEDATA\CMPFULL.DAT&quot;
OPEN correnmpfull$ FOR OUTPUT AS #1
PRINT #1, &quot;25&quot;
CLOSE #1
CORRENMPCURRENT$ = &quot;C:\GAMEDATA\CMPCURRE.DAT&quot;
OPEN CORRENMPCURRENT$ FOR OUTPUT AS #1
PRINT #1, &quot;25&quot;
CLOSE #1
monster1hpfull$ = &quot;C:\GAMEDATA\MON1HPFL.DAT&quot;
OPEN monster1hpfull$ FOR OUTPUT AS #1
PRINT #1, &quot;140&quot;
CLOSE #1
MONSTER1HPCURRENT$ = &quot;C:\GAMEDATA\MON1HPCT.DAT&quot;
OPEN MONSTER1HPCURRENT$ FOR OUTPUT AS #1
PRINT #1, &quot;140&quot;
CLOSE #1
CORRENEXPERIENCE$ = &quot;C:\GAMEDATA\CEXPLEVE.DAT&quot;
OPEN CORRENEXPERIENCE$ FOR OUTPUT AS #1
PRINT #1, &quot;0&quot;
CLOSE #1
cice1attackallow$ = &quot;C:\GAMEDATA\CICE1ALL.DAT&quot;
OPEN cice1attackallow$ FOR OUTPUT AS #1
CLOSE #1
monster1attack$ = &quot;C:\GAMEDATA\MON1ATTA.DAT&quot;
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 &quot; Corren the Great enters the city of Gandor... &quot;
SLEEP 7
LINE (2, 2)-(637, 300), 4, BF
LOCATE 5, 7, 0
COLOR 15
PRINT &quot; Suddenly a monster attacks from nowhere! &quot;
SLEEP 3
LINE (2, 2)-(637, 300), 0, BF

DO
CALL monster1
monster1attack$ = &quot;C:\GAMEDATA\MON1ATTA.DAT&quot;
OPEN monster1attack$ FOR INPUT AS #1
INPUT #1, monster1attack%
CLOSE #1
CORRENHPCURRENT$ = &quot;C:\GAMEDATA\CHPCURRE.DAT&quot;
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 &quot;&quot;, BATTLECOMMAND$
IF BATTLECOMMAND$ = &quot;A&quot; THEN CALL correnattack1
IF BATTLECOMMAND$ = &quot;M&quot; 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 &quot;Monster Defeated!&quot;
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 &quot;Corren gained 2 experience points!&quot;
LOCATE 6, 10, 0
COLOR 4, 0
PRINT &quot;Current experience points: &quot;
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 &quot;Press <Enter> to continue... &quot;
INPUT &quot;&quot;, 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$ = &quot;C:\GAMEDATA\MON1HPCT.DAT&quot;
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 &quot;Corren died!&quot;
LOCATE 7, 10, 0
COLOR 14, 0
PRINT &quot;Press <Enter> to try agian...&quot;
INPUT &quot;&quot;, Q
END SUB

SUB correngriddata
correnhpfull$ = &quot;C:\GAMEDATA\CHPFULL.DAT&quot;
OPEN correnhpfull$ FOR INPUT AS #1
INPUT #1, correnhpfull%
CLOSE #1
CORRENHPCURRENT$ = &quot;C:\GAMEDATA\CHPCURRE.DAT&quot;
OPEN CORRENHPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENHPCURRENT%
CLOSE #1
correnmpfull$ = &quot;C:\GAMEDATA\CMPFULL.DAT&quot;
OPEN correnmpfull$ FOR INPUT AS #1
INPUT #1, correnmpfull%
CLOSE #1
CORRENMPCURRENT$ = &quot;C:\GAMEDATA\CMPCURRE.DAT&quot;
OPEN CORRENMPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENMPCURRENT%
CLOSE #1
LOCATE 22, 2, 0
COLOR 15
PRINT &quot;Corren&quot;
LOCATE 22, 42, 0
COLOR 4
PRINT CHR$(3); &quot;HP:&quot;
LOCATE 22, 46, 0
COLOR 15
PRINT CORRENHPCURRENT%; &quot;/&quot;; correnhpfull%
LOCATE 22, 60, 0
COLOR 2
PRINT CHR$(4); &quot;MP:&quot;
COLOR 15
LOCATE 22, 64, 0
PRINT CORRENMPCURRENT%; &quot;/&quot;; 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 &quot;Magic Spells&quot;
CORRENMPCURRENT$ = &quot;C:\GAMEDATA\CMPCURRE.DAT&quot;
OPEN CORRENMPCURRENT$ FOR INPUT AS #1
INPUT #1, CORRENMPCURRENT%
CLOSE #1
IF CORRENMPCURRENT% <= 9 THEN cice1attackallow$ = &quot;C:\GAMEDATA\CICE1ALL.DAT&quot;: OPEN cice1attackallow$ FOR OUTPUT AS #1: PRINT #1, &quot;0&quot;: CLOSE #1
IF CORRENMPCURRENT% >= 10 THEN cice1attackallow$ = &quot;C:\GAMEDATA\CICE1ALL.DAT&quot;: OPEN cice1attackallow$ FOR OUTPUT AS #1: PRINT #1, &quot;1&quot;: 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 &quot;1. Ice&quot;
LOCATE 17, 14, 0
COLOR 15
INPUT &quot;Spell:&quot;, CORRENMAGICSELECTION$
IF CORRENMAGICSELECTION$ = &quot;1&quot; THEN GOTO correniceattack1:
GOTO nullmagicinput:
correniceattack1:
CORRENMPCURRENT$ = &quot;C:\GAMEDATA\CMPCURRE.DAT&quot;
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$ = &quot;C:\GAMEDATA\MON1HPCT.DAT&quot;
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 &quot;Characters:&quot;
LOCATE 20, 42, 0
PRINT &quot;Status:&quot;
LOCATE 27, 2, 0
COLOR 14
PRINT &quot;Command Center:&quot;
LOCATE 27, 42, 0
COLOR 14
PRINT &quot;<--- A=Attack M=Magic (use CAPS.)&quot;
END SUB

SUB monster1
monster1attack% = INT(RND(1) * 2) + 1
monster1attack$ = &quot;C:\GAMEDATA\MON1ATTA.DAT&quot;
OPEN monster1attack$ FOR OUTPUT AS #1
PRINT #1, monster1attack%
CLOSE #1
monster1hpfull$ = &quot;C:\GAMEDATA\MON1HPFL.DAT&quot;
OPEN monster1hpfull$ FOR INPUT AS #1
INPUT #1, monster1hpfull%
CLOSE #1
MONSTER1HPCURRENT$ = &quot;C:\GAMEDATA\MON1HPCT.DAT&quot;
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 &quot;Monster - &quot;
COLOR 4
LOCATE 18, 12, 0
PRINT CHR$(3); &quot;HP:&quot;
LOCATE 18, 16, 0
COLOR 15
PRINT MONSTER1HPCURRENT%; &quot;/&quot;; monster1hpfull%
END SUB

SUB monster1attacks
LOCATE 10, 15, 0
COLOR 4
PRINT &quot; Monster attacks Corren! &quot;
CORRENHPCURRENT$ = &quot;C:\GAMEDATA\CHPCURRE.DAT&quot;
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 :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top