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.
I need a lil help guys!
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:
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.
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
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.