The Tale of the Math Conflict.

● ARCHIVED · READ-ONLY
Started by Trommer 10 posts View original ↗
  1. Greetings!

    I am working on a way to increase a skills damage/healing based upon a variable. But now I have hit a wall. I'm trying to make the variable an % increase.

    Aka a variable of 5 should be 5% increase of damage and so on.

    So I though it would look something like this:

    [increase spell damage by 5%]

    Set control variable: [0001: spell damage] = 5

    [Very Original Fireball]

    (a.mat * 4 + a.mp * 4) + v[1]%

    So it would add everything up and then add the extra % on top of that in the end. so if it was 5% it would deal a total off 105% damage.

    I have tried almost everything but all I get is errors or the wrong math. I would be very grateful for any thoughts on this.
  2.   (a.mat * 4 + a.mp * 4) +  (  (a.mat * 4 + a.mp * 4) * v[1]  )   / 100 

    I think this will do the trick. Parentheses have the higher priority of the used operators here. 

    So let's use them a LOT here just to be sure.

    I assume that the damage for your spell is given by  

    (a.mat * 4 + a.mp * 4)   

    plus 5% of that whole thing in the parentheses if the variable is 5. The variable is variable with id=1

    So...

     (  (a.mat * 4 + a.mp * 4) * v[1]  )   / 100  

    gives you this 5%

    Tell me if that soved the case. 
  3. easier and shorter would be the following code:

    (a.mat * 4 + a.mp * 4) * (100+v[1])/100The first part is the base damage, multiplied by the total percentage choosen (100% + V[1]%).It is important to have the division by 100 as late as possible, because the integer functions will cut off any remainder from the operation.
  4. Thanks man! Amazing work!
  5. Andar said:
    easier and shorter would be the following code:

    (a.mat * 4 + a.mp * 4) * (100+v[1])/100The first part is the base damage, multiplied by the total percentage choosen (100% + V[1]%).It is important to have the division by 100 as late as possible, because the integer functions will cut off any remainder from the operation.

    Wait, that returns just the percentage to be added if I am not wrong.

    Was that what was asked or was it a bonus x%?

    I mean I think the person wanted the base damage PLUS that percentage.

    I see what you did there. :) God job.
  6. To clarify I wanted the 5% to add to the total damage. So let's say I have a skill that deal 100 damage. If I have [increase spell damage by 5%] it would deal 105 damage instead.
  7. Trommer said:
    To clarify I wanted the 5% to add to the total damage. So let's say I have a skill that deal 100 damage. If I have [increase spell damage by 5%] it would deal 105 damage instead.

    Yes what @Andar wrote is 100% correct. My bad. And it is more simple and easy to read and understand.

    (a.mat * 4 + a.mp * 4) * (100+v[1])/100

    (100+v[1])/100 equals to 100% + v[1]%

    So for V1 = 5 this becomes 105.

    So it is (a.mat * 4 + a.mp * 4) * 105%

    A very nice way to code it, since it is easier to tweak it if needed and easier to understand. 
  8. Yes what @Andar wrote is 100% correct. My bad. And it is more simple and easy to read and understand.

    (a.mat * 4 + a.mp * 4) * (100+v[1])/100

    (100+v[1])/100 equals to 100% + v[1]%

    So for V1 = 5 this becomes 105.

    So it is (a.mat * 4 + a.mp * 4) * 105%

    A very nice way to code it, since it is easier to tweak it if needed and easier to understand. 
    Don't worry mate, I am still very glad for you insight. :)
  9. Andar said:
    easier and shorter would be the following code:

    (a.mat * 4 + a.mp * 4) * (100+v[1])/100
    even shorter:

    Code:
    (a.mat + a.mp) * 4 * (100+v[1])/100
    even shorter:
    Code:
    (a.mat + a.mp) * (100+v[1])/25
    ;)
  10. Just as a heads-up, the % sign is the "modulo" operator in many programming languages, including Ruby.  Modulo divides one number by another and returns the remainder, so "73 % 10" would return 3.  RPG Maker thought you were trying to use a modulo operation here, but there was no number following the operator, so the formula errored out.

    Whenever you want to work with X percent, always use the form X / 100.0 (sometimes 100 will work in place of 100.0, but it can cause serious precision issues), rather than the form X%.