RMMV Damage Formula - ideas and help

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

  1. jetboost

    jetboost Veteran Veteran

    Messages:
    81
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    If you are using Yanfly DamageCore you can just reach the Id of your skill with
    Code:
    item.id
    And this
    will give you 2 errors 1: the V in value is capitalized and when written correctly it would say invalid left hand side something.

    What you thus want is this
    Code:
    $gameVariables.setValue(5,item.id);
    Edit: A quick way to test my example is when you the required plugins installed is selecting your skill and make it do damage without variance and put in this
    Code:
    <damage formula>
    value = item.id;
    </damage formula>
    You will now deal damage equal to your skill id.
     
    Last edited: Apr 7, 2019
  2. LGardner

    LGardner Veteran Veteran

    Messages:
    36
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi. Many thanks for the reply. I had Yanfly core installed, but not Yanfly Damage Core. Have since installed it. Am still not having any joy I am afraid; I tried the code you suggested in both the damage box:
    [​IMG]

    and the common event itself:

    [​IMG]

    Neither worked. However, in response to your edit, I can confirm that item.id does work in terms of calculating damage -
    value = item.id;
    returned a hit of approx the skill id each time. But the formula for setting variables [by the way, I wrote last time from memory, but I did use the same capitalisation as standard when actually trying it] didn't work for me. :/

    Edit: FOUND THE PROBLEM. Skill's scope was set to none, which worked fine as long as all I needed was the effects, but meant that hp damage formula wasn't taking any effect when I used it. Now I set it to 1 ally, it works as intended. Sorry all, and thanks for the help.
     
    Last edited: Apr 7, 2019
  3. jetboost

    jetboost Veteran Veteran

    Messages:
    81
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Sorry to you as well the moment you were using scripts in combination with damage formulas I asumed you were allready working with Yanfly plugins and knew what they were capable of.

    If you read the description that comes with the plugin or the descriptions of the plugins from Yanfly website and/or his videos you can find out what they are all capable of.

    You can just put this in the skills notebox
    Code:
    <damage formula>
    $gameVariables.setValue(5,item.id);
    </damage formula>
    and insert your script in between.
    So if you put the first example of mine in your skill's notebox and remove the script part of your common event it ought to work.
    "value" is a variable(used within the damage core plugin) that stores the result of your formula you wrote down, thus by writing "value =50;" makes the skill do 50 damage.

    The reason the script in the comon event isn't working is because item.id is (I believe an temporary and/or local) Object that is created by the plugin at skill selection.
    When "<damage formula></damage formula>" is found, by a function of the plugin, in the notebox of your selected skill and it will then read what is written.
    It's also in that point in time that you can thus access the data of the object "item".

    However this is thus far my understanding of Yanfly's plugins I have not really looked into the code of the plugin itself so i might not be entirly correct.
    Long story short use item.id only within Yanfly's plugins.

    In case you don't understand some of the things I was talking about, go to w3schools and to the javascript section IMO it's a good website that teaches you the basics of code.
    You will however have to understand it yourself as in how to make use of it.

    And in case you are going to experiment with some lets say more advanced scripts do note the script box can only hold about ten lines and if you would lets say press enter to have the code on line 10 move to line eleven .... well the result is an empty line 10 it has happend to me sadly.
    Thus I recommend when possible to code/test your larger scripts in the debug console and when finished save your script somewhere else and jam your code together on fewer lines bofore cramming it in your script box.

    I really have been typing way to much late at night......
     
    Last edited: Apr 7, 2019
  4. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,456
    Likes Received:
    2,844
    Location:
    Philippines
    First Language:
    Tagalog
    Yup that is right, to explain this:

    The damage evaluation function is actually called by the Target object (not the user). So since the scope is none, there is no Target object, meaning there is also no object that will call the damage evaluation function, so its never evaluated.

    @jetboost - no need for Yanfly's plugin and a custom <damage formula> notetag for the set variable part because the damage formula can already run JS codes by default. So basically, he can just insert the $gameVariables.setValue() call inside the skill's actual damage formula box.

    Also item.id is accessible in the damage formula box even without any plugin because item is actually passed as a parameter of the function that evals the damage formula box. Plus since you're doing it on the formula box, its better to just write the skill id number itself.. and ofc, if you're using a common event, item.id will not exist.
     
    Last edited: Apr 8, 2019
    LGardner and jetboost like this.
  5. jetboost

    jetboost Veteran Veteran

    Messages:
    81
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Thank you for the correction I didn't know that.


    (I think)I understand it. By doing so the program has less work to do.

    However in my case I use it for my "skill mastery/lvl" system I have set up for my skills and I will thus need the skill id quite a bit more thus I store the value of item.id in a variable and use that.
    Quite sad that a few weeks later after having created it Yanfly released a plugin that does allmost the same:|.

    Because of the way I set up various things for my skills and the various systems that I have set up that can influence the skills I will need to use quite a bit of code thus I actually allmost never use the damage formule box cause it just isn't convenient for writing a large amount of code inside of it, the notebox even has a scroll bar :D.
     
    Engr. Adiktuzmiko likes this.
  6. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,456
    Likes Received:
    2,844
    Location:
    Philippines
    First Language:
    Tagalog
    Yeah, different cases different uses. Indeed for a JS system that will be used by different skills, using item.id (if possible) is better so that the skill wont need to supply its id to the system via other methods (on the other poster's case, via setting a game variable's value to the id). As you said and explained though, if he uses item.id in the common event, it will not work.

    Dont be sad, you learned something and now you have a system that you made on your own and didnt need to rely on somebody elses work. Be happy :)
     
    Last edited: Apr 8, 2019
    jetboost likes this.
  7. Manjini

    Manjini Dummy Member

    Messages:
    24
    Likes Received:
    19
    First Language:
    German
    Primarily Uses:
    RMMV
    Hello! Could somebody help me to figure out a nice damage formula similar to Ragnarok Online just with higher damage outputs and obviously no agility, dextery etc.? Let's say you are level 10 and the enemy is level 1 and you have like 20 defense, the enemy still could hit you for maybe 1 or 2 damage but not 0 and not 100. I want a high tolerance in attack * defense ratio. So that killing a monster one level below would not be one hit (Unless you have special gear which gives high amount of attack or something) but we are talking about raw values here. Like no extra armor or weapons added. I want defense to be meaningful but also high damage numbers. My level cap is 60 at the moment to keep the balancing a little on the easier side. I managed to do fun battles in the higher levels, but my issue really is the lower end. For example I kill level 1 monsters being level 1 and then level up, I would one shot the level 1 enemies by just being one level higher.
    (I am using yanflys plugins: baseparamcontrol, classbaseparam, enemy levels, damage core and armor scaling if that helps).
     
  8. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,456
    Likes Received:
    2,844
    Location:
    Philippines
    First Language:
    Tagalog
    If you want defense to work more, you just need to set your damage formula to use defense more...

    Like, the original DF is

    a.atk*4 - b.def*2

    So you can make it like

    a.atk*4 - b.def*4

    or you can make def work as % reduction like

    (a.atk*4)*(1.00-def/100.0)

    This will make it such that each point of defense gives 1% damage reduction
     
  9. jetboost

    jetboost Veteran Veteran

    Messages:
    81
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    I use the same plugins except armor scaling.
    I had the same issue going from lvl 1 to lvl 2 and ballancing to the point I have made an gigantic spreadsheet that calculates the damage done and recieved so I could keep an eye on the vallues and test skills faster at various levels against various levels.
    (Can't really share it with you though it is to personalized for my project so its useless to you.)
    I suggest you create something similar based on your situation if it's really neccesary.

    Anyway the way I solved this issue is by making my game start at lvl 2.
    Create a tutorial fight balance it to lvl 1 and have it give you enough EXP to lvl up.
    This is how I solved my issue.
     
    Manjini likes this.
  10. Manjini

    Manjini Dummy Member

    Messages:
    24
    Likes Received:
    19
    First Language:
    German
    Primarily Uses:
    RMMV
    I guess I have to use excel or google spreadsheet as well. Since altering the atk + def formula with default values is not accurate in addition with the enemy levels (How much atk, def etc. the enemy itself will gain per level in my game).
    I like your workaround jetboost, but I cannot admit defeat just yet! I want it sorted out with a nice smooth curve!
    Anyways thanks for the replies.
     
  11. SANTERSAKH

    SANTERSAKH Villager Member

    Messages:
    14
    Likes Received:
    1
    First Language:
    Russian
    Primarily Uses:
    RMMV
    Hello everyone!
    How to set formula like this: when attacker's final ATK is less than target's DEF, minimum damage will not be 0 but be random number between 1 and 1/20 of attacker's ATK?
    Or just tell how to remove 0 damage (at least 1)
     
  12. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,456
    Likes Received:
    2,844
    Location:
    Philippines
    First Language:
    Tagalog
    You can probably use a plugin to avoid 0 damage after all calculations are done...

    Or in your damage formula

    Math.max(1,actual formula)

    This way, if the damage will be less than 1, it will be 1 instead.

    So like

    Math.max(1,atk*4-b.def*2)

    Take note though that doing this in the damage formula box means that it can still be changed via the other factors that are incorporated after the formula calculation, like element rates and pdr/mdr. But as long as you dont have a 0% element rate or pdr/mdr then you wont get 0 damage after this.
     
    SANTERSAKH likes this.
  13. SANTERSAKH

    SANTERSAKH Villager Member

    Messages:
    14
    Likes Received:
    1
    First Language:
    Russian
    Primarily Uses:
    RMMV
    Thanks! That is what I need!
    Back to my request, will this work fine?

    Math.max(1,Math.randomInt(a.atk/20),a.atk * 3 - b.def * 2)
     
  14. Silva

    Silva Scoobityboo Veteran

    Messages:
    268
    Likes Received:
    126
    First Language:
    English
    Primarily Uses:
    RMMV
    This will work. It will make the damage the highest of all the values separated by a comma. I noted in your previous post though that you wanted to use the random number between 1 and atk/20 only when a.atk < b.def (or maybe a.atk * 3 < b.def * 2, your word choice confused me a little). To do this you can use the ternary operator "?" like so:

    Code:
    a.atk < b.def ? Math.randomInt(a.atk/20) : a.atk * 3 - b.def * 2
    You can combine this with Math.max as well to make sure the formula's output is always 1 like so:

    Code:
    Math.max(1, a.atk < b.def ? Math.randomInt(a.atk/20) : a.atk * 3 - b.def * 2)
     
  15. SANTERSAKH

    SANTERSAKH Villager Member

    Messages:
    14
    Likes Received:
    1
    First Language:
    Russian
    Primarily Uses:
    RMMV
    This is an example. I will fit this formula for not-overpowered minimum damage.
     
  16. Catog

    Catog Professional Internal Screamer Veteran

    Messages:
    50
    Likes Received:
    12
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Okay, this is sending me stir-crazy, I swear.

    I have a skill called Shatter which, if the target is already inflicted with Petrify, should inflict Death. Even if that isn't the case, I want it to inflict damage. But no matter what, I can't seem to get this to work.

    I've tried two main formulas:
    and
    The latter is if I can't get it to work with damage, and therefore it'll either inflict Death or damage.
    But no matter how much I try, I can't get it to work.

    I have Yanfly's Buff/States Core, so if someone has a solution there, even, that can work.
     
  17. jetboost

    jetboost Veteran Veteran

    Messages:
    81
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Have you set your skill up to do (hp)damage?
     
  18. Catog

    Catog Professional Internal Screamer Veteran

    Messages:
    50
    Likes Received:
    12
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Yeah, definitely been set for HP Damage through the whole process.
     
  19. jetboost

    jetboost Veteran Veteran

    Messages:
    81
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Was reading it from my mobile just before now that I take a better look at your question it seems I missunderstood you.
    I think you want this
    Code:
    if (b.isStateAffected(35)){ b.addState(1);} a.mat * 4 - b.def * 1
    You had an "!" before b and you missed these "{ }" in your first example
     
  20. Catog

    Catog Professional Internal Screamer Veteran

    Messages:
    50
    Likes Received:
    12
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Hmm... I gave it a go, and while it did do the damage, it didn't add the Death state :/
     

Share This Page