New account registration is temporarily disabled.

DAMAGE FORMULA - HOW TO MAKE IT WORK?

Posts

Pages: first 12 next last
Hi. I'm new to the RPG Maker program, but i have been working on an RPG for a long time. I have a formula i want to use, but i am not sure how to get it to work. Essentially, its this:


Phys Minimum Damage - (a.atk / b.def) * 15
Phys Maximum Damage - (a.atk / b.def) * 25

Phys Crit Minimum - (a.atk / b.def) * 35
Phys Crit Maximum - (a.atk / b.def) * 45

Magic Minimum Damage - ((a.Mat / b.mdf) * X) * 1.6
Magic Maximum Damage - ((a.Mat / b.mdf) * X) * 1.8

How it works is i take what the minimum damage is for the attack, and the maximum, and the damage is between there. Not sure if i can get away with using a random variable for 15-25 or not. If it helps, i have the lunatic damage script.

Edit: Using VXAce. Wont be using equipment at all.
Which RPG Maker is this for? That is the first question. If it is 2K or 2k3, then doing these formulas would require custom coding since the maker themselves use a very specific (albeit dumb) formula for attacks.
Sorry. VXAce. Knew i forgot something >.>
I don't think you need a script for this since Ace has an inbuilt custom formula system. (it's on the skills tab.)
I also believe that you can cite a random ammount through it but I don't remember. Anyways, for it to work like this you'd have to basically make this damage algorythm:

(a.atk/b.def)*20 <-wich is pretty much the same that you've shown us
Then change the Variation to 25 (wich stands for 25% I think)
So that the result would be "((a.atk/b.def)*20)*rand0.75~1.25, wich I believe is pretty much what you want.

Well what I mean is: Mess around with the skills tab. =D
i'll have to fool around with it but i'll see if its the same. Thanks.

Now i just have 2 other things to figure out:

How to prevent the enemy from KOing you unless your below 20% HP, and how to implement some kind of counter so that when your hit, it goes up and when it reaches 100, you enter a state. But i think i can figure those both out with time.

Edit: Just tried out the formula and i don't think it works. i should be doing about 15-25 damage on this monster i set up but i'm doing 100 or so. Physical works but magic is still buggy. Example of magic formula for a 5 power spell: (((a.mat/b.mdf)*5)*1.7) with Variance 10(to make it 1.6-1.8).

With 90 Mat and 50 mdf, the attack should do 14-16 damage. Instead its doing consistant 8.


The heal is: (((a.mat/40)*5)*1.7) and should be healing 18-20. Instead it heals 16-18.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
As for the first of those two ideas, you'll definitely need a script for that one, but it shouldn't be a hard one. If you wanted a crash course in scripting, it'd be a good one to dive in with - you just need to find the place in the built-in scripts where hp is subtracted from a battler upon taking damage, and add a conditional branch to it, with an "else" case that subtracts less damage. I strongly suspect it'll be somewhere in Scene_Battle.

As for the second one, I'm almost sure limit breaks already exist in VX Ace...
That isn't LB though. IT's a pretty interesting mechanic that whoa, I've never seen before. Like being hit with a "Toxin" spell increases the "poison" counter by a base value (possibly altered by DEF / SPI / VIT / WHTVR), but the poison only actually activating when it hits 100%.
Whoa, that would add a nice ammount of tactics to battles. Having equipment that halves this counter, spells that freeze it... Kinda really nice but I have no idea how to do it, I don't know how to script at all... At least not yet.
And you should learn! (So should I...)

Also, variance 10 wouldn't make it 1.6-1.8. because variance is actually a percentage that applies over the RESULT of the formula, so variance 10 would multiply it anywhere from 0.90 to 1.10 xD
I... Think. I'm not sure. But to make sure just check with an ability with the fixed formula of dmg = 100. xD
Ok. I found out the problem with the damage formula. What was happening was RPG Maker VX Ace doesn't like decimals. So it was causing problems. I managed to alter the formula so i'll post them here:

Physical Formula: ((a.atk * 1000) / b.def * (15 + rand(10))) / 1000

Magical Formula: ((((a.mat * 1000) / b.mdf) * 5) / 1000) * (1600 + rand(200)) / 1000
Mmmmm, that looks pretty good!
i still need to find a way to prevent enemies and PCs from dying when over 20% HP. The reason why is because stats in this game are going to be static(IE, no leveling). To prevent one hit KOs from damage i kind of need that.
if b.hp =< b.mhp*0.2 ; (insert regular damage formula here) ; else; (insert regular damage formula here)b.remove_state(1); end;


If target Hp is less than 20% Max Hp
In these formulae the target can die
Removes death status, wich should revive target with 1hp in case of death

I'm not sure if this'll lead to a game over if the character is alone though
Nor if the syntax is right, I don't know RGSS. But it's more or less this line of thought. =>
I'll admit I'm no expert (only just started looking at Ace Lite), but wouldn't it be possible to simply mod the 'else' case statement for to ('regular damage formula' - 1)?
Nope. xD
Say the damage is 1000 and you have 500 Hp remaining. Like this it'd go 999 dmg, still killing you. =3c
If you're going to use these three formulae for nearly every skill in the game, you might want to consider baking them into a script like this:

module Formulae
  module_function

  def physical_damage(a, b, v = $game_variables)
    (((10 * rand) + 15) * (a.atk / b.def))
  end

  def magic_damage(spellpower, a, b, v = $game_variables)
    (spellpower * ((0.2 * rand) + 1.6) * (a.mat / b.mdf))
  end

  def critical_damage(a, b, v = $game_variables)
    (((10 * rand) + 35) * (a.atk / b.def))
  end

  def clamp_damage(damage, mhp, hp)
    if hp * 5 >= mhp then
      [damage, hp - 1].min
    else
      damage
    end
  end
end

In the actual box for a skill where it prompts you to enter a damage formula, you would then enter something like:

Formulae.physical_damage(a, b)

or

Formulae.magical_damage(X, a, b)

(You'll need to set the variance to zero, as well).

This script should give you damage that's fairly close to the formulae you asked for, and also lays the groundwork for the rest of it.

To get critical hits working, and to prevent damage from killing someone if they have at least 20% of their health, this might work:

class Game_Battler
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = Formulae.critical_damage(user, self) if item.physical? && @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end

  def execute_damage(user)
    if damage = @result.hp_damage > 0 then
      damage = Formulae.clamp_damage(damage, self.mhp, self.hp)
      on_damage(damage)
    end
    self.hp -= @result.hp_damage
    self.mp -= @result.mp_damage
    user.hp += @result.hp_drain
    user.mp += @result.mp_drain  
  end
end

Again, I haven't tested this, but I think it should sort you out.

EDIT: I had to change this up a little -- I completely forgot that the damage formula is dealt with before the game assesses elemental resistances and vulnerabilities. This amended script doesn't have any mistakes I know of, but again, I haven't tested it.

EDIT 2: These scripts are very quick and dirty. You'll probably need to place them before any other scripts that affect the battle system -- if you don't, then those other scripts might break.
Thanks pete. Im still trying to figure stuff out, but i take it i just copy/paste all this in to a section under 'materials' in the script editor?
The first and last bits go into a section under 'materials' in the script editor, yes. You can put them together, or paste each into its own section. The second script needs to go before any scripts you're getting from someone else, otherwise one of them might end up breaking.

The middle two parts are what you need to enter into the damage formula boxes in order to use these. For magical damage, replace X with whatever its actual value is for this spell.

If you only want the 20% hp thing to apply to PCs, then you'll need this changed a little more.
Nah bosses too. it prevents PC cheese. Hm..is there any way to include a flag in the skill to ignore that 20% protection though. Like If (item.flag.IgProt) = True
I don't know how to implement it off the top of my head, but it should be possible, yes.
getting an error when i load the test battler.

Script 'Game_Battler' line 385: SyntaxError Occurred.
Unexpected Keyword_end
End
I've run both of the scripts I gave you through a syntax checker, but neither of them is long enough for that error message to make any sense.

Did you edit one of the default scripts, above 'Materials'?
Pages: first 12 next last