@Kes uhm, I replied to this, in which he explicitly stated he wanted to know the MV version of the formula
How to make the most of custom formulae. Part #1
RMVXAce Tutorials@Engr. Adiktuzmikohow right you are. I had forgotten that bit. My apologies.
This is indeed quite the wrong place for it though 🙂
I'm trying to write a formula which increases the damage done by 1% for every decrease of 1% in the user's HP. What I have so far is this:
a.atk *4 - b.def * 2 + ((a.atk*4 - b.def * 2) * (a.mhp - a.hp)/a.mhp)
However, this produces zero damage and I can't see what my mistake is.
Can anyone enlighten me?
Thanks.
a.atk *4 - b.def * 2 + ((a.atk*4 - b.def * 2) * (a.mhp - a.hp)/a.mhp)
However, this produces zero damage and I can't see what my mistake is.
Can anyone enlighten me?
Thanks.
Hm, I do know that Ruby is a bit picky with spacing, so try and see if you should put some more spaces between your numbers and operators.
Anyway, this formula seems to be written correctly. The only way this formula should get a 0 is if you were trying to test this against an enemy with very high defense. For example, if a has 10 attack and b has 5 defense, that should be (40)-(10) which becomes a minimum of 30 damage, but b should need about 20 defense (40) to negate that attack.
Also, here's an alternate way to write your formula: (a.atk * 4 - b.def * 2) * (1 + (a.mhp - a.hp) / a.mhp)
Anyway, this formula seems to be written correctly. The only way this formula should get a 0 is if you were trying to test this against an enemy with very high defense. For example, if a has 10 attack and b has 5 defense, that should be (40)-(10) which becomes a minimum of 30 damage, but b should need about 20 defense (40) to negate that attack.
Also, here's an alternate way to write your formula: (a.atk * 4 - b.def * 2) * (1 + (a.mhp - a.hp) / a.mhp)
@Harosata Arrghhh! It was a spacing issue. I must have been really tired when I typed that. Thank you for suggesting that.
Just out of curiosity I tried your version and it returned no more damage when the actor had 1HP than when he had 200. Multiplying the (a.mhp - a.hp) / a.mhp) by 1 is bound to give less than multiplying it by a.atk * 4 - b.def * 2 isn't it?
Just out of curiosity I tried your version and it returned no more damage when the actor had 1HP than when he had 200. Multiplying the (a.mhp - a.hp) / a.mhp) by 1 is bound to give less than multiplying it by a.atk * 4 - b.def * 2 isn't it?
Hm, I'm pretty certain that your damage formula is (damage * 1) + (damage * 1 * percent), and if math/Excel serves correctly, I could rewrite that as damage * (1+ (1*percent)). Because if your HP is full, that should be damage + (damage * 1/1) or damage * 2.
Hm, I would say that the biggest problem with writing formulas is that some variables can convert the semi-answers to an integer instead of a float. Probably have to put a few .to_f in there so that results become more accurate.
Hm, I would say that the biggest problem with writing formulas is that some variables can convert the semi-answers to an integer instead of a float. Probably have to put a few .to_f in there so that results become more accurate.
Oh thank you great guide! Keep up the good work
Hm, a thought just occurred to me. State Resist [state] is a feature you'd normally give to ensure that a state is not added to a battler, and state_resist?(state_id) is its method. Now, I'd imagine that if there is an enemy resistant poison but you use a bomb to give them an illness, the formula could be written as:
if b.state_resist?(POISON); b.add_state(ILLNESS); end; 0
And yet consider this:
b.state_resist?(SMALL) ? 1000 : 10
This is a skilled called Stomp and it will deal a lot of damage if the target is small. That's right, we don't actually use a SMALL state but instead use it as a racial property by making the target Resist that state. This applies to both Actors and Enemies as well as anything linked to them, which would include Classes, Weapons, Armor and States. In other words, if we apply Shrink which has a State Resist[SMALL] in it, the affected target will return true for state_resist?(SMALL)
Now, here's another example, a purchased skill for everyone:
a.state_resist?(BEASTMAN) ? 100 : 75
Now, we can ideally give this to the Beastman member of our party for maximum damage. However, we can also transform into a "Beastman" or equip Beastman claws to also qualify for that higher damage.
And finally, something like Waltz, a dance between man and woman in the form of:
a.state_resist?(FEMALE) != b.state_resist?(FEMALE) ? b.add_state(CHARM) : b.add_state(CONFUSE)
Which can become a bit ridiculous if you have your male dancer dress up as a female to charm the majority of male enemies or if you have to transform all those enemies into girls first.
...I will admit, you can use notetags instead, but I figure this is an interesting way if you are uncomfortable with notetags. Also, you can use this method on the map (Entering a girls-only slumber party with disguises or chopping wood with an appropriate ax without having to check each individual equipment) but this topic isn't for that.
---
Theoretically, that should also qualify for other Features, but since most rates are multiplicative, I do not think it is easy to use State Rate to measure how Evil you are.
if b.state_resist?(POISON); b.add_state(ILLNESS); end; 0
And yet consider this:
b.state_resist?(SMALL) ? 1000 : 10
This is a skilled called Stomp and it will deal a lot of damage if the target is small. That's right, we don't actually use a SMALL state but instead use it as a racial property by making the target Resist that state. This applies to both Actors and Enemies as well as anything linked to them, which would include Classes, Weapons, Armor and States. In other words, if we apply Shrink which has a State Resist[SMALL] in it, the affected target will return true for state_resist?(SMALL)
Now, here's another example, a purchased skill for everyone:
a.state_resist?(BEASTMAN) ? 100 : 75
Now, we can ideally give this to the Beastman member of our party for maximum damage. However, we can also transform into a "Beastman" or equip Beastman claws to also qualify for that higher damage.
And finally, something like Waltz, a dance between man and woman in the form of:
a.state_resist?(FEMALE) != b.state_resist?(FEMALE) ? b.add_state(CHARM) : b.add_state(CONFUSE)
Which can become a bit ridiculous if you have your male dancer dress up as a female to charm the majority of male enemies or if you have to transform all those enemies into girls first.
...I will admit, you can use notetags instead, but I figure this is an interesting way if you are uncomfortable with notetags. Also, you can use this method on the map (Entering a girls-only slumber party with disguises or chopping wood with an appropriate ax without having to check each individual equipment) but this topic isn't for that.
---
Theoretically, that should also qualify for other Features, but since most rates are multiplicative, I do not think it is easy to use State Rate to measure how Evil you are.
Is it possible to have a sort of voidform state?
E.g. you use voidform, you gain let's say, 100 mana points, you can spend those mana points on anything that's linked to the voidform skill category, but the 100 mana depletes per turn?
Or:
You pop voidform, can use unlimited skills in voidform skill category for 4 turns, then it drops off and you go back to normal mode?
E.g. you use voidform, you gain let's say, 100 mana points, you can spend those mana points on anything that's linked to the voidform skill category, but the 100 mana depletes per turn?
Or:
You pop voidform, can use unlimited skills in voidform skill category for 4 turns, then it drops off and you go back to normal mode?
I think the question deserve their own thread? not sure if custom formula alone could deal with it
This has been INCREDIBLY helpful for me. Just saved me hours and hours of testing. Thank you so much xD
Im trying to figure out how to make a mp draining heal hp. I'm probably over thinking it and after a week i can't get it working
Am i overlooking something?
Am i overlooking something?
Your question might be better if you create a new thread for more visibility than asking it here.
What would be the setup for an if statement for a skill that compares the users and targets attack/m.atk/hp and then do damage based on the outcome. For example I am trying to make a skill that is based on the users attack vs the targets attack. If the user has higher attack then the skill does double the damage, but it only does half if the targets attack is higher.
Great tutorial, easy to understand and follow!
So I was asking in the Damage Formula 101 thread but didn't want to clutter it. Got a response that a lot of the functionalities there can't be use in VXA due to different programming languages:
@ATT_Turan I checked the VXA script call list, but it's all about changing data and performing actions. Here, I want to perform boolean checks. For example, I want to know if a specific enemy is inflicted with poison or not. Is a battler guarding? Are they wielding a weapon or not?
There's an example of that on the first page of this thread, post 11.
There's a lot more I want to know such as the other examples, but I guess I'll just have to post here and see if anyone can reply. Thanks though.
You can use the same function to check if it has a certain state
This only works for actors they are the only one that has weapons.
For example
a.weapons.size > 0Throw your questions here.
Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-most-of-custom-formulae-part-1.1143/