RMMV Damage Formula - ideas and help

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

  1. Mellye

    Mellye Veteran Veteran

    Messages:
    347
    Likes Received:
    277
    First Language:
    Portuguese
    Yes.

    The formula field goes through an eval(), and any number that it results in at the end is used on for the Damage (or heal or etc) action.

    Incidetanlly, you can also even include statements before the formula itself, and they will be run. But this has side-effects as I described in a post above.
     
    #61
  2. Liak

    Liak Veteran Veteran

    Messages:
    1,789
    Likes Received:
    269
    Location:
    Germany
    First Language:
    German
    In a conditional formula, is it possible to make a skill have no effect? So something like this:

    b.hp > 100 ? 25 : ???What do I put where the ??? are if I want no effect at all (so not only 0 damage, no effect at all)? "return false"?
     
    #62
  3. Chaos Avian

    Chaos Avian Abyssal Wing Restaff

    Messages:
    3,231
    Likes Received:
    780
    Location:
    Currently fighting demon hoards for fun.
    First Language:
    English
    What would the damage formula be for a skill that does more damage if the enemy is afflicted with state x?
     
    #63
  4. Liak

    Liak Veteran Veteran

    Messages:
    1,789
    Likes Received:
    269
    Location:
    Germany
    First Language:
    German
    I think that woud be:

    b.isStateAffected(x) ? [high damage formula] : [lower damage formula]
     
    #64
    Chaos Avian likes this.
  5. Mellye

    Mellye Veteran Veteran

    Messages:
    347
    Likes Received:
    277
    First Language:
    Portuguese
    The function that evals the Formula for damage defaults to 0 if it can't get a number at all from the formula. So I don't think there's anything you could do in that field to make it fail completely like that.

    Code:
    Game_Action.prototype.evalDamageFormula = function(target) {    try {        var item = this.item();        var a = this.subject();        var b = target;        var v = $gameVariables._data;        var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);        return Math.max(eval(item.damage.formula), 0) * sign;    } catch (e) {        return 0;    }};
     
    Last edited by a moderator: Oct 28, 2015
    #65
  6. Nuhada

    Nuhada Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    French
    Hello, if the command to gain mp if gainMp(x), what is the command to lose mp?

    I tried loseMp(x), but that doesn't work and i don't know where all the commands like this are wrote :/
     
    #66
  7. Chaos Avian

    Chaos Avian Abyssal Wing Restaff

    Messages:
    3,231
    Likes Received:
    780
    Location:
    Currently fighting demon hoards for fun.
    First Language:
    English
    That works wonderfully, thanks!
     
    #67
  8. Tobbx

    Tobbx Veteran Veteran

    Messages:
    45
    Likes Received:
    25
    Location:
    Sweden
    First Language:
    Swedish
    Thx, think i get it now. :)

    A list of different methods and such would be awesome to have. I want to use more advanced if else statements and such to. And maybe use game variables like Victory Count and Escape count.
     
    Last edited by a moderator: Oct 28, 2015
    #68
  9. Cel

    Cel Veteran Veteran

    Messages:
    88
    Likes Received:
    56
    First Language:
    Swedish
    I've run into a very weird problem with b.addState... Whenever I use this inside a formula to add a state to an enemy the enemy just... stops. It won't act, it won't take damage from the state itself. It just sits there letting me hit it, pretending my state's a stun effect. For clarity's sake, here's the formula I'm using:

    b.isStateAffected(34) ? b.addState(34) : b.isStateAffected(33) ? b.addState(34) : b.isStateAffected(32) ? b.addState(33) : b.isStateAffected(31) ? b.addState(32) : b.addState(31)

    (Basically what I want it to do is "upgrade" a poison state step by step, which it does just fine as every new step makes the target immune to the steps before, effectively removing lesser states. For some reason it also removes the target's will to act...
     

    Anyone got any idea as to why?

    EDIT: So with a super minor edit:

    (b.isStateAffected(34) ? b.addState(34) : b.isStateAffected(33) ? b.addState(34) : b.isStateAffected(32) ? b.addState(33) : b.isStateAffected(31) ? b.addState(32) : b.addState(31)), 1

    The skill no longer freezes the enemy. It seems like having no damage in the damage formula while making it apply states doesn't play well with enemies in general for some reason.
     
    Last edited by a moderator: Oct 28, 2015
    #69
  10. SgtBusCake

    SgtBusCake Villager Member

    Messages:
    15
    Likes Received:
    7
    Location:
    East Coast
    First Language:
    English
    Hi Nuhada,

    I think what you may be looking for is a negative value for x.

    e.g. a.gainMp(-10) will make the actor lose 10 MP if they do not miss.

    If you are looking for dealing MP damage, you may be able to use the Damage, Type: combo box in the top right and change HP Damage to MP Damage.
     
    #70
  11. SgtBusCake

    SgtBusCake Villager Member

    Messages:
    15
    Likes Received:
    7
    Location:
    East Coast
    First Language:
    English
    Hello Cel,

    I've not looked into the code behind the scenes on this, but I found that I was able to get away with inflicting 0 damage and still apply the ailments by adjusting the end of the formula. The 0 still appears and if it is not present, the poison will land, but will not actually deal damage at the end of each turn.

    (b.isStateAffected(34) ? b.addState(34) : b.isStateAffected(33) ? b.addState(34) : b.isStateAffected(32) ? b.addState(33) : b.isStateAffected(31) ? b.addState(32) : b.addState(31)); 0At first, I was a bit confused with the poisons stacking when yours were not. Then I figured you may have added a Trait in the State Resist of the lower tier of poison and that seemed to do the trick for me.
     
    #71
  12. zidaneggg

    zidaneggg Warper Member

    Messages:
    4
    Likes Received:
    2
    First Language:
    Spanish
    Is there a way to increase de critical strike chance by some % ? 

    For example make a skill ta has a 30 % extra chance of doing critical.
     
    #72
  13. Nuhada

    Nuhada Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    French
    Thank you, i don't know why i didn't think of that x)

    I don't deal only mp damages, thats why i needed this. The spell attack the enemy, drain his mp, and if the mp of the enemy is 0 after the attack, he become stuned.

    r=(20+(a.atk * 4 - b.def * 2));b.gainMp(-(Math.round(r/17)));a.gainMp(Math.round(r/17));if(b.mp==0){b.addState(8)};rIt works fine like this now :)
     
    #73
    SgtBusCake likes this.
  14. SgtBusCake

    SgtBusCake Villager Member

    Messages:
    15
    Likes Received:
    7
    Location:
    East Coast
    First Language:
    English
    Still learning at how all of this works and I'm certain there is a better way than what I threw together.

    In the meantime, I think this may simulate the effect of swapping HP and MP with the formula you provided.

    Try:

    c = b.hp; d = b.mp; b.gainHp(-b.hp+1); b.gainMp(-b.mp); b.gainMp(Math.round(c * 0.5 - b.level)); b.gainHp(Math.round(d * 1.33 + b.level)); 0If I'm not mistaken, if a caster continually casts this HP Conversion spell on a target, the target will gradually lose both HP and MP, due to the MP being halved with each iteration.

    There will be an odd "Harold has recovered X MP" message. While it looks like the message could be made blank in the Database, it will display a blank line. Fiddling around in Notepad, it looks like there's a file in your game directory's "js" folder called "rpg_windows.js" and in it, a line that says "Window_BattleLog.prototype.displayMpDamage"  If you add two forward slashes before the "this.push" text, it should make the message go away.

    // this.push('addText', this.makeMpDamageText(target));This will also impact messages from MP recovery items. I suspect there's a much easier way to make all of this happen - I just haven't learned it yet.
     
    Last edited by a moderator: Oct 28, 2015
    #74
    Milennin likes this.
  15. Jandas

    Jandas Villager Member

    Messages:
    7
    Likes Received:
    0
    Location:
    Various
    First Language:
    English
    Thanks for this, I was using the clunkier "(Math.random()*X)".
     
    #75
  16. LunarWingCloud

    LunarWingCloud Villager Member

    Messages:
    5
    Likes Received:
    1
    First Language:
    English
    Is there a way to change the multiplier for Critical Hits? I managed to go in and change that in VX Ace because I want it to be a 2x multiplier rather than 3x. I don't see any plugins that can do it either. 
     
    #76
  17. Calicer

    Calicer Composer Member

    Messages:
    7
    Likes Received:
    3
    Location:
    Australia
    First Language:
    English
    I have 2 questions:

    1. I was wondering is there a way to add debuffs or buffs in the formula box now

    2. Can I have an if/else statement checking the value of a random integer

    Any help is appreciated, thanks :)
     
    #77
  18. Grimoire LD

    Grimoire LD Veteran Veteran

    Messages:
    39
    Likes Received:
    8
    First Language:
    English
    Here's an interesting note. When you apply actual formulas that search for stats to On Field items (e.g. Healing Potions) the system seems to default look at the Leader's stats to reference if there is an "a.stat" used which is pretty interesting. It implies that the item is being administered by the leader, which is kind of a neat character trait and shows a real use for the leader. If you use "b.stat" it will look at the character being effected. A cool little system though, I'll have to manipulate this to make some not so bland healing items (and to use some lesser used stats)
     
    #78
  19. Shaz

    Shaz Veteran Veteran

    Messages:
    37,712
    Likes Received:
    11,421
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    multiplier for critical hits is not in the damage formula.  Please post a new thread with your question (in Javascript/Plugin Support).  Or do a search, as someone else has already asked this question and received an answer.

    a is the user of the item and b is the target of the item.  As there is no user/target when you're not in battle, it must default to the leader.
     
    Last edited by a moderator: Oct 28, 2015
    #79
  20. Korokage

    Korokage Veteran Veteran

    Messages:
    56
    Likes Received:
    9
    First Language:
    English
    Just quoting this since I don't think that first question got answered and I'm curious about the answer as well.
     
    #80
    Liak likes this.

Share This Page