RMMV Damage Formula - ideas and help

Riku_Masamune

Veteran
Veteran
Joined
Aug 23, 2016
Messages
42
Reaction score
15
First Language
English
Primarily Uses
RMMZ
@Riku_Masamune Hey, see if this works:



a.gainHp(-(Math.randomInt(500) + 500)) ; a.mat * 5


My syntax might be off somewhere, but the Math.randomInt(500) function should give you something in the 0 to 499 range, so adding 500 after should give you the 500 to 999 you're looking for. :)

Works, but then for every enemy the spell hits, it stacks up damage (570 and 980 were the numbers I saw). But then I guess that's the point of a taxing spell. Thanks a ton!
 

kovak

Silverguard
Veteran
Joined
Apr 3, 2016
Messages
1,263
Reaction score
1,565
First Language
PT - EN
Primarily Uses
RMMV
Guys, i know i can use a.addState(); to apply a state to actors but i wanna know how can i add more than 1 state using this method.
 

Riff

Eorzean
Veteran
Joined
Oct 25, 2015
Messages
266
Reaction score
84
First Language
English
Primarily Uses
RMMV
Guys, i know i can use a.addState(); to apply a state to actors but i wanna know how can i add more than 1 state using this method.


You can repeat, i believe. Like a.addState(x); a.addState(y); a.addState(z);
 

BodkinsOdds

Villager
Member
Joined
Jul 26, 2014
Messages
8
Reaction score
2
First Language
English
Primarily Uses
And to the original question of adding a D4 to a formula it would be Math.randomInt(4) + 1, meaning the complete formula is:


a.atk + Math.randomInt(4) + 1 - b.def


Oh, sorry. I seem to have missed the intervening posts that answered already.
 
Last edited by a moderator:

emelian65

Veteran
Veteran
Joined
Sep 13, 2015
Messages
190
Reaction score
50
First Language
Spanish
Primarily Uses
How should I do this?


I have a skill for a vampire that is obviously Bite, to feed on Foe and Allies, however I would like that when the skill is used in the actor with Id 2 then a state is applied to both the user and the target


if (b.isActor(2)) {
a.addState(12)
b.addState(12)
} else {
a.addState(11)
}


in the above case the state 12 is applied to any ally and the user not only when the skill is used on actor 2 but on any other actor.


So how should I do it?
 
Last edited by a moderator:

jonthefox

Veteran
Veteran
Joined
Jan 3, 2015
Messages
1,436
Reaction score
596
Primarily Uses
Is there a way to include a variable in the battle formula based on the specific actor or class being targeted?


Example:  enemy uses a skill that does X+Y dmg, where Y is different variable depending on what class the targeted actor is.  
 
Joined
Sep 11, 2016
Messages
2
Reaction score
3
First Language
English
Primarily Uses
I am currently researching these things, since I am new to all this thing, and it's all rather complex to a newbie, I know, I should probably learn how to place shop events down, lol. Just kidding, I know how to event.


Still, I am looking for a way to make these two skills work at the moment: one of them is a skill that has a chance to land multiple hits (2 to 6 hits) and the other one, the less HP the enemy has, the more damage the skill does. I figure it has something to do with Math, but I'm not sure how exactly I can check what Math values the system understands.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
@Drone of Ether the damage formula is a full eval of javascript. So it understands any mathematical formula that you can program in javascript (within its length, no formula that would require a thousand commands to calculate)
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
I'm having trouble with this formula...


i = Math.randomInt(2); a.addBuff(2, 1); c = (a.atk * 4 - b.def * 2) * 2; d = c * (Math.randomInt(41) / 100 + 0.8); (i === 1) ? {a.gainHp(-d) ; 0} : c


it was supposed to:

  • choose either 1 or 0 randomly (saving it on 1),
  • add an attack buff to the character,
  • calculate the damage (saving it on c)
  • calculate a "variance" (saving it on d)
  • if i is 1, gives the user d of damage and 0 to enemy, else give the enemy 0 damage.

Basically Invigorate from bravely default.


But it is giving neither the enemy or the user any damage...


Help, please?
 

GammaVD

Veteran
Veteran
Joined
Oct 29, 2015
Messages
70
Reaction score
3
First Language
English
if I remember correctly, new variables need to have the 'var' keyword in-front of them


so


var i = Math.randomInt(1); a.addBuff(2, 1); var c = (a.atk * 4 - b.def * 2) * 2; var d = c * (Math.randomInt(41) / 100 + 0.8); (i === 1) ? {a.gainHp(-d) ; 0} : c


Also, Math.randomInt(integer) returns a number from zero to the specified integer, so you want 1 not 2


Try this and see if it work
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Didn't work...


I know it works like that on scripts plugins but every time I did so for damage formulas they worked without the var.


And I heard it goes from 0 to (number - 1), so 2 should give either 0 or 1...
 

GammaVD

Veteran
Veteran
Joined
Oct 29, 2015
Messages
70
Reaction score
3
First Language
English
no, I went and checked, its between 0 and number inclusive, you might be confusing it with arrays were the length 2 has 0 & 1 cause all arrays start at zero


If it isn't throwing a runtime error and just giving 0 damage then there is an error in the formula and it will default to zero


I can only suggest testing each part as an individual formula to find what part isn't working
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Tested like you said.


Putting 1 in randonInt did not want to get me a 1 no matter how much I tried... where I saw the command said that if you put 100 it gives a number from 0 to 99, are you sure yours is right?


Found the error, though.


i = Math.randomInt(2); a.addBuff(2, 1); c = (a.atk * 4 - b.def * 2) * 2; d = c * (Math.randomInt(41) / 100 + 0.8); (i === 1) ? {a.gainHp(-d); 0} : c


also, just the a.gainHp(-d) seemed to work without the 0, (also, need to put a Math.floor on d) so I'm doing like this, but I'd like to know if anyone knows if it is possible to use a block there and how...


Either way, thanks for the help! ^_^
 
Last edited by a moderator:

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,520
Reaction score
1,655
First Language
English
Primarily Uses
RMMV
I'm coming back to a project I worked on last year, but I'm stuck on a damage formulae after doubling the max HP value of my character.


What I currently have in MV and worked with my character sitting at 21 max HP, but now that I have him at 42 max HP, it's all messed up. What do I change to make this work? Bonus points if the change is able to roughly take into account some level scaling (it's a small game, so the max HP won't go up by a lot).


c=b.hp;d=b.mp;b.gainHp(-b.hp+1);b.gainMp(-b.mp); b.gainMp(Math.round(c*0.5-b.level));b.gainHp(Math.round(d*1.33+b.level-1));0




(What it's meant to do (very roughly) is swap the user's HP and MP around.)
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
c=b.hp;d=b.mp;b.setHp(Math.round(d*1.33+b.level-1));b.setMp(Math.round(c*0.5-b.level));0


... if you are doing the user's, I don't know if using b works, but anyways if you already got h.p and m.p as c and d why aren't you using them right away?


Anyways, I think setHp/No should work better for you... but better to put a min on h.p if it works so it can't kill the user...
 
Last edited by a moderator:

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,520
Reaction score
1,655
First Language
English
Primarily Uses
RMMV
c=b.hp;d=b.mp;b.setHp(Math.round(d*1.33+b.level-1));b.setMp(Math.round(c*0.5-b.level));0


... if you are doing the user's, I don't know if using b works, but anyways if you already got h.p and m.p as c and d why aren't you using them right away?


Anyways, I think setHp/No should work better for you... but better to put a min on h.p if it works so it can't kill the user...
Well, I got help on the formulae when I made it like last year, because I suck at damage formulaes. I kind of understood how VX Ace's worked, but MV seems to have made things way more complicated (the same formulae in VX Ace is only like half the length of the one I have in MV). Also, from my playtesting, it's not actually possible for the user to kill itself using this skill, as it regenerates 3MP after casting it, on top a passive 1MP regen every turn, making it impossible to fully drain his life, although it does go too low for my liking (or doesn't increase enough in a reverse scenario), due to having increased max HP from when I first made the formulae.


What do I change to make this work?
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
What, my version of the formula is not working?


Then sorry, I have no idea. Without pc right now to test for you...


Save to change the b. for a. that is. Who knows
 
Last edited by a moderator:

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,520
Reaction score
1,655
First Language
English
Primarily Uses
RMMV
What, my version of the formula is not working?


Then sorry, I have no idea. Without pc right now to test for you...


Save to change the b. for a. that is. Who knows
After trying out a bunch of different stuff, I think I got it to work with the hero's new max HP value, using this:


c=b.hp;d=b.mp;b.gainHp(-b.hp+1);b.gainMp(-b.mp); b.gainMp(Math.round(c*0.25-b.level));b.gainHp(Math.round(d*2.67+b.level-1));0


It  makes a 0.25 of what first was a 0.5, and doubles the 1.33 into a 2.67. It seems to be working, but I'll report back if I run in more problems.
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,520
Reaction score
1,655
First Language
English
Primarily Uses
RMMV
I have a skill that needs to be able to do 2 things at once. I can make them work individually, but I don't know how to make them work together. The first effect simply deals an amount of damage. The other effect inflicts a condition if the target has a certain condition on them.


Damage:


a.mat*1.33-b.mdf*0.33


Condition:


b.state?(59)?b.addState(61)


How does the formulae needs to be written so it uses both effects?
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
I think this should work...

Code:
if b.isStateAffected(59) b.addState(61); a.mat*1.33-b.mdf*0.33
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top