RMMV Damage Formula - ideas and help

Discussion in 'RPG Maker MV' started by Shaz, Oct 25, 2015.

  1. Confodere

    Confodere Villager Member

    Messages:
    24
    Likes Received:
    26
    First Language:
    German
    Primarily Uses:
    RMMV
    Hmm, are you sure? I know for example you can add states with a formula like this:
    a.addState(id); (a.atk * 1.3 - b.def)

    This example would deal damage to the enemy and give state xy to the user. Taking this in mind i thought it must be possible to use something like a.ifstate(id); b.addstate(id)
     
  2. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    You will have to use a FOR statement in your formule if you would want to copy every state the target has with one skill.
    And you wanted to only copy beneficial states? If so it will get a little bigger.
     
  3. Confodere

    Confodere Villager Member

    Messages:
    24
    Likes Received:
    26
    First Language:
    German
    Primarily Uses:
    RMMV
    Hey there, could you explain me what exactly a FOR statement is?
     
  4. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Am at the dentist.
    There you can find what you search for
    https://www.w3schools.com/js/js_loop_for.asp
    This is the correct link.
    You may need to use plugins to make use of it in a damage formule.
    When i have more time i could give you an proper example.
     
    Last edited: Dec 17, 2018
  5. Boonty

    Boonty Veteran Veteran

    Messages:
    38
    Likes Received:
    14
    First Language:
    French
    Primarily Uses:
    RMMV
    I want to create a formula for a combined skill between actor 1 and actor 2 (either performed by actor 1 or actor 2) where the damage is the sum of actor 1 attack and actor 2 magic attack.

    If I enter "$gameActors.actor(1).param[2] + $gameActors.actor(2).param[4]", it make 1 damage. Formula error ? Or correct formula but plugins incompatibility ?
     
  6. Boonty

    Boonty Veteran Veteran

    Messages:
    38
    Likes Received:
    14
    First Language:
    French
    Primarily Uses:
    RMMV
    Somebody to help with my above problem ? It has been 3 days that I torture myself :frown:
     
  7. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Use param(1) instead of this param[1].
    These [ ]are used for objects (and perhaps even more) and param is a function that you have to give an id to work with.
    If you put your line in the debug console you can test it.
     
    Boonty likes this.
  8. Boonty

    Boonty Veteran Veteran

    Messages:
    38
    Likes Received:
    14
    First Language:
    French
    Primarily Uses:
    RMMV
    Thanks jetboost !
     
    jetboost likes this.
  9. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Here is what you need:

    Code:
    if(target.states().length != 0){
    for(i=0; i < target.states().length;i++)
    {user.addState(target.states()[i].id)
    }}
    *You need Yanfly damage core plugin for this to work. Edit(control to core. the plugin gives more control it wasn't named as such sorry about that)

    This will copy every state the target enemy has and gives them to you.
     
    Last edited: Dec 22, 2018
  10. The_Black_Knight

    The_Black_Knight Veteran Veteran

    Messages:
    59
    Likes Received:
    3
    First Language:
    Finnish
    Primarily Uses:
    RMMV
    So, I ran into an issue with Absorption Barrier. I tried to make an attack that would deal good damage against enemy barriers, but otherwise deal normal damage.
    What I managed does deal good damage to barriers, however it also deals 0 hp damage every time I attack, and once the barrier is gone it only deals that 0 damage.
    It's even on my actor with the highest attack, and the others do deal succesful hp damage to the enemy.
    Help?

    Edit: Nevermind I'm an idiot everything works now, I had removed the multiplier from the normal attack damage.
     
  11. Arin

    Arin Tonight...we dine...in-oh a piece of candy! Veteran

    Messages:
    1,225
    Likes Received:
    189
    Location:
    Why is this important?
    First Language:
    Fraglspock
    Primarily Uses:
    RMMV
    Alright, if someone could help me out with a specific skill, I would really appreciate it.

    The Skill's tooltip is "Deals 50% more damage for each negative parameter status change the enemy has". This can scale up to 250% for all 5 states (Attack, Defense, Magic Attack, Magic Defense, and Agility). If the enemy doesn't have any debuffs on them, it's a regular "a.mat * 2 - b.mdf".

    I'm also using Yanfly's Damage Core to write this code. I've tried it myself but the damage doesn't work. Not even a 0 damage popup, it simply does nothing.

    <damage formula>

    value = a.mat * 2 - b.mdf;

    if (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

    value *= 3.5;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

    #No Agility Debuff/Everything Else

    value *= 3.0;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

    #No Magic Defense Debuff/Everything Else

    value *= 3.0;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

    #No Magic Attack Debuff/Everything Else

    value *= 3.0;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(40)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

    #No Defense Debuff/Everything Else

    value *= 3.0;

    } elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

    #No Attack Debuff/Everything Else

    value *= 3.0;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(30)) {

    #No Magic Defense/Agility Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(40)) {

    #No Magic Attack/Agility Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

    #No Defense/Agility Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

    #No Attack/Agility Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(30)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

    #No Attack/Defense Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

    #No Attack/Magic Attack Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

    #No Attack/Magic Defense Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(40)) && if (b.isStateAffected(53)) {

    #No Defense/Magic Attack Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

    #No Defense/Magic Defense Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) && if (b.isStateAffected(53)) {

    #No Magic Attack/Magic Defense Debuff

    value *= 2.5;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(57)) {

    #No Magic Attack/Magic Defense/Agility Debuff

    value *= 2.0;

    } elseif (b.isStateAffected(53)) && if (b.isStateAffected(57)) {

    #No Magic Attack/Magic Defense/Attack Debuff

    value *= 2.0;

    } elseif (b.isStateAffected(27)) && if (b.isStateAffected(53)) {

    #No Magic Attack/Magic Defense/Defense Debuff

    value *= 2.0;

    } elseif (b.isStateAffected(57)) && if (b.isStateAffected(40)) {

    #No Attack/Magic Attack/Agility Debuff

    value *= 2.0;

    } elseif (b.isStateAffected(30)) && if (b.isStateAffected(40)) {

    #No Attack/Defense/Agility Debuff

    value *= 2.0;

    } elseif (b.isStateAffected(30)) && if (b.isStateAffected(53)) {

    #No Attack/Defense/Magic Defense Debuff

    value *= 2.0;

    } elseif (b.isStateAffected(57)) && if (b.isStateAffected(30)) {

    #No Attack/Magic Defense/Agility Debuff

    value *= 2.0;

    } elseif (b.isStateAffected(27)) || if (b.isStateAffected(57)) || if (b.isStateAffected(30)) || if (b.isStateAffected(40)) || if (b.isStateAffected(53)) {

    #Only One Debuff

    value *= 1.5;

    }

    </damage formula>

    Any help would be appreciated. Thanks.
     
  12. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    2 things first
    1: does "value *= 3.5" work i remember getting some invalid left side errors or something when i used it at other places in the engine i can be wrong though.
    2. The way you have set up the formula is needlessly large and a pain to make some changes to i will put something down for you that's a bit more compact i may even solve your issue. Will edit this post when i finish it.

    Edit: And i believe you are using && if the wrong way.
    Edit 2 the formula. I haven't tested it yet though.

    Code:
    <damage formula>
    debufstates=[27,30,40,50,53];
    multi = 1;
    if(target.states().length != 0)
        {
        for(i=0; i < target.states().length;i++)
            {for (o=0;o < debufstates.length; o++)
            {if(target.states()[i].id==debufstates[o] )
            {multi + .5;}
            }
            }
        }
    value = (a.mat * 2 - b.mdf)* multi;  
    </damage formula>
     
    Last edited: Jan 2, 2019
    Arin likes this.
  13. Arin

    Arin Tonight...we dine...in-oh a piece of candy! Veteran

    Messages:
    1,225
    Likes Received:
    189
    Location:
    Why is this important?
    First Language:
    Fraglspock
    Primarily Uses:
    RMMV
    @jetboost Thank you so much for the code! I was able to get it working!
     
    jetboost likes this.
  14. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Good to hear!:thumbsup-left:
     
  15. SavageWolf09

    SavageWolf09 Villager Member

    Messages:
    18
    Likes Received:
    4
    Location:
    United States
    First Language:
    English
    Hi I don't know if this is possible. But can anyone help me with a formula where lets say actor one has an atk of 12 he will do anywhere from 1 to 12 points of damage and then do the same with the opponts def and have the atk amount subtract from the def amount
     
    Last edited: Jan 9, 2019
  16. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    That's possible. But I don't know what the engine would do with negative values to be honest.
    Code:
    <damage formula>
    value = Math.randomInt(a.atk)+1 - Math.randomInt(b.def)+1;
    
    </damage formula>
    So you could add this to the formule
    Code:
    if(value < 0){value=0;} \\Or  value = 1 depending on your preference. Oh wait nevermind this negative values will become 0 i believe so this isn't needed
    Yanfly damage core plugin required*
    It ought to work.
     
  17. SavageWolf09

    SavageWolf09 Villager Member

    Messages:
    18
    Likes Received:
    4
    Location:
    United States
    First Language:
    English
    I have a D&D type of formula that i want to use in a game I'm making and it's very close to what i need. However there's one part I'm having trounble with. if (b.def <= (Math.randomInt(20) + 1 + a.atk)) Math.randomInt(4) + 1 + a.atk; else 0 is the formula.

    if (b.def <= (Math.randomInt(20) + 1 + a.atk)) is what determines if you hit or miss.

    Math.randomInt(4) + 1 + a.atk is what determines the damage.

    My question is for the damage part instead of using the players over all atk. Is it possible to only use the weapons atk stat
     
  18. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Ok, that is possible
    If you would like to write your code in the way i did, there is an insert button next to the floppy disk symbol with which you can choose to do so.

    Code:
    <damage formula>
    \\Because we wish to select data from an actor that isn't accesable like a.atk for as far as i know, we will \\have to select our correct actor like this and as enemies don't have equips.
    if( a.isActor() ){
    x = a.actorId() ;
    if (b.def <= (Math.randomInt(20) + 1 + a.atk)) {
    value= Math.randomInt(4) + 1 +$gameActors.actor(x).equips()[0].params[2];
    }else{ value = 0;}
    }
    This should do it.
     
  19. SavageWolf09

    SavageWolf09 Villager Member

    Messages:
    18
    Likes Received:
    4
    Location:
    United States
    First Language:
    English
    Hi wanted to thank everyone for their help with my D&D style Damage Formula and decided to upload it here.

    if (b.def <= (Math.randomInt(20) + 1 + a.atk + Math.floor(v[1]-10)/2)) Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0

    if (b.def <= (Math.randomInt(20)+ 1 + a.atk + Math.floor(v[1]-10)/2)) This is the attack roll that decides if you hit or miss


    if (b.def <= (Math.randomInt(20) + 1 is the dice roll that results in a number from 1 to 20. Then you add your overall atk as the Proficiency bonus. Then Math.floor(v[1]-10)/2)) as the part that determines your ability score. With this part you will have to create a variable to act as the six basic skill.

    I recommend using yanfly's actor variables just to keep track of them in game.

    Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0 is the damage roll

    Math.randomInt(4) + 1 is the basic dice roll. Just repe lace the 4 with the type of dice roll you want. 4 for a d4 dice 6 for d6 etc.

    Math.floor(v[1]-10)/2 this is you ability score again.

    else 0 just reduces all damage to 0 if your attack roll doesn't beat out your opponents. As I couldn't figure out how to do a miss.
     
    jetboost likes this.
  20. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    You are welcome, solving puzzles is fun and i get to see a new perspective on skills.
    Did you manage to get the skill working? The one with which you wanted to select the weapons attack?
    Kinda just put it together and haven't tested it.
     

Share This Page