FUN WITH FORMULAS
Posts
probably add a .round or a .ceil or a .floor to the result, depending on how you want to "round" your values.
I'm not sure what the difference with those are, but a simple round up to a whole number or whatever's easiest would be fine with me. I'll give it a try, thanks ^_^
You want ceil (ceiling) if you want to always round up. Floor truncates decimals / always rounds down. Round will try to round to the nearest integer.
Depends on the language. Ruby is #.ceil , Javascript is Math.ceil(#) . You should .ceil your HP change calculation, so
should do the trick.
e: Your snippet would try to ceil whatever the change_hp method returns which probably won't do much (except probably throw a MethodNotFound error but idr what change_hp returns)
Also I worded that above bit really bad, but I'll leave it there for the MX users.
change_hp( (damage/2).ceil, false)
should do the trick.
e: Your snippet would try to ceil whatever the change_hp method returns which probably won't do much (except probably throw a MethodNotFound error but idr what change_hp returns)
Also I worded that above bit really bad, but I'll leave it there for the MX users.
Thanks a ton! That works perfectly!
I have a concern about the script, which is totally nitpicking, and I don't want to be looking a gift horse in the mouth and everything...
But I noticed the "half healing of the damage" isn't affected by weaknesses/resistance. Like if the damage is 20, the character is healed 10, but if the enemy resists the damage type, and the damage is reduced to 5, the character is still healed 10.
Given that the description is literally that the character gets healed half the amount that they deal with the move, I'll need to change that unless there's a way to fix that with the script. ^^;; Thanks!
I have a concern about the script, which is totally nitpicking, and I don't want to be looking a gift horse in the mouth and everything...
But I noticed the "half healing of the damage" isn't affected by weaknesses/resistance. Like if the damage is 20, the character is healed 10, but if the enemy resists the damage type, and the damage is reduced to 5, the character is still healed 10.
Given that the description is literally that the character gets healed half the amount that they deal with the move, I'll need to change that unless there's a way to fix that with the script. ^^;; Thanks!
Elemental multipliers are applied after the base calculation in the skill. To emulate it properly I'd c/p the code from the damage application code (find all -> 'eval' should find where it is, it should only be used in two or three places and one's the Game_Interpretor and one will be what executes the damage algorithm) into your damage algorithm. I don't remember what it looks like but you'd apply it like so:
Replace b.multiplier accordingly. I can look it up later tonight if nobody else does.
change_hp( (b.elemental_multiplier * damage/2).ceil, false)
Replace b.multiplier accordingly. I can look it up later tonight if nobody else does.
Yeah, that looks accurate. Replace my b.multiplier with item_element_rate(user, item) and hopefully user and item are in scope when the battle algorithm eval fires and it'll work fine*!
*not counting for rng stuff like variance and crits which will take a script fix I think
e; Actually after thinking about it for a bit I'm not sure anymore! Is all this in a Game_Battler? There's no reference to the target otherwise.
*not counting for rng stuff like variance and crits which will take a script fix I think
e; Actually after thinking about it for a bit I'm not sure anymore! Is all this in a Game_Battler? There's no reference to the target otherwise.
Huh, now it's making the damage "null." I'll post the whole thing:
class Game_Battler < Game_BattlerBase def drain_half_damage(damage) change_hp( (item_element_rate(user, item) * damage/2).ceil, false) txt = (item_element_rate(user, item) * damage/2).ceil create_popup(txt.to_s, "HP_HEAL") return damage #don't forget this line if you want this to deal damage end end
let this be a lesson to all of you - coding something is never as straightforward as it first seems.
Oh, that's because user and item are out of scope where you placed them. They're locally defined variables that you don't have a reference to in that method. Change that code to:
and when you call drain_half_damage pass it the user and item variables. That way you have access to them and item_element_rate can use them without freaking out.
class Game_Battler < Game_BattlerBase def drain_half_damage(damage, user, item) change_hp( (item_element_rate(user, item) * damage/2).ceil, false) txt = (item_element_rate(user, item) * damage/2).ceil create_popup(txt.to_s, "HP_HEAL") return damage #don't forget this line if you want this to deal damage end end
and when you call drain_half_damage pass it the user and item variables. That way you have access to them and item_element_rate can use them without freaking out.
Done.
My battle formula is
So I need to change that so it gives the user and item variables in the formula?
My battle formula is
a.drain_half_damage(2.5 * (a.mat * 2 - b.mdf))
So I need to change that so it gives the user and item variables in the formula?
Right, so
If that doesn't work then I was wrong with a base assumption and will check the actual ace code later tonight
a.drain_half_damage(2.5 * (a.mat * 2 - b.mdf), user, item)
If that doesn't work then I was wrong with a base assumption and will check the actual ace code later tonight
What matters with damage in general is how many hits the target can take. So the damage formula needs to be examined in parallel with HP.
For example, based on the reasoning on the standard formula, Damage = (100 / (100 + def)) * atk leads to
Hits = HP / Damage = HP * (100 + def) / (100 * atk)
so raising def by 1 is equivalent to raising HP by 1%. Thus, we could replace the damage computation formula by Damage = atk and have the armor giving extra % of HP instead of defense points.
In the development of MinST, I started with constant damage formula, thinking of enhancing it later with attack and defense dependencies. But it didn't happen due to the limitations of console display. I'm now thinking to push the simplicity even further : have all attacks causing 1 damage so HP become a direct measure of how many hits the unit can take. What do thing about it?
For example, based on the reasoning on the standard formula, Damage = (100 / (100 + def)) * atk leads to
Hits = HP / Damage = HP * (100 + def) / (100 * atk)
so raising def by 1 is equivalent to raising HP by 1%. Thus, we could replace the damage computation formula by Damage = atk and have the armor giving extra % of HP instead of defense points.
In the development of MinST, I started with constant damage formula, thinking of enhancing it later with attack and defense dependencies. But it didn't happen due to the limitations of console display. I'm now thinking to push the simplicity even further : have all attacks causing 1 damage so HP become a direct measure of how many hits the unit can take. What do thing about it?
class RPG::UsableItem::Damage def eval(a, b, v) [Kernel.eval(@formula), 0].max * sign rescue 0 end end
fuuuuuuuuuuuuuuuuuuuuuuuuuuuuck
yooooooooooooooooooooooooooooou
enterbrain
The skill/item used isn't available in the scope of the damage algorithm box. Why the fuck a data object is responsible for doing the calculation is beyond me. I'll just make a hp leech script or something (and due to how make_damage_value is done I have to override it! Fucking hooray!)
Unity: I'll send you a PM with a script and demo project in a few days that has a better set up battle algorithm execution so you can do the shit you're trying to do without wanting to rip out your own teeth.
author=GreatRedSpiritfuuuuuuuuuuuuuuuuuuuuuuuuuuuuckclass RPG::UsableItem::Damage def eval(a, b, v) [Kernel.eval(@formula), 0].max * sign rescue 0 end end
yooooooooooooooooooooooooooooou
enterbrain
The skill/item used isn't available in the scope of the damage algorithm box. Why the fuck a data object is responsible for doing the calculation is beyond me. I'll just make a hp leech script or something (and due to how make_damage_value is done I have to override it! Fucking hooray!)
Unity: I'll send you a PM with a script and demo project in a few days that has a better set up battle algorithm execution so you can do the shit you're trying to do without wanting to rip out your own teeth.
;_; Thank you soooooooo much! I really appreciate it!

















