Page 1 of 1

RPG battle engine help

Posted: Fri Sep 07, 2007 1:59 am
by vkstylez
Hi i've been an avid researcher on this site, but i can't still get my head around this battle engine and why it sucks lol, so i registered and was hoping if one of you guys can offer me some good magic codes, enemy codes etc, this is what i have so far. It's a bit messy so bare with me, i've been using DarkDread's tutorials and its a sub program for my game, much help would be appreciated. Ignore the stats, im just testing out stuff so there a bit imbalanced.
What i need, better enemy attack codes, better magic codes or even better a much better layout and set of codes.
'NOTE CLEAR UP THIS AND ADD COLOUR DAMMIT
HitPoints = 300000
MaxHitPoints = 300000
MagicPoints = 1000000
MaxMagicPoints = 1000000
Strength = 100
Defense = 70
Experience = 0
Gold = 0
Level = 1
Weapon$ = "Ultima Blade"

Spell$(1) = "Fire"
Spell$(2) = "Cure"
Spell$(10) = "Death"

EnemyName$ = "IST SLIME MASTER!!" ' the enemy stats based on
EnemyHP = 5000 ' what number was chosen.
EnemyStrength = 150 ' Feel free to experiment by
EnemyDefense = 200
' changing these stats around


CLS ' Again, a good way to read
' input from the keyboard.

PRINT "(A)ttack " ' Print the user's options on
PRINT "(F)ire " ' the screen.
PRINT "(C)ure"
PRINT "(D)eath"
PRINT "(S)tatus"
'

DO
Choice$ = LCASE$(INPUT$(1))

IF Choice$ = "a" THEN

' Below is a simple equation which will create a random attack
' strength based in part on the player's Strength.
attack = ((INT(RND * 3) + 2) * Strength) - ((INT(RND * 3) + 2) * EnemyDefense)

PRINT "You attack the "; EnemyName$; " with your "; Weapon$; " and do"; attack; "damage!"
EnemyHP = EnemyHP - attack ' This will decrease the
' enemy's HP by the amount of

ELSEIF EnemyHP <1> 0 THEN
PRINT EnemyName$; " throws his goo at you and does"; attack; "damage!"
HitPoints = HitPoints - attack ' This will decrease the
' player's HP by the amount of
' the enemy's attack.
ELSE
PRINT EnemyName$; " did no damage!"' If the enemy's attack is
' less than 1 then no damage
' will be taken from the
' player.
END IF
IF HitPoints < 1 THEN ' This IF block checks to see if the
' player has no hit points left and
' exits the LOOP if so.
PRINT "HAVE"
done = 1



ELSEIF Choice$ = "c" THEN magicheal = 200
HitPoints = HitPoints + magicheal
PRINT " YOu have casted "; Spell$(2); " you healed "; magicheal; ""
MagicPoints = MagicPoints - 100



ELSEIF EnemyHP <1> 0 THEN
PRINT EnemyName$; " casts his ultimate DARK GOO BEAM and does"; attack; "damage!"
HitPoints = HitPoints - attack ' This will decrease the
' player's HP by the amount of
END IF ' the enemy's attack.
ELSE
PRINT EnemyName$; " did no damage!"' If the enemy's attack is
' less than 1 then no damage
' will be taken from the
' player.
END IF
IF HitPoints < 1 THEN ' This IF block checks to see if the
' player has no hit points left and
' exits the LOOP if so.
PRINT "muahaha"
done = 1


ELSEIF Choice$ = "s" THEN PRINT " Player STATUS: HP="; HitPoints; ""; MaxHitPoints; ",MP="; MagicPoints; "/"; MaxMagicPoints; "'"
PRINT "STR= "; Strength; ", DEF="; Defense; ""
PRINT " YOur enemy status"



END IF

IF done = 1 THEN SLEEP

LOOP UNTIL done = 1

Posted: Fri Sep 07, 2007 2:04 am
by vkstylez
Sorry for double post, but i was thinking the OP was too long, newho, i need coding for death and well, if anyone can offer me a better but similar text type battle engine OR fix this up, it would be much appreciated.

Re: RPG battle engine help

Posted: Fri Sep 07, 2007 8:53 am
by Mac
vkstylez wrote:What i need...a much better layout and set of codes.
'NOTE CLEAR UP THIS AND ADD COLOUR DAMMIT
I advise to forget colour until everything else is working perfectly.

Below is a "much better layout".

Code: Select all

DECLARE SUB demo (n$)
CLS
PRINT "The name of this game is blah-blah"
PRINT : PRINT "The rules are ...."
LOCATE 25, 1: LINE INPUT "Press Enter to start"; e$
CLS
PRINT "OK, you are starting to play the game now."
CONST Choices = "afcds"
DO
  PRINT : PRINT
  PRINT "(A)ttack, ";
  PRINT "(F)ire, ";
  PRINT "(C)ure, ";
  PRINT "(D)eath, ";
  PRINT "(S)tatus"
  DO
    PRINT : LOCATE , , 1: ' Turns blinking cursor on
    PRINT "Choice ("; Choices; "): ";
    Choice$ = LCASE$(INPUT$(1))
    IF Choice$ = CHR$(27) THEN SYSTEM
    IF ASC(Choice$) > 32 THEN PRINT Choice$
    c = INSTR(Choices, Choice$)
    PRINT "Invalid choice. Press ESC to terminate game or choose correctly"
  LOOP WHILE c = 0
  CLS
  ON c GOSUB Attack, Fire, Cure, Death, Status
LOOP

Attack:
demo "Attack"
RETURN

Fire:
demo "Fire"
RETURN

Cure:
demo "Cure"
RETURN

Death:
demo "Death"
RETURN

Status:
demo "Status"
RETURN

SUB demo (n$)
PRINT "You need to replace the statement"
PRINT "demo " + CHR$(34) + n$ + CHR$(34)
PRINT "with your code of what happens if the player"
PRINT "selects that option."
' When you have done this everywhere, remove this sub.
END SUB
Mac

Posted: Fri Sep 07, 2007 7:02 pm
by Mentat
Here's two general tricks for developing large programs:

1) Make a Debug subroutine. It serves two functions, to help find problems by showing variables, and can correct silent runtime bugs (ex: in pong, if the ball goes out of left/right bounds, use a debugger to reset the pong coordinates). PowerBASIC and FirstBASIC have an evaluator debugger, which is pretty cool.

2) Don't go head first into a large program. Before starting, make smaller programs just to test and see if a part of a program will work. Such as menu screens with arrows.

And never underestimate debugging and debuggers. Write clean code.
For example:

instead of

Code: Select all

FOR Y = TOPZ TO BOTTOMZ
FOR X = LEFTZ TO RIGHTZ
NUMBERZ = X + Y
NEXT
NEXT
do

Code: Select all

FOR Y% = TOPZ% TO BOTTOMZ%
_____FOR X% = LEFTZ% TO RIGHTZ%
__________LET NUMBERZ% = X% + Y%
_____NEXT X%
NEXT Y%
note: underscores are tabs. Don't put them in your code.

Cleaning code may be tedious, but the payout is worth it.

Posted: Sun Sep 09, 2007 7:11 am
by Mac
Mentat wrote:2) Don't go head first into a large program. Before starting, make smaller programs just to test and see if a part of a program will work. Such as menu screens
"like Mac illustrated above"

(heh - you forgot that)

Mac

Posted: Sun Sep 09, 2007 9:38 am
by Mentat
Hm...I'm working on a realtime battle engine. A mix of The Old Republic and Morrowind. More skill driven and open ended, or at least I'm trying.

Good

Posted: Sun Sep 09, 2007 7:52 pm
by Mac
n/t

Posted: Mon Sep 10, 2007 6:11 am
by Mentat
Well, I'm going to need a lot of help on it, but I'm working on another problem.

Start new threads when you have a question

Posted: Mon Sep 10, 2007 6:24 am
by Mac
n/t

Posted: Mon Sep 10, 2007 4:25 pm
by Mentat
Okay...But I do have something pertaining to the topic. How should I alert the player if he/she is being attacked from behind in the battle. It's first person, and I'm not using beeps. Any suggestions? I'm not changing to a separate battle screen. Should attacking from behind constitute an attack modifier?

Posted: Mon Sep 10, 2007 4:35 pm
by Raspberrypicker
draw a little arrow on the screen in the direction that the person gets hit.
It doesn't need to be an arrow, just some sort of indicator. Like in Gears of War, the red circle starts to appear when you are being hit, and it gets darker as you lose more and more health.

Posted: Mon Sep 10, 2007 5:07 pm
by Mentat
Sounds good in theory but somethimes I don't pay attention and I have to assume the player doesn't too. But, I guess that might play in to the real player's actual capabilities and awareness. Thanks. :)
Andmaybe the virtual player's awareness could also play a part; both KOTORs do it.

Wrong thread

Posted: Mon Sep 10, 2007 7:38 pm
by Mac
Are you hijacking vkstylez' thread, Mentat? I suggest starting a new thread with your problem. Let's stick with vkstylez here, to be courteous.

vkstyles wants to know how to organize his code, not how to do the whole thing.

Mac

Posted: Mon Sep 10, 2007 9:33 pm
by Nodtveidt
Mac wrote:
Mentat wrote:2) Don't go head first into a large program. Before starting, make smaller programs just to test and see if a part of a program will work. Such as menu screens
"like Mac illustrated above"

(heh - you forgot that)

Mac
I see you're just as egocentric as ever.

Just a note

Posted: Tue Sep 11, 2007 3:29 pm
by Mac
Nodtveidt wrote: I see you're just as egocentric as ever.
My intent, should you choose to believe it or not, was to focus the OP on the model program I gave. Using that, he can develop the subroutines as required and make a nice RPG exactly according to his wishes.

I am not familiar with you so I don't know where the hostility comes from. Hope whatever I did to you in the past can be forgiven.

Mac

Posted: Tue Sep 11, 2007 8:47 pm
by k7
Mac, are you trying to hijack vkstylez' thread? I'm sure Mentat wasn't aware that it isn't 'courteous' to stray from the thread topic, which is a natural event for anyone on this forum.

Posted: Tue Sep 11, 2007 9:18 pm
by Mac
k7 wrote:Mac, are you trying to hijack vkstylez' thread? I'm sure Mentat wasn't aware that it isn't 'courteous' to stray from the thread topic, which is a natural event for anyone on this forum.
Just trying to help. This isn't the only forum in the universe. There are many such as www.CraigsList.org. They all have common concepts such as no SHOUTING, no stalking, ... blah blah. Amoung these many customs is avoidance of hijacking a thread which means

Person A asks a question "Where can I buy a cheap car?"
People debate this issue and then Person B comes in with
"I need a boat. Where can I get a boat". This is called hijacking. If tolerated, the thread becomes hectic, like a chat room, with next post talking about car and next about boat. So people are encouraged to start a nice new thread to talk about a new topic.

If vkstylez asks for help, on-topic replies are directed to vkstyles with help or are directed to others who have provided what you deem to be incorrect help, etc. Off topic is to ask for help yourself.

The Craigslist computer forum amoung others is a good place to learn some netiquette that will be useful on other forums, whether such manners are honored at this forum or not.

I note that Mentat did not take offense.

Mac

Posted: Wed Sep 12, 2007 6:25 am
by Mentat
Mac wrote: I note that Mentat did not take offense.
None taken :wink: .

I was thinking of teaching vkstylez from a general point of view. The best way to get familiar with code is to create it. It's harder to debug with copy-paste.

And - hopefully - vkstylez might look to other RPGs for inspiration, as I did.

Maybe. But I tutor in math, and I don't usually take the text book aproach. The best way to learn is to find some out of the stuff along the way without being told it. And it works quite well. :D.

And anyways, where is he?

Re: Just a note

Posted: Fri Sep 14, 2007 5:05 pm
by Nodtveidt
Mac wrote:I am not familiar with you so I don't know where the hostility comes from. Hope whatever I did to you in the past can be forgiven.
Nah, don't mind me. I was in a bad mood that day. :D You DO know me though...sort of.

There really needs to be more RPG tutorials. DarkDread's is very good but only covers specific styles and techniques. rpgdx and rpg-dev were supposed to be home to a lot of RPG development techniques but I think both are more or less now just chat sites...

Posted: Fri Sep 14, 2007 5:16 pm
by Mentat
There really needs to be more RPG tutorials. DarkDread's is very good but only covers specific styles and techniques. rpgdx and rpg-dev were supposed to be home to a lot of RPG development techniques but I think both are more or less now just chat sites...
I'll try! :D
When I finish my own. And it's more or less my own style, with the help of others of course. Especially Mac.