Thank you. I tried this, and the now the opposite is happening. The enemies now can damage the actors, but the actors can't damage them.
RMMV Damage Formula - ideas and help
RPG Maker MV SupportOh my bad. Minor capitalization error
actorId(), not actorid()
So:
actorId(), not actorid()
So:
Code:
if (a.isActor()) v[25] = a.actorId(); a.atk * 4 - b.def * 2
Oh are those two different things?? I did not know that. By the way, it works now. Thank-you.
yeah, javascript is case sensitive. meaning aA is sifferent from Aa that is different from AA that is different from aa
Hello!
I need help with a formula. So I have tried making a formula which damages the user, when it has over 30% HP and heals when it is below that percentage. Here's what I did:
(a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)
But I also want the skill to damage the enemy. Thus I tried to do it like this:
a.atk * 4 - b.def * 2 && (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)
This unfortunanly didn't work.
Can I please get help with this one? How can I fix this formula?
Thank you in advance.
I need help with a formula. So I have tried making a formula which damages the user, when it has over 30% HP and heals when it is below that percentage. Here's what I did:
(a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)
But I also want the skill to damage the enemy. Thus I tried to do it like this:
a.atk * 4 - b.def * 2 && (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1)
This unfortunanly didn't work.
Can I please get help with this one? How can I fix this formula?
Thank you in advance.
Is the 30% heal/damage supposed to happen to the user regardless of whether they target an enemy or ally?
Anyway, the logic in the second one is weird and is tripping you up.
if (a.hp < a.mhp * 0.3) a.gainHp(Math.floor(a.mhp * 0.1)); else a.gainHp(Math.floor(a.mhp * -0.1)); a.atk * 4 - b.def * 2
Anyway, the logic in the second one is weird and is tripping you up.
- You're not doing any sort of check to see if an enemy is targeted, if your system allows for the targeting of enemies or allies alike.
- The logic in the first part is a bit weird, because the a.atk * 4 - b.def * 2 part is always going to evaluate to true unless it equals 0.
- That's...not really how you use the ternary operator (value = conditional ? trueValue : falseValue) however you're trying to use it like a classic if...else.
- Damage needs to be the last thing in the formula box.
- So, overall, your formula is trying to assign whatever value gainHp() returns after it is executed. Since it doesn't return anything, the resulting damage is undefined.
if (a.hp < a.mhp * 0.3) a.gainHp(Math.floor(a.mhp * 0.1)); else a.gainHp(Math.floor(a.mhp * -0.1)); a.atk * 4 - b.def * 2
there are two things you are doing wrong: you don't use && to separate things in damage formulas, you use ;
&& is for comparisons.
and second, the damage is the last thing in the formula.
meaning you need to separate your a.atk * 4 - b.def * 2 from your (a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1) with an ; and a.atk * 4 - b.def * 2 goes the latest.
so,
(a.mhp * 0.3) < a.hp ? a.gainHp(a.mhp * -0.1) : a.gainHp(a.mhp * 0.1); a.atk * 4 - b.def * 2
@Aesica are you sure you can't use a ternary like that? while I mostly use them like "x = ternary" I think I already did something like this successfully before too...
Well technically...I suppose you could since you're still invoking the functions (gainHp in this case). I guess that's why I like Javascript (yes, I actually like it) because it seems like there's always bizarre, alternative ways to do something.
I'm trying to create an item that heals the user a variable amount. My initial attempt was 0.3*+(v[X]*.05), which in my mind translates to 30% plus 5% times Variable.
Since it didn't work, this is why I am here.
I want the item to heal a base 30%, but have it so that a variable adds 5%, in essence acting like the Estus Flask in Dark Souls 2 and 3, where it is enhanced to allow for more potent healing. Where do I go wrong in setting up the formula, and how could I make it work properly?
Since it didn't work, this is why I am here.
I want the item to heal a base 30%, but have it so that a variable adds 5%, in essence acting like the Estus Flask in Dark Souls 2 and 3, where it is enhanced to allow for more potent healing. Where do I go wrong in setting up the formula, and how could I make it work properly?
If I'm reading you right, you want to heal the user for 30% of their max HP, plus 5% x v[x]? Try this:
b.mhp * 0.3 + b.mhp * 0.05 * v[x];
So:
v[x] == 0 => 30% healing
v[x] == 1 => 35% healing
v[x] == 2 => 40% healing
...etc
This words perfectly! Thank you! ^n.=.n^
alternativelly, @Diretooth , you can use a very close code to both yours and @Aesica 's, but isntead of multiplying both sides for b.mhp you just multiply the result.
since multiplying both sides of an addition is the same as multiplying the result.
b.mhp * (0.3 + 0.05 * v[x])
assuming that you do mean a percentage of max hp, of course.
b.mhp is essential to be there though, or at least a value in its place. your original version of the code was doing it with 30% + 5% of variable... of 1. Since damage formula, be damage or heal, is rounded before being applied, it would only heal either 0 or 1, and 1 only if the variable was 4 or more to reach 50% to be rounded up.
since multiplying both sides of an addition is the same as multiplying the result.
b.mhp * (0.3 + 0.05 * v[x])
assuming that you do mean a percentage of max hp, of course.
b.mhp is essential to be there though, or at least a value in its place. your original version of the code was doing it with 30% + 5% of variable... of 1. Since damage formula, be damage or heal, is rounded before being applied, it would only heal either 0 or 1, and 1 only if the variable was 4 or more to reach 50% to be rounded up.
Honestly, I'm not sure why I wrote it the way I did, probably because I was tired if anything. But yeah, I'd suggest doing it this way over what I wrote:
Observed and updated. Thank you again for the help, both of you.
I'm looking to make some simple skills that have set damage ranges like in dragon quest. For example: a fire spell that does 10-20 damage or a heal spell that heals 30-50 Hp. Can someone help me with the formula? Thanks.
@itzel if by set damage ranges you mean it is in that range regardless if your attack or magic is 1 or 99...
for the 10-20 put damage as 15 and variance as 33%, and for heal between 30-50 put damage as 40 and variance as 25%.
variance is a random value up to that percentage of the damage (25% of 40 is 10, so from 0 to 10) that has a chance of being either added or removed from the damage. meaning that damage 40 with 25% variance can go anywhere from 30 to 50, or from 40-10 to 40+10
for the 10-20 put damage as 15 and variance as 33%, and for heal between 30-50 put damage as 40 and variance as 25%.
variance is a random value up to that percentage of the damage (25% of 40 is 10, so from 0 to 10) that has a chance of being either added or removed from the damage. meaning that damage 40 with 25% variance can go anywhere from 30 to 50, or from 40-10 to 40+10
Code:
Math.randomInt = function(max) {
return Math.floor(max * Math.random());
};
EDIT: Silva pointed out a mistake I made,
Math.randomInt(max) generates a whole number between 0 and (max -1)
Code:
Math.randomInt(10) + 10
one thing to note is that the max damage will be the two values combined (9 + 10) while the minimum damage will be the 10 at the end.
@xDRAGOONx that is a good one, but would need variance to be set to 0...
but as I said ealier, variance is there to do... exactly that already...
but as I said ealier, variance is there to do... exactly that already...
I apologize, I had actuall meant to reply to itzel with that comment.
Original thread: https://forums.rpgmakerweb.com/threads/rmmv-damage-formula-ideas-and-help.47099/