I'm trying to figure out how create a skill that deals damage while decreasing the max HP of the target based on the amount of damage dealt, but attempting to actually change this value only throws errors.
Example: x = a.atk * 4 - b.def * 2; x; x / 4 -= b.mhp
This formula is a basic attack that reduces maximum HP by 25% or 1/4 of the damage dealt. It doesn't work of course...
I can think of a few reasons as to why this is, but the point is that I need to get this or something similar to work.
Reduce Max HP In Damage Formula
● ARCHIVED · READ-ONLY
-
-
Why not use debuffs? :D
-
You should add states or use debuffs for that.
-
Kind of like the disease ailment from ffxii. Goes great with poison.
-
First, the formula is wrong - in any code, the variable to be changed has to stand in the beginning, not after the operation.b.mhp -= x/4 might work, but not in the way you wrote the formula.x = a.atk * 4 - b.def * 2; x; x / 4 -= b.mhp
x = a.atk * 4 - b.def * 2; b.mhp -= x / 4; xhas a chance to work, but I don't know if you can change mhp that way.Better would be to look for the script equivalent of the parameter change command and use that in the middle part to reduce the mhp.
Doing it this way will result in a permanent reduction - if you want it only temporary, you have to go with the states. -
here's my HP damage formula, and it works. Although it's for the lower the users HP the more damage is done
a.mhp/4 - a.mhp/5 - b.def*2
this is for a boss in my game, so the numbers should probably be tweeked if you decide to use this. But i hope this helps in giving you an idea on how to do HP damage formula's
Edit: Oh! i just remembered I was toying with this very thing trying to get a damage formula that reduced a charecters HP to 1 for that same boss. I got really close, but couldn't quite get it, but you can reduce it by % in damage formulas
It is painfully simple what i used though
b.hp/99.99
i'm sure
a.atk*4 + b.mhp/5 -b.def
could work maybe -
Why not use debuffs? :DIt's not that simple... The change in maximum hp must decrease based on the amount of damage dealt.You should add states or use debuffs for that.
I did notice that little error in the formula and corrected it before checking this thread for replies, but thanks for pointing that out. Correcting my own formula didn't work, nor did the one you provided.First, the formula is wrong - in any code, the variable to be changed has to stand in the beginning, not after the operation.
b.mhp -= x/4 might work, but not in the way you wrote the formula.
x = a.atk * 4 - b.def * 2; b.mhp -= x / 4; xhas a chance to work, but I don't know if you can change mhp that way.Better would be to look for the script equivalent of the parameter change command and use that in the middle part to reduce the mhp.
Doing it this way will result in a permanent reduction - if you want it only temporary, you have to go with the states.
I thought changing max hp this way might be permanent, but its a side effect I'm willing to deal with. I'm searching for a script that might help right now.
I have considered both debuffs and states, however, I need maximum HP to decrease by an integer; states only deal with percentages as far as I know.
Thanks for your input, but I already know how to do this. I'm attempting to decrease maximum hp based on the amount of damage dealt to the target.here's my HP damage formula, and it works. Although it's for the lower the users HP the more damage is done
a.mhp/4 - a.mhp/5 - b.def*2
this is for a boss in my game, so the numbers should probably be tweeked if you decide to use this. But i hope this helps in giving you an idea on how to do HP damage formula's
Edit: Oh! i just remembered I was toying with this very thing trying to get a damage formula that reduced a charecters HP to 1 for that same boss. I got really close, but couldn't quite get it, but you can reduce it by % in damage formulas
It is painfully simple what i used though
b.hp/99.99
i'm sure
a.atk*4 + b.mhp/5 -b.def
could work maybe
a.atk*4 + (b.mhp/5) - b.def
This formula would add 20% of the target's maximum hp to the user's attack power and then damage the target's HP. I need MHP to decrease based on HP damage done. -
oh, I should have read better...
no that definitly was NOT what I thought it was. YEAY! 50 DUH! points for me! -
Params aren't modifiable via simple -= because the param calls like .atk, .mhp returns the value from the params array which returns the data from the database plus the params bonus.
Using things like -= would modify the returned value only; keyword is value, it doesn't return the actual param object which in turn makes it such that you cannot modify it.
Example:
you call a.mhp => returns 50. if you do it like a.mhp -= 10, it will reduce 10 from the value that is 50, not from mhp itself.
Here take a look at the code in case it still isn't clear
Code:Any changes to be made to params are made via the params_plus array instead (look at how the event command works). You would normally do that via#mhp calls param(0) for example, you can look it up at the top part of Game_BattlerBase def param(param_id) value = param_base(param_id) + param_plus(param_id) value *= param_rate(param_id) * param_buff_rate(param_id) [[value, param_max(param_id)].min, param_min(param_id)].max.to_i end
Code:so if you want to add 50 to mhp for example to actor 1actor_object.add_param(param_id, value)
Code:$game_actors.add_param(0,50) -
Andar's formula should work. Note that you made two mistakes in your first formula; first, b.mhp has to be on the left side of the -= sign, and second, the damage (the solo "x" in this case) needs to be the last thing in the formula. If it doesn't work, give us some more detail. What is the attacker's ATK, what is the defender's DEF, how much damage is the skill doing, does anything happen to their maximum HP (try healing the character who lost max HP; it might be possible their max HP did drop and wasn't reflected in the visual display), and do you see anything else weird that's happening.
Edit: Ninja'd by the Engineer! Actually, what he said sounds correct. Replace the "50" with x and you might be good.
Note, however, an enemy's resistances, critical hits, etc., will NOT be considered in the formula that you are using. Certain factors (like crits) can be checked in the formula (I think it's "result.critical?"), but others (like resistances) would require heavier scripting. -
@Wavelength - As I explained above doing .mhp -= value wouldn't work. because, read my post :)
-
And I did read your post, the moment I saw I was ninja'd, and edited mine. Now read my post! :D@Wavelength - As I explained above doing .mhp -= value wouldn't work. because, read my post :)
-
Ah I think I just misunderstood this part: "Replace the "50" with x and you might be good."
XD -
Thank you. This info certainly helped me solve the problem.Params aren't modifiable via simple -= because the param calls like .atk, .mhp returns the value from the params array which returns the data from the database plus the params bonus.
Using things like -= would modify the returned value only; keyword is value, it doesn't return the actual param object which in turn makes it such that you cannot modify it.
Example:
you call a.mhp => returns 50. if you do it like a.mhp -= 10, it will reduce 10 from the value that is 50, not from mhp itself.
Here take a look at the code in case it still isn't clear
#mhp calls param(0) for example, you can look it up at the top part of Game_BattlerBase def param(param_id) value = param_base(param_id) + param_plus(param_id) value *= param_rate(param_id) * param_buff_rate(param_id) [[value, param_max(param_id)].min, param_min(param_id)].max.to_i endAny changes to be made to params are made via the params_plus array instead (look at how the event command works). You would normally do that via
Code:so if you want to add 50 to mhp for example to actor 1actor_object.add_param(param_id, value)
Code:$game_actors.add_param(0,50)
This seems to work, though I haven't tested it thoroughly.
x = a.atk * 4 - b.def * 2; b.add_param(0, -x / 4); x -
That skills seems to powerful though, you're dealing damage and reducing the max hp at the same time. Creepy skill to be used upon. XD
-
Okay. Here's where I've gotten so far.
This is the formula for a basic attack.
x = ((a.atk*4.0-b.def*2.0) * (a.hp/a.mhp.to_f) * (b.mhp/b.hp.to_f)); b.add_param(0, -x / 4.0); x
The target's maximum HP will be decreased by 25% of the damage dealt. Damage dealt will decrease as the user loses HP and Increase based on the target's missing HP.
The decrease in maximum HP is unfortunately permanent, but I have an idea of how to deal with this.
On turn 1 of every battle, the MHP values of each party member will be stored within a variable. (AHP)
At the end of combat, I'll have another variable store each party member's MHP value again through an event. (BHP)
Then use Change Parameters command to decrease MHP by BHP(should reduce the value to 0 or 1), and then Increase MHP by AHP.
AHP = MHP (become combat)
BHP = MHP (after combat)
MHP - BHP + AHP = Original MHP?
I'd have to use 2 variables for each actor though... -
Oh, if only we could work with array variables RPG Maker...I'd have to use 2 variables for each actor though...
-
you can use arrays in RM.Oh, if only we could work with array variables RPG Maker...
@Rinobi - that might kill the actor and cause a game over in case the subtraction fires first...