I need a lil help guys!

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Guest

I need a lil help guys!

Post by Guest »

Does anyone know how I could do this?: I am making a text-based game using a Dungeons and Dragons engine (same rules and regulations), and I wanted to know how to program the stat mods for each stat. For those who don't play, I need to know how to take a number value for a stat and then take that number and get the mod from it. ex:

strength= 10-11 the mod is +0

Now I know I could program it basically like that, but why waste lines of code when I'm sure there is some other way I could do it.
The unnammed assassin

What!?!?

Post by The unnammed assassin »

I'm sorry, maybe its just me but, what are you trying to do? What the hell is a mod? Do you mean like '10 mod 2 = 0' If I knew what the hell you were talking about i could probably help you but . . . . i don't
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

The way I'm doing it for Rise Of The Lich is to have like a chart for each statistic made into a large array. In QB, it might look something like this:

DIM strength(25,5) AS INTEGER

where the first element is the strength score (1 thru 25) and the second is the attribute (attack adjust, max press, etc.). Of course, for that particular stat, you also have to handle exceptional strength (18/01 thru 18/100) but that can be fixed with another array...other stats can be handled using this method quite easily (your first array element contains the score, and the second element contains the attribute). Then, to assign a value to each; for example, to assign the Hit Probability of Strength score 21, you might do something like this:

strength(21, 0) = 4

where 21 is the score, 0 is the attribute (in this case, the 0 would represent Hit Probability), and the 4 is the modifier (strength 21 carries a +4 Hit Probability bonus, in QB you can represent this with a normal 4 without the + sign, as values are automatically positive unless otherwise specified).

OR

if you want to get funkier, you can use a TYPE as opposed to the two-dimensional array. You might have something like this:

Code: Select all

TYPE strengthScore
    HitProb AS INTEGER
    DamageAdj AS INTEGER
    WeightAllow AS INTEGER
    MaxPress AS INTEGER
    OpenDoors AS INTEGER
    BendBars AS INTEGER
END TYPE
an then, a simple DIM strength AS strengthScore will give you a single array, to which you can work with as something like

strength[21].HitProb = 4

Does this help at all? I hope you know what you're getting into, as programming a D&D game is not easy. :D
Guest

Post by Guest »

Hey thanks! That helped alot, I'm just glad that I was able to get around it, as I already finished a large portion of the game and I didn't want to quit... Good luck on your own game also! :)
Post Reply