PDA

View Full Version : Secret of Mana Style Damage Number System and Enemy Weaknesses



bigjoe
06-10-2008, 07:02 AM
I think I'm finally getting to an intermediate level in terms of scripting. Check out this video, and read the description

http://www.youtube.com/watch?v=nwW-HRDbRnI

When I am finished with this script I will release it. Anyone interested?

P.S. The enemies do seem a little unimaginative, but they're pretty much dummy enemies with which to test the system.

Gleeok
06-10-2008, 08:00 AM
Oooh..Nice. I friggin love this idea. At some point there may even be a little drawtile pop up that displays damage dealt.

I'm assuming you even got a little custom array type thing made and maybe have plans for stuff like armor and whatnot also....but I'm just speculating.

Although I have no use for this script whatsoever, I'd love to see it used. :)

bigjoe
06-10-2008, 08:22 AM
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.





//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



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



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.

Gleeok
06-10-2008, 01:02 PM
Already got that taken care of. See the video. (You may have to enlarge it to full screen to see them, they're tiny.)


0_o ....How did I miss that?! @_@ That's...Sweet!



Well from what you posted I don't really see a need for arrays. (Though Joe123 might disagree.. <_<) I myself am only using three in my entire quest so far.
..Well if your gonna utilize enemy ID's in any way, then yeah, your gonna want to use them. For example; enemy[1-8]keese, enemy[8-16] Gels...etc. It lets you reference lots of stored data quickly and easy with only one variable. :)




Also, I'm going to factor in accuracy somehow. Not sure how just yet. That could get ugly. When a lweapon hits an enemy, it knocks it back and deals damage. Youd be doing what I'm doing at that point; Trying to 'uncode' Zelda. ;)

And do I smell experience points?

C-Dawg
06-10-2008, 04:30 PM
Awesome. This is exactly why I encourage people to release their scripts. The more scripters we have working on stuff, the faster we can develop new and awesome features. I was planning on something like this for my own quest, but I hadn't gotten as far as figuring out how to display damage. Joe, does your script let you display any arbitrary amount of damage? Or is it limited to tiles you've drawn? I'd love to see the code.

It shouldn't be too hard to modify this code so that damage "falls" from the enemy and bounces on the ground, or alternatively, "rises" from the enemy into the air.

If you're really going for Secret of Mana, you could make a custom energy meter (or use magic) that steadily refills, empties with each attack, and the power of the attack varies with how full the meter is.

As far as making your code universal goes, why not go with FFC weapons? That is, have your weapon item just set an FFC, then have a global or ffc script use drawtile to display an animation, and if it's close to an enemy, calculate damage and spawn a weapon on the screen to damage the enemy accordingly.

bigjoe
06-11-2008, 11:04 AM
Joe, does your script let you display any arbitrary amount of damage? Or is it limited to tiles you've drawn? I'd love to see the code.

Well, at the time of the video, it was limited to tiles I drew. However, I tweaked it a bit since and now it displays each digit seperately from a set of tiles 0-9. At this point, it can display any arbitrary value up to 9999. It would take only a few lines of code to add another digit to that.
As well, since then, I've made it to where the damage stays after the enemy dies.

I am currently working on making it use different number sets for different damage ranges. This is to add emphasis when you start taking large amounts of damage.



It shouldn't be too hard to modify this code so that damage "falls" from the enemy and bounces on the ground, or alternatively, "rises" from the enemy into the air.

Right now I'm working on streamlining it. Getting rid of unnecessary segments and stuff. When its finish I'll have different variations to suit peoples whims.


If you're really going for Secret of Mana, you could make a custom energy meter (or use magic) that steadily refills, empties with each attack, and the power of the attack varies with how full the meter is.

I'll probably have a global variable or something that sets whether this functionality is true. Some people might like to have it off or on.




As far as making your code universal goes, why not go with FFC weapons? That is, have your weapon item just set an FFC, then have a global or ffc script use drawtile to display an animation, and if it's close to an enemy, calculate damage and spawn a weapon on the screen to damage the enemy accordingly.

I'm trying to make global things like weapons and damage calculations more or less independent of FFCs. Enemies, however, are currently each linked to an FFC. This is because, in my quest, I wish to have all enemies use a skeleton "custom enemy" but have their behavior modified by ffc variables.

As for using drawtile to display animations, I am working on a function called drawdmg which draws a tile and spawns a stationary weapon as long as that tile is present.

Because of the complexity of setting up enemy weaknesses, it will be difficult to make it universal. However, once the code is finished, I may work on a more universal-friendly version of it, for those who wish to implement it into quests without having to sit and go through each of their weapons and items and adjust their damage/variables accordingly, among other things. This universal-friendly system may have some limitations due to the fact that spawning weapons that way only allows engine weaknesses to be factored in. You couldn't have enemies with weaknesses that go beyond the basic stuff, unless you scripted them yourself, and I'm trying to focus more on editor friendliness.

bigjoe
06-13-2008, 04:45 AM
Update: I am going to release the damage display function. Feel free to leave suggestions. Note that you have to call this function yourself from your global or FFC scripts. To get a variable to pass to it, check for changes in an enemy's hit points. Because of the problem about having to go through a proxy, I cant do CODE, so Im going to link to a text file: http://bigjoesquests.googlepages.com/dmgdisfunc.txt Until this godawful proxy problem is fixed for me again I will operate elsewhere, but I will check in every other day or so.

Gleeok
06-13-2008, 04:56 AM
What proxy are you using? There are some faster ones. The one I'm using right now is actually pretty good. http://www.kingofproxies.com/
I do have javascript and everything else shut off while I use it, that could be making a big difference in speed. In fact, just paste it in your restricted sites list, that'll get rid of the ads too.


I'll check out yous script. :)



..Wait, why can't you post code?

bigjoe
06-13-2008, 05:14 AM
Well, the one I was using, beatfiltering, was slow. But kingofproxies is much faster! Thanks. Still a little delay but its more tolerable. beatfiltering sucks. It removes formatting so you can't split lines. Hopefully this one doesn't do that. EDIT:ARGH. Still does. :(

Master_of_Power
06-24-2008, 01:24 AM
It reminds me of Light Crusader, except with weaknesses! sweet!