RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 36 of 77 View original ↗
  1. Waterguy said:
    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. :)
  2. 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?
  3. try to separate else if
  4. Waterguy said:
    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)
  5. 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 ;}
  6. Waterguy said:
    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.
  7. 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
  8. Waterguy said:
    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
  9. Happy Birthday!


    Seriously, if anyone that understands damage formulas better could tell what we did, wrong and right...
  10. Waterguy said:
    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.
  11. ...


    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...
  12. Waterguy said:
    ...


    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 .
  13. 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.
  14. 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
  15. Waterguy said:
    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. :)
  16. yeah, I had a problem with a plugin later because I forgot those too, sorry...
  17. 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! :)
  18. 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?
  19. 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!
  20. 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.