Help - Search - Members - Calendar
Full Version: Damage Algorithm Script
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
Athendial
I have little to no experience with scripting, and I don't really like the constant testing that goes along with the default damage algorithm of RPG Maker XP. So I have created my own algorithm, but of course, I don't know how to script it. Could anyone help me?

The algorithm is as follows:

Physical attacks: (Strength + Weapon Attack) - (Physical Defence + Dexterity) = Damage done to target

Agility = Evasion & Critical Strike Chance

Skills/Spell Attacks: (Intellect + Skill's Power) - (Magical Defence + Dexterity) = Damage done to target
brewmeister
Take a look at Game_Battler 3, attack_effect(attacker) & skill_effect(user, skill) methods.
The battle formulas are in the help docs for reference.
The statement you would use to replace line 51:

self.damage = [(attacker.atk + attacker.str) - (self.pdef + self.dex),0].max

You'll see there is a lot of other stuff going on there. Critical hit correction, Guarding, Dispersion(random variation), Element correction, 2nd hit (evasion).

You'll need to decide HOW you want agility to effect critical & evasion.
Athendial
Thank you very much, this helps me alot.
Athendial
QUOTE (brewmeister @ Jul 17 2010, 10:19 AM) *
You'll need to decide HOW you want agility to effect critical & evasion.


I have the standard attack and skill damages set now and they work great. But I can't seem to find where I change what agility does. Would it also be in Game_Battler 3?

I want agility to increase the user's chance to get a critical strike on an enemy, and the user's chance to evade an attack from an enemy, at a rate of around 0.5% for both of those.
brewmeister
Critical correction starts on line 57 of Game_Battler 3
CODE
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end


It takes the attacker's DEX, divided by the defender's AGI then mutlitplied by 4 as a percentage chance.
i.e. if the attacker's DEX & defender's AGI are equal, there is a 4% chance of getting a critical.
If a critical is scored, the damage is simply doubled.
You could add the attacker's AGI into the equation:

CODE
        if rand(100) < 4 * attacker.dex / self.agi + (attacker.agi * 0.005)



Evade is labeled "Second hit detection" down on line 72

CODE
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)


You could add the atacker's AGI the same way...

CODE
      eva = 8 * self.agi / attacker.dex + self.eva  + (attacker.agi * 0.005)


In both cases, for each 200 points of AGI, the attacker now has an additional 1% chance of a critical hit, or evading. (0.5%)
Athendial
Ok, that seems a bit off for what I'm after, if I were to change it from 0.5 to 2 would that make it 1% for every 50, or am i doing the math wrong on that?
brewmeister
QUOTE (Athendial @ Aug 1 2010, 12:29 PM) *
Ok, that seems a bit off for what I'm after, if I were to change it from 0.5 to 2 would that make it 1% for every 50, or am i doing the math wrong on that?


actually, my math was off (0r at least a decimal point).

Change it to 0.02 to get a 1% increase for each 50 AGI
Athendial
Ok, that all seems to work perfectly, many thanks for your help!
But now I'm rather curious. Agility now seems to work similarly to the agility in World of Warcraft, is there any way to make the other stats similar, such as having strength incease attack by a percent or allowing dexterity to increase health by a certain amount? I don't see any way of editing the current script to do that, so I'm assuming that it would be something I'd have to add in somewhere.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.