RMMV Damage Formula - ideas and help

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

  1. Oddball

    Oddball Veteran Veteran

    Messages:
    1,545
    Likes Received:
    390
    First Language:
    English
    Primarily Uses:
    N/A
    So you can add a state, while simutaniously removing states all to the actor in the same formula? Excellent!

    Certain types of state effects just opened up. Like states that only go away when the actor uses an attacking skill while those attacking skills add states to the user and enemies through the effect part. While not going away when they use a support skill
     
  2. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    184
    Likes Received:
    33
    Location:
    Austria
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Is there a way to save the Evasion Rate of an actor in a variable?

    I tried $gameActors.actor(1).xparam(1)
    and actor.eva

    but neither of them worked...
     
  3. Silva

    Silva Scoobityboo Veteran

    Messages:
    289
    Likes Received:
    139
    First Language:
    English
    Primarily Uses:
    RMMV
    If you're trying to set a game variable using the damage formula you'll need to use something like this

    Code:
    $gameVariables.setValue(id, $gameActors.actor(1).eva)
    Where id is the variable's ID.
     
    jjleroy likes this.
  4. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    184
    Likes Received:
    33
    Location:
    Austria
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Thank you very much!

    So I would like to create a state which halfs the hit rate of all incoming attacks.

    I was wondering if I could just half the Hit Rate formula (for ALL actors&enemies) for a brief amount of time whenever the actor is attacked.
    Then after damage is done, reset Hit Rate formula to normal one.

    Is it ok to do it this way, or do you see some kind of error in my solution?!
     
  5. Silva

    Silva Scoobityboo Veteran

    Messages:
    289
    Likes Received:
    139
    First Language:
    English
    Primarily Uses:
    RMMV
    The logic seems fine but I think the execution would be difficult without using a plugin. Do you have something that will allow you to modify an actions hitrate? I suspect you might be able to do this with Yanfly's buffs states core.

    If not you could try saving the below as a plugin and adding it to your plugin manager. On the line that starts "var div = ", replace "stateId" with the state's id.

    Code:
        jjleroy_Game_Action_itemHit = Game_Action.prototype.itemHit;
        Game_Action.prototype.itemHit = function(target) {
            var div = target.isStateAffected(stateId) ? 2 : 1;
            return jjleroy_Game_Action_itemHit.call(this, target) / div;
        };
     
    jjleroy likes this.
  6. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    184
    Likes Received:
    33
    Location:
    Austria
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Thank you @Silva !

    Is there a way to define in the damage formula whether or not a target
    result().isHit() ?
     
  7. Silva

    Silva Scoobityboo Veteran

    Messages:
    289
    Likes Received:
    139
    First Language:
    English
    Primarily Uses:
    RMMV
    Not by default. The damage formula will only evaluate if target.result().isHit() returns true, at which point it's too late for any changes to matter.

    If you're looking to make changes to the way hits are calculated I would definitely recommend using a plugin so that you can change the result before the damage formula is reached.
     
    jjleroy likes this.
  8. TMS

    TMS Guy with Mask Veteran

    Messages:
    298
    Likes Received:
    55
    Location:
    Ohio
    First Language:
    English
    Primarily Uses:
    N/A
    So I'm thinking for the first time about damage formulas I might want to use. I've noticed people in this thread talking about Math.randomInt(x). Is there a place in MV's Help documentation (or anywhere else) that describes stuff like that?

    Edit:
    I have a few other questions.

    The first one I'm not really sure how to word, but I'm thinking of having attacks in my game that hit multiple times. Not in the sense that the attack repeats itself; rather it calculates several damage values according to a given formula and then adds them together, whereas usually (with an attack that only hits once) only one damage value is calculated for the total. Would a multi-hit attack like what I'm describing just be a case of using a lot of parentheses to make a really long formula?

    A somewhat related question is whether there's a way to get a random number that's between two numbers other than 0. What do I do if, say, I want an attack to hit between 2 and 4 times (inclusive)?
     
    Last edited: Oct 13, 2019
  9. D.L. Yomegami

    D.L. Yomegami Sanely Insane Veteran

    Messages:
    158
    Likes Received:
    202
    Location:
    Somewhere
    First Language:
    English
    Primarily Uses:
    RMMV
    For your first question, this ought to be of some use.

    For your third question: it's mostly a simple matter of taking your desired minimum value and adding Math.randomInt() to it. A rough exact formula would look something like this:

    Min + Math.randomInt((Max - min) + 1)

    Where Min is your desired minimum value and Max is your desired maximum value. Some examples:
    Min = 2, Max = 4: 2 + Math.randomInt(3)
    Min = 3, Max = 7: 3 + Math.randomInt(5)
    Min = 10, Max = 13: 10 + Math.randomInt(4)

    I'm not entirely sure what you're asking for your second question, but to me it sounds like you want something like Formula1 + Formula2 = Final Damage Value that produces 1 Damage Popup. In that case, it really is as simple as putting the two formulas in parentheses and then adding them together. If that's not what you're looking for, then I'm not sure how to answer that, unfortunately.

    Now for my own question.

    I'm trying to design a damage formula with a sort of "soft cap" on both maximum and minimum damage values. Basically, whenever the damage approaches some kind of maximum value (like 9999 or half the target's maximum HP) or minimum value (like 10 or a third of the attacker's offensive parameter), the damage kind of levels out. For example, if the "soft cap" is 9999 while the final damage would otherwise be twice that, it'd instead be something like 10,100 or even still below 9999. Likewise for minimum damage: if the "soft cap" on minimum damage is a third of the attacker's offensive parameter, I don't want any damage to be drastically below that. All this while the damage in between the two "soft caps" is more or less normal for whatever formula I decide to use (I normally use something like a.atk * (256 - b.def) / 256 or a.atk * 100 / (100 + b.def)).

    I'm completely at a loss at what kind of math I'd need to do to achieve this effect. It feels like the exact curves I want look similar to a square root formula (for max "soft cap") or exponent formula (for min "soft cap"), yet whenever I play around with such formulas in a graphing calculator I simply cannot get the curves to look the way I want them to. Would anyone have a better idea of what formula I would want for something like this?

    I'm aware I could achieve something similar via the Math.max/Math.min or clamp functions, but that's not quite what I want. Those are a hard stop that cause the damage to turn into a flat line at the maximum and minimum values (variance notwithstanding); I'm looking for something that'd be more of a curve at the "caps."
     
    TMS likes this.
  10. Engr. Adiktuzmiko

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

    Messages:
    14,548
    Likes Received:
    2,901
    Location:
    Philippines
    First Language:
    Tagalog
    @Yomegami - You'd either want to use maybe if statements or the Min/Max method. If those are pretty "hard" caps for you, you can always add a bit of random integers to vary the resulting values, or add a percentage of the actual over damage.

    If you want it for all skills though, you might want to actually write a plugin that handles it just so you wont need to do it for every skill in your game.
     

Share This Page