Well, theres something I can't really wrap my mind around about arrays. I'd love to use them, but.. hmm, let's see. I'll grab a code snippet.


Code:
//FROM INSIDE rpgfunc.zh

int damage_algorithm_basic(int algtype){
int rdamage;
//ALGORITHMS FOR SWORDS
if (algtype == 2) rdamage = Rand(char_atk) + Rand(2);
if (algtype == 4) rdamage = char_atk + Rand(char_atk) + Rand(2);
if (algtype == 6) rdamage = char_atk + (2 * Rand(char_atk)) + Rand(2);
if (algtype == 8) rdamage = char_atk + (3 * Rand(char_atk)) + Rand(char_atk) + Rand(2);

return rdamage;
}
There's a ENGINE hp and a REAL hp.

ENGINE HP = The hp that the engine uses. Part of the npc.

REAL HP = The hp that will determine whether or not the enemy dies or goes into a frantic weak mode or whatever.

What the script does to determine what algorithm it will use to calculate the damage is takes the difference between the enemy's max ENGINE hp (usually 256) and it's current hp. Once it does that, the enemy's hp is immediately restored to maximum, but the difference is kept in a variable. That variable is passed through the above function. What is returned gets subtracted from the REAL hp, and then another function creates a display from that. When the REAL hp is zero, the enemy dies.

The above four algorithms are for swords.

If an enemy is immune to swords, it would pass to a different function. One that might be called damage_algorithm_noswords.

Rather than

Code:
if (algtype == 2) rdamage = Rand(char_atk) + Rand(2);
if (algtype == 4) rdamage = char_atk + Rand(char_atk) + Rand(2);
if (algtype == 6) rdamage = char_atk + (2 * Rand(char_atk)) + Rand(2);
if (algtype == 8) rdamage = char_atk + (3 * Rand(char_atk)) + Rand(char_atk) + Rand(2);
You'd just see

Code:
if (algtype == 2) rdamage = 0;
if (algtype == 4) rdamage = 0;
if (algtype == 6) rdamage = 0;
if (algtype == 8) rdamage = 0;
How can I use arrays to streamline this? Is there any way I can use them to reduce it to a single function rather than having different functions for different weakness types?

Oooh..Nice. I friggin love this idea. At some point there may even be a little drawtile pop up that displays damage dealt.
Already got that taken care of. See the video. (You may have to enlarge it to full screen to see them, they're tiny.)

(Also, anyone got some better algorithm ideas? These were just slapped together. There are three offensive stats, char_atk, char_spd, and char_mag. I'd like for basic swords to use char_atk. Also, I'm going to factor in accuracy somehow. Not sure how just yet.)

Now, if I were to have weapons with their own stats, I could see how I could use arrays. I'll have to consider doing that. But for now the damage calculations are taken directly from base statistics. I think thats pretty sufficient given the average scale of a quest.