Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Best way about battling & spells in an RPG?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Drake




PostPosted: Thu Jun 23, 2005 8:05 pm   Post subject: Best way about battling & spells in an RPG?

As some people already know, I'm making an RPG. This is NOT a culminating activity for any course. This is purely for my own entertainment and enjoyment.

Now that that's out of the way, I'd like to know what you people think would be the best way about a battle system for an RPG. The RPG will be completely text based; no graphics. Or, at least, none yet. I may put something in later but that's not the point.

I currently am making a spells class that has different procedures for each spell. And a spells known class that contains a boolean array with one item for each different spell, the item set to true if the player is able to cast the spell. Is there an easier way of doing this that people have found? Something that works better/faster? Or, in the long run, will this one not work well? I can already tell that, once I get the proper number of spells in the game that I want (at -least- 50 is what I'm aiming for) it will be near impossible to keep track of them all. What can I do to make this a little easier on me?

Also, I can't figure out a way to have a list displayed to the user of the spells that they can cast. My best guess would be to have a window pop up with a list of the spells that can be cast and when you hover the mouse over one spell, it says the mana cost for it (I currently have no idea how to do this yet, but I'll figure it out when I get to there). Or have a list of all the spells possible, but have the ones that can't be cast in grey or something else not black.

Anywho, I can't figure out a way to do the battle system, either. I have a (small) list of monsters premade but I have no idea how to use them.

Any suggestions on how to do any of this would be great. I definetly -don't- want the answers on how exactly to do it, just a nudge in the right direction or something like that. It wouldn't be fun otherwise! Wink
Sponsor
Sponsor
Sponsor
sponsor
vagyb




PostPosted: Thu Jun 23, 2005 8:10 pm   Post subject: (No subject)

eh text only rpgs are very boring :S try to do at least 2d type of graphic rpg, more challanging but surely very fun.
Drake




PostPosted: Thu Jun 23, 2005 8:17 pm   Post subject: (No subject)

I realize that text only would be -very- boring. But, to be completely honest, the only person I expect to actually play this game is me. That's why I want to make it as random as I can up until then. Once the game is done or near done, though, I'll definetly start to work on putting in pictures. I've seen a lot of good games on here done with better than excellent GUIs. Maybe if I get good enough at programming in Turing and spend enough time on it I'll do that.
vagyb




PostPosted: Thu Jun 23, 2005 8:25 pm   Post subject: (No subject)

hm.. well it would be nice if u told us about the story of ur rpg a bit and give more detail so i can think of how i can help. basically tell wat the story in the rpg is about.
Cervantes




PostPosted: Thu Jun 23, 2005 8:35 pm   Post subject: (No subject)

You should use files to read data into records about different spells and monsters, etc.

I don't see why you'd want to make a "spells known" class. Why not just have a field of the character's record as an array of known spells?

Also, the spell class could be a good idea. I'm assuming it will have procedures and functions such as cast spell, damage, damage type, spell school, etc. Based on what I'm thinking, I'm not sure why you'd want to make it a class though. Would a module better suit your needs?

As for a battle system, you'll have to plan out some rules and such, first. I assume it will be turn based. If you know anything about D&D, you can lift a lot of the ideas from there. For example, have each creature have a certain number of attacks per round. Iterate through all creatures in the battle and go through a for loop from one to the maximum number of attacks that the quickest creature in that battle has. Then apply the attacks for each creature that whose number of attacks is greater than or equal to the iteration of the for loop (of attacks, not of creatures. Smile) In general, you would probably want to create a BATTLE module. I'll leave it to you as to how to structure that, as you said you wanted to do it yourself and I've rambled on enough already.

Cheers!
Drake




PostPosted: Thu Jun 23, 2005 8:48 pm   Post subject: (No subject)

Well that's the issue right there. There is no story as of yet. I guess I just want to program a generic battle and spell and monster and... thingy. I tguess I'm modeling it off of D&D a fair bit, seeing as my second spell was Magic Missile! So I can't really say what the story is because there is none.

Basic things to note about the game:

  • turn based battle style (too hard otherswise, I think.)
  • only one monster per battle against the player
  • only one action per turn for the monster/character (could change easily later, though)
  • I confuse classes and modules all the time, I actually -am- using modules
  • I don't really want to have dynamic arrays here. The arrays that I start off with should be the same size when I'm done (just because I want it that way, I can't think very well when I have to take into account that the whole range of pisibilities changes over time)


I know I didn't explain myself very well in any of these past posts. To be honest, I think the easiest thing for me to do at this point would be to RAR everything that I have worked on so far and throw it up on here so what I'm saying actually makes sense.

What I am trying to do is to keep all my doors open. I want to make this as easy on me in the long run as possible. Which, when you look at the Pc.tu file, explains why I have so many procedures when it seems that lots of them are repeats.



Drake's Crappy RPG.rar
 Description:
The RPG. The crappy crappy RPG.

Download
 Filename:  Drake's Crappy RPG.rar
 Filesize:  12.56 KB
 Downloaded:  145 Time(s)

Delos




PostPosted: Fri Jun 24, 2005 8:49 am   Post subject: (No subject)

Couple of pointers:

I don't like the idea much of having seperate procedures for each 'spell'. All 'spells' are are a series of mathematical operations you'll be applying to certain characters. To that effect, you could devise a system in which a 'spell' was simply a varaiable with a series of pseudo-commands in it that told you programme what to do.

I just glanced at your 'SpellList.tu' file to see what was going on.
code:

            if (damage = 1) then
                locate (5, 1)
                put "You cast Magic Missile for 1 point of damage!"
            else


I really don't like the put statements here. What if you later decide to change your output position to, say, (5, 3)?! You'll be pretty much screwed as you'll have to go in and change around everything.

Turing:

proc MagicMissile (col, row : int)
%...
locate (row, col)
put "You cast0z Magik Missilz0rs!"

Would help a little.
I still don't like it. What if at some point you decide to upgrade you graphics and use fonts instead? Now you're even more screwed!

Turing:

function MagicMissile () : string
   var outMsg : string
   %...
   % if all conditions are met:
   outMsg := "You cast Magic Missle.  Yay!"
   else
   outMsg := "Cannot cast this spell.  Go level up!"
   end if
   %...
   result outMsg
end MagicMissile

% now at any point:
put MagicMissile ()
% or
Font.Draw (MagicMissile(), someX, someY, someID, someColour)


The joys of dynamic coding.
wtd




PostPosted: Fri Jun 24, 2005 4:04 pm   Post subject: (No subject)

Why not?

code:
function MagicMissile () : string
   if ... then
      result "You cast Magic Missle.  Yay!"
   else
      result "Cannot cast this spell.  Go level up!"
   end if
end MagicMissile
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Fri Jun 24, 2005 4:58 pm   Post subject: (No subject)

I see...so you save yourself a variable. That works really well in this case, of course, but needless to say I've encountered quite a few instances where I needed to change the particular message as the conditions went on. For example:
pseudo:


if casting_spell and level_high_enough then
  msg= "You have cast an Awexome spell!"
if random_int == 3 then
  msg+= "  The enemy was poisoned."
if random_int == 5 then
  msg+= "  And you burnt your robe."


See what I mean? Especially in a case like this where a single spell may have multiple effects, it would be easier to include all in one function. Multiple functions for each set of outcomes (e.g., damage, additional effects, random comments) could be done as well, and then called within the 'main' magic-function...but I see that getting a little bit too complicated for one's taste.
wtd




PostPosted: Fri Jun 24, 2005 5:24 pm   Post subject: (No subject)

code:
if casting_spell and level_high_enough then
   if random_int == 3 then
     result "You have cast an Awexome spell!  The enemy was poisoned."
   elsif random_int == 5 then
     result "You have cast an Awexome spell!  And you burnt your robe."
   else
     ...
   end if
else
   ...
end if
Delos




PostPosted: Fri Jun 24, 2005 6:27 pm   Post subject: (No subject)

Will that be able to produce something to the effect of:
"You cast Magic Missiles. The enemy was burnt. Your spell won't be ready for another 3 turns."
?
I'm pretty sure that a function will exit as soon as a 'result' is met. Again, it comes down to a question of context. Your method is likely the best in most situations, though I still feel that my intepretation would be better suited to the situation I described (in which a single function would have to produce a series of results depending on condtions...) Of course we can get all fancy here and create an array of basic messages, then use some nifty function-work to determine which are returned during a spell-cast.
Drake




PostPosted: Mon Jun 27, 2005 11:55 am   Post subject: (No subject)

Very good ideas all around from everybody.

About the movement of the text idea (concerning locate (x,y)): I'm using that statement because I ave things (so far) set up to happen in certain lines. For health, it happens in the third line. For mana, in the fourth. Your actions against an enemy happen in fifth line and sixth line contains the enemies actions agains you.

About the delay before the same spell can be cast, I'm not going to be doing that. That would be too many restrictions for the spell. Whenever I play a game where there is the possibility of becoming a spell caster instead of a brute force fighter, I usually take the spell caster. And I usually end up happy about that. In D&D (If anybody plays it) each spell caster has a certain number of 0-level spells that they can cast, a certain number of 1st level spells and so on up until 9th level. Most casters require that you choose which spells you are goingto cast during the day at the beginning of the day, but there are some that let you just pick a spell, and it gets cast if you have enough empty spell slots for that level. I'm going towards something like that, just with the more powerful spells requiring higher mana costs. As long as I do enough testing in the end regarding damage, I'm sure I'll be able to balance everything. I will, also, be making physical attacks forthe game, too.

I probably won't be having the possibility of spells backfiring. The way I play D&D is that if you roll a 1 on anything, it's an auto-fail (regardless of how weak.strong the enemy is) and a 20 is an automatic hit. Makes thigns a little easier if I adopt that system to here.

I will be including spell resistance later on in the game where the caster needs to check to see if the spell hit the enemy, then how much damage the enemy takes.

For the going up in levels aspect (the character not knowing the spell), I still need to work out a way to make it so that the character doesn't have the ability to cast the spell. So that they can physically not click the button/select the spell to cast. I can't think of any way of doing that at the moment other than having a seperate window pop up with the spell that the character knows in it. That would be the use for the SpellList.t file, too. All I would need to do is find out which spells are set to true and put in their titles. An idea that just came to me about that: set the array to be 2D with the first length being the number of spells in total (1 section for each spell) and that bing a string with the spell's name. The second dimension would be just one layer of boolean, true if you can cast the spell.

For the upgrading the game idea (upgrade graphics/use different fonts): I don't plan on rally doing anything like that until I have the game somewhat close to being done. Based on what I am trying to do and my knowledge, it's going to take a while to get that far. So I'm not really concerned about the fonts or any graphics right now.

I did start trying to program a battle window function, so that whenver you enter a battle some windows pop up. I decided that there would be one window that displays the text of what has happened in the battle so far and one window that contains buttons/some other way of selecting what you will be doing next turn. This window could just be "Attack/Spell/Run" with, when the user clicks on 'Spell' another window pops up with the spells that they can cast. To be completely honest, I have no idea how to get this thing to work. I looked at the tutorials for multiple windows and it all makes sense to me, I just have no idea how to program it so that it will work. I also had a look at Aziz's BattleShip game (which is awesome, I have to say) for some ideas, the only thing that I learned from that would be that I should put as many things in procedures as I can (especially the spell wondow thingy). Here's the code for the battlewindows (keep in mind I had no idea what I was doing at the time, just throwing things in there to see if I could get any sort of window display to work at all for me)
code:
unit
module BattleWindow
    import "MonsterClass.tu", "Dice.tu", GUI in "%oot/lib/GUI"
    export BattleWindowText, BattleWindowButtons, Damage
    include "MonsterArray.t"

    var attackButton : int
    var battleTextWindow : int
    var battleButtonWindow : int

    procedure BattleWindowText
        var monster : int := Rand.Int (1, 7)
        if (MonsterClass.Battle
                (MonsterArray (monster).Name,
                MonsterArray (monster).Health,
                MonsterArray (monster).Mana,
                MonsterArray (monster).AttackMax,
                MonsterArray (monster).AttackMod,
                MonsterArray (monster).Defense,
                MonsterArray (monster).Experience) = true) then
            battleTextWindow := Window.Open ("text:10;20,nobuttonbar,position:top;centre,title:Battle!")

            loop
                exit when MonsterClass.ReturnHealth <= 0
            end loop
            Window.Close (battleTextWindow)
        end if
    end BattleWindowText

    procedure Damage
        MonsterClass.DisplayHealthTotals
        MonsterClass.UpdateHealth (0, Dice.d8 (2))
        MonsterClass.DisplayHealthTotals
    end Damage

    procedure BattleWindowButtons
        battleButtonWindow := Window.Open ("text:10;20,nobuttonbar,position:top;centre+200,title:Battle!")
        Window.Select (battleButtonWindow)
        GUI.CreateButton (0, 0, 20, "Attack!", Damage)

        if (MonsterClass.ReturnHealth <= 0) then
            Window.Close (battleButtonWindow)
            Window.Close (battleTextWindow)
        end if
    end BattleWindowButtons
end BattleWindow
I saved all that stuff in a unit file BattleWindow.tu and included it in the main game file, but for some reason it tells me that Damage is not a procedure and hence cannot be called. No idea about that one.

So, in short, I've tried to bite off more than I can chew with this project so far. I think my best bet would be to work one one thing only for the time being, the monster class stuff or the spell stuff or the battle stuff, but not all three. At this point I dont even know what to work on first; not sure which one needs help the most. I guess that's what I get for going away for an entire weekend and not even seeing a TV during that time. Embarassed
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: