RMMV Damage Formula - ideas and help

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 think this should work...



if b.isStateAffected(59) b.addState(61); a.mat*1.33-b.mdf*0.33


edit: Okay, now I got it to work. Thanks. :)
 
Last edited by a moderator:

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Hello i'm new to RPGmaker MV and i'm running in a bit of trouble with the damage formula of the attack skill and i wonder if someone can help me.


Currently i have this:


if (a.actorId() == 1)


{a.atk * 4 + 560 - b.def * 2;}


elseif(a.enemyId() >= 1)


{a.atk * 4 - b.def * 2 ;}


But the actor and enemy only deals 0 damage.


If i remove the elseif statement the actor deals the correct ammount of damage but the enemy deals nothing cause i didn't specify it and if i only do this:


if( a.enemyId() >= 1 ) {a.atk * 4 - b.def * 2 ;} only the enemy will do damage.


(Thought some plugins might interfere so i also tested it in a new project same results.)


So can someone tell me why it doesn't work and what it should be?
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
try to separate else if
This is what caused the first part of the formula to go wrong thank you, but now the enemy doesn't deal damage i have also tried this:


if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2;}else{ if( a.isEnemy()){ a.atk * 4 - b.def * 2 ;}}


this also only made the actor do damage while the enemy does no damage.


(EDIT: my spelling was off missed some letters)
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
The only notable thing I did as far as I know was add a space between the } and the else and it worked for me...

Code:
if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2;} else if( a.isEnemy()){a.atk * 4 - b.def * 2 ;}
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
The only notable thing I did as far as I know was add a space between the } and the else and it worked for me...



if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2;} else if( a.isEnemy()){a.atk * 4 - b.def * 2 ;}
It doesn't work for me :( .


I did like you say and also just copy paste your line of code but the enemy keep dealing 0 damage.
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Uh. I tested again, and this time it dealt no damage...


Then tested if( a.isEnemy()){a.atk * 4 - b.def * 2 ;} to see if the problem is there, it worked. Did not test  if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2;}  because you said it worked.


so I tested again with if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2;} else if( a.isEnemy()){a.atk * 4 - b.def * 2 ;} and it worked again.


http://starecat.com/content/wp-content/uploads/my-code-doesnt-work-i-have-no-idea-why-my-code-works.jpg
 
Last edited by a moderator:

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Uh. I tested again, and this time it dealt no damage...


Then tested if( a.isEnemy()){a.atk * 4 - b.def * 2 ;} to see if the problem is there, it worked. Did not test  if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2;}  because you said it worked.


so I tested again with if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2;} else if( a.isEnemy()){a.atk * 4 - b.def * 2 ;} and it worked again.


http://starecat.com/content/wp-content/uploads/my-code-doesnt-work-i-have-no-idea-why-my-code-works.jpg
Thank you for your efforts and fast replies, just woke up so i'm glnna check it a bit later.


Though my replies might be delayed it just so happens that it is my birthday today
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Happy Birthday!


Seriously, if anyone that understands damage formulas better could tell what we did, wrong and right...
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Happy Birthday!


Seriously, if anyone that understands damage formulas better could tell what we did, wrong and right...
Thanks :D !


ok ignore this between  the quotes i figured out what was wrong now i need to see how i will aply a fix


"Still can't get it to work though it only does what the if statement says it has to do and ignores the rest maybe this will clarify where the fault lies, i changed the code to this:


if(a.actorId() == 1){a.atk * 4 + 560 - b.def * 2 ;} else {a.atk * 4 - b.def * 2 ;}"


The problem is this allways is true " if(a.actorId() == 1)" (I don't know why it is allways true) i figured this out by changing the code to this:


if(a.isActor()){a.atk * 4 + 560 - b.def * 2 ;} else {a.atk * 4 - b.def * 2 ;} and this worked correctly then tried this:


if(a.isActor()){a.atk * 4 + 560 - b.def * 2 ;} else if( a.isEnemy()){a.atk * 4 - b.def * 2 ;} and it also worked correctly.


So with that i know that this statement allways is true "if(a.actorId() == 1)" but why?


EDIT: No wait if that statement is true then it would grab that formula but the enemy deals 0 damage........... I'm confused :unsure: .


And thanks Waterguy for the help.
 
Last edited by a moderator:

YoraeRasante

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


That wouldn't make the damage be 0 though...


ok, try  if( a.isActor()  && a.actorId() === 1) since the problem could be either the lack of a third = (javascript uses three =s mosd of the time from what I saw, no idea of the difference yet (for lack of research) but it is there and may be it) or the fact that a.actorid() checks the id but...what does it give when it is not an actor?


Ok, I can find out easily, but it is too late right now and I'm sleepy...
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
...


That wouldn't make the damage be 0 though...


ok, try  if( a.isActor()  && a.actorId() === 1) since the problem could be either the lack of a third = (javascript uses three =s mosd of the time from what I saw, no idea of the difference yet (for lack of research) but it is there and may be it) or the fact that a.actorid() checks the id but...what does it give when it is not an actor?


Ok, I can find out easily, but it is too late right now and I'm sleepy...
I thank you once more this is what  works thus what i needed :D .


Now to get the formulas more complicated and when i run in something again i will come back here BD .
 

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
Back here once again. I've been trying to get this to work, but everything I tried, failed.


What I currently got, what isn't working:


b.isStateAffected(59) ? b.addState(57) ; a.atk * 1.5 - b.def * 0.33 : a.atk * 1.5 - b.def * 0.33


What I'm trying to do:


If target has condition (59) on them, it puts condition (57) onto them. In addition, when the condition is met, the skill also does more damage.


I can get a simpler version to work, in which it puts the condition onto the target if the condition is met, but when adding a secondary effect (damage, in this case) to the formula, it stops functioning.
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Your first problem: b.isStateAffected(59) ? b.addState(57) ; a.atk * 1.5 - b.def * 0.33 : a.atk * 1.5 - b.def * 0.33


There is nothing there saying they are supposed to be together. As far as the program goes, b.isStateAffected(59) ? b.addState(57) ; is one line and a.atk * 1.5 - b.def * 0.33 : a.atk * 1.5 - b.def * 0.33 is the other.


Your second problem is one I had earlier. I do not think ? : can be used with more than one line, even with {}s, or so my problem seemed. You'll have to use if-else instead.


So it would be


if b.isStateAffected(59) {b.addState(57) ; a.atk * 1.5 - b.def * 0.33;} else a.atk * 1.5 - b.def * 0.33


Give it a try
 

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
Your first problem: b.isStateAffected(59) ? b.addState(57) ; a.atk * 1.5 - b.def * 0.33 : a.atk * 1.5 - b.def * 0.33


There is nothing there saying they are supposed to be together. As far as the program goes, b.isStateAffected(59) ? b.addState(57) ; is one line and a.atk * 1.5 - b.def * 0.33 : a.atk * 1.5 - b.def * 0.33 is the other.


Your second problem is one I had earlier. I do not think ? : can be used with more than one line, even with {}s, or so my problem seemed. You'll have to use if-else instead.


So it would be


if b.isStateAffected(59) {b.addState(57) ; a.atk * 1.5 - b.def * 0.33;} else a.atk * 1.5 - b.def * 0.33


Give it a try


Sorry for the late reply. Your version didn't work at first, until I added () and {}, like this:


if (b.isStateAffected(59)) {b.addState(57) ; (a.atk*1.5-b.def*0.33)*1.5;} else {a.atk*1.5-b.def*0.33}


And yeah, I had no idea how to put those effects, but now I know. :)
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
yeah, I had a problem with a plugin later because I forgot those too, sorry...
 

HasuHasi

Learning every day
Veteran
Joined
Aug 15, 2014
Messages
48
Reaction score
3
First Language
English
Primarily Uses
This might be a silly question: but is it possible to have different elements in one attack? For example a fire sword that deals 50% physical and 50% fire damage and the restistances/weaknesses are calculated seperately? 

For example, the sword deals 100 damage, 50% as physical, 50% as fire. 


Actor uses it to attack the.. fire demon, who has a physical rate of 100% and fire rate of 0% (thusly, takes 0 damage from fire). He then would suffer 50 physical damage and 0 fire damage, since resistances are calculated seperately. When I try to give my sword both Attack Elements, the engine seems to look which one will deal most damage, and then deal only that element (in this example it would ignore the fire element, and deal 100 physical damage (which I find kind of lame :-( )). 


Is it possible to achieve this effect? I'd also be fine with defining the damage such as "10 physical damage & 10 fire damage" like weapons in Diablo 3 often have. 


Thank you for the help! :)
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Through damage formula, as far as I know, it will still be affected by the skill's/weapon's attack element. But I think you could make the skill cause half the damage, then make it call a second, fire-element skill for the other half?
 

HasuHasi

Learning every day
Veteran
Joined
Aug 15, 2014
Messages
48
Reaction score
3
First Language
English
Primarily Uses
Yeah I figure that will definitely work, although I was hoping, there was a *more elegant* way to accomplish this effect. 


Thanks for the help!
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Well, I know of at least one plugin that allows for multi-elemental skills, Yanfly's Elemental Core, but it is more a mix of the damage rates than a 50-50 damage type split.
 

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

Latest Threads

Latest Posts

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,033
Messages
1,018,441
Members
137,820
Latest member
georg09byron
Top