RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 44 of 77 View original ↗
  1. Blue Symphony said:
    @Pharonix
    Maybe you figured it out by now; but this is my approach to that skill, in case anyone needs something similar.
    Set up for a "Reduce your HP to 1 and convert the amount of HP sacrificed into damage" skill.
    Damage formula
    Code:
    x = a.hp-1; a.setHp(1); x;

    @Hungry Moogle
    This one is kinda tricky. You'll need Yanfly's Skill Core, and Yanfly's Target Core plugins.
    Set up for a "Halve your HP to heal all allies equal to the amount of HP sacrificed" skill.
    Damage formula
    Code:
    a.hp
    Notebox
    Code:
    <Target: All Allies But User>
    <Custom HP Cost>
    cost = Math.ceil(a.hp / 2)
    </Custom HP Cost>



    I decided to use yanflys lunatic mode to set a variable to set up cost = 100% -1.
    Then set that to a variable I use in the damage formula.
    Surprising number of yanflys script work.
  2. Hi guys,
    I'd like to have different damage formula depending on the weapon the actor is using. So if he uses weapon number 6, 7 or 8 he deals 1000 damage. If he uses any other weapon he deals: a.atk * (100.0/(100.0 + b.def))

    [6,7,8].some(function(e){return a.hasWeapon($dataWeapons[e])}) ? 1000 : a.atk * (100.0/(100.0 + b.def))

    The formula works for the actor, but the enemy always deals 0 damage. But as they dont have a weapon number 6,7 or 8 they should deal following the formula: a.atk * (100.0/(100.0 + b.def))

    What could be the problem? Thanks for your help!
  3. @Hungry Moogle
    I told you it was a tricky one. Yes, there is some problems with this setup because the cost is applied before the skill can do it's calculations.
    We need to rework it. And this time it won't look that pretty.

    You need to set up the Damage type of the skill to none. And the animation to none.
    Then paste this on the notebox:
    Code:
    <Before Eval>
    if (this._recoveredMp === undefined) {
      this._recoveredMp = Math.ceil(user.hp * 0.25);
    }
    </Before Eval>
    
    <After Eval>
    user.setHp(user.hp - this._recoveredMp);
    target.startAnimation(x);
    target.gainMp(this._recoveredMp);
    target.startDamagePopup();
    target.clearResult();
    </After Eval>
    You'll need to replace the "x" with the animation you want to play on the healed ally.
    This is also done with Yanfly's skill core plugin. Hopefully you can tweak this formula for the rest of your covertion skills.:ehappy:

    @freebooter
    That formula won't work for enemies because you're asking if the enemy has a weapon equiped, wich they can't, so it immediately triggers an exception and turns the damage to 0. You need to ask if the user is an actor on this formula.

    I rewrote it, using Yanfly's damage core plugin. So it maaaay be more easy to understand.
    Leave the formula space blank, and write this on the notebox.
    Code:
    <Damage Formula>
    value = a.atk * (100.0/(100.0 + b.def));
    if(a.isActor() && [6,7,8].some(function(e){return a.hasWeapon($dataWeapons[e])})){
       value  = 1000;
    }
    </Damage Formula>
    Value is the total damage the skill will deal. :rhappy:
  4. Thanks for that!
    If Yanfly's damage core plugin is compatible with LeTBS, which I use, all is fine :) I have to check ...

    One question concerning the formula: If I want to make the damage formula depending on the weapon-TYPE (not a special weapon), would I write "a.hasWeaponType" instead of "a.hasWeapon"?
  5. Blue Symphony said:
    @Hungry Moogle
    I told you it was a tricky one. Yes, there is some problems with this setup because the cost is applied before the skill can do it's calculations.
    We need to rework it. And this time it won't look that pretty.

    You need to set up the Damage type of the skill to none. And the animation to none.
    Then paste this on the notebox:
    Code:
    <Before Eval>
    if (this._recoveredMp === undefined) {
    this._recoveredMp = Math.ceil(user.hp * 0.25);
    }
    </Before Eval>
    
    <After Eval>
    user.setHp(user.hp - this._recoveredMp);
    target.startAnimation(x);
    target.gainMp(this._recoveredMp);
    target.startDamagePopup();
    target.clearResult();
    </After Eval>
    You'll need to replace the "x" with the animation you want to play on the healed ally.
    This is also done with Yanfly's skill core plugin. Hopefully you can tweak this formula for the rest of your covertion skills.
    Thanks again for the help, the skill now seems to be working in the manner that I intended it to.

    I was also wondering about the possibility of making a skill that deals greater damage, the lower the user's HP is (For example: If the user is missing 75% of their HP then the skill's power will increase by 75%.), similar to how the Frog Squash tech from Chrono Trigger worked.
  6. Blue Symphony said:
    @Hungry Moogle
    I told you it was a tricky one. Yes, there is some problems with this setup because the cost is applied before the skill can do it's calculations.
    We need to rework it. And this time it won't look that pretty.

    You need to set up the Damage type of the skill to none. And the animation to none.
    Then paste this on the notebox:
    Code:
    <Before Eval>
    if (this._recoveredMp === undefined) {
      this._recoveredMp = Math.ceil(user.hp * 0.25);
    }
    </Before Eval>
    
    <After Eval>
    user.setHp(user.hp - this._recoveredMp);
    target.startAnimation(x);
    target.gainMp(this._recoveredMp);
    target.startDamagePopup();
    target.clearResult();
    </After Eval>
    You'll need to replace the "x" with the animation you want to play on the healed ally.
    This is also done with Yanfly's skill core plugin. Hopefully you can tweak this formula for the rest of your covertion skills.:ehappy:

    @freebooter
    That formula won't work for enemies because you're asking if the enemy has a weapon equiped, wich they can't, so it immediately triggers an exception and turns the damage to 0. You need to ask if the user is an actor on this formula.

    I rewrote it, using Yanfly's damage core plugin. So it maaaay be more easy to understand.
    Leave the formula space blank, and write this on the notebox.
    Code:
    <Damage Formula>
    value = a.atk * (100.0/(100.0 + b.def));
    if(a.isActor() && [6,7,8].some(function(e){return a.hasWeapon($dataWeapons[e])})){
       value  = 1000;
    }
    </Damage Formula>
    Value is the total damage the skill will deal. :rhappy:

    @Blue Symphony I downloaded Yanfly's damage core plugin, put it in the js/plugins folder and activated it in the plugin-manager. I used your formula but the problem stays the same: enemys deal 0 damage, but also the hero (who is equipped with weapon nr. 6) deals 0 damage.

    Any idea what could be wrong? Thanks.
  7. @freebooter

    **EDIT**
    The formula works perfectly for me. So you either have incompatible plugins or didn't install the plugin correctly. My guess is you don't have Yanfly's Core Engine plugin installed, wich is the one that enables all the others. If you don't want to install them tell me and I'll modify the formulas.
    **END EDIT**

    You were close, it's kinda like that.
    This is the way to check for equipped weapon types in a formula.
    Code:
    <Damage Formula>
    value = a.atk * (100.0/(100.0 + b.def));
    var WpnType = x;
    if(user.isActor() && user.isWtypeEquipped(WpnType)){
       value  = 1000;
    }
    </Damage Formula>
    Replace the x with the index of the weapon type you want. Remember to start counting from 0!
    Altough I'm not very sure why would you want to do this instead of making skills with weapon requirements...

    @Hungry Moogle
    Well, sadly I have no idea what the formula for Frog Squash is, but I think I have something(?).

    How to make a "deal more damage the lower your HP is" a.k.a. berserk-like skill.
    Code:
    <Damage Formula>
    value = a.atk * 4 - b.def * 2;
    value *= 2 - user.hpRate();
    value = Math.ceil(value);
    </Damage Formula>

    This will do exactly what you asked, when you're missing 75% of your health it will multiply the damage x1.75.
  8. @Blue Symphony I had to reopen my project, now it works.

    The point is I want 2 different damage formulas, depending if actor uses bows or guns or melee weapons. I think this is the most convenient way for the player. He just clicks "attack" and dont has to scroll down to find the skills. As I have 8 weapon types the player had to find the corresponding skill each time he wants to attack. Or did I get something wrong? (which could easily be as I'm a noob ;)

    Concerning your formula (thanks for that!), di I understand right that I can replace x with a list of numbers? Like:

    var WpnType = 19,20,21,22;

    Can you please explain what you mean with start counting from 0. My weapon types reach from 14 to 22.
  9. @freebooter Hmmm, I think I undertand what you're trying to achieve. Altough I think you're right saying that it's easier for the player to only have one attack option, I feel like as a developer you're walking on a somewhat inefficient path IMO. I think the most convinient way is just making the weapons have different traits or effect depending on its type.
    Now let's anwer your questions. You can't write a list of numbers there, WpnType can only store one number, sadly, I don't how to efficiently check for multple weapon types. Also, with weapon type I'm talking about this:
    Spoiler
    upload_2017-12-6_18-39-57.png
    The weapon type number 0 is the "bare fist" weapon type. that's why I said you should count from 0. Since you just said you had 22 weapon types, I'd like to believe we're talking about different things.
  10. Blue Symphony said:
    @Hungry Moogle
    Well, sadly I have no idea what the formula for Frog Squash is, but I think I have something(?).

    How to make a "deal more damage the lower your HP is" a.k.a. berserk-like skill.
    Code:
    <Damage Formula>
    value = a.atk * 4 - b.def * 2;
    value *= 2 - user.hpRate();
    value = Math.ceil(value);
    </Damage Formula>
    This will do exactly what you asked, when you're missing 75% of your health it will multiply the damage x1.75.
    Actually, this is exactly what I was looking for. I didn't actually intend for a 1:1 recreation of the Frog Squash tech, I just wanted a skill that functioned in a somewhat similar manner. Thanks again for the help!

    On a different note, I've been trying to make a instant death-type of skill that, if successful, will absorb 100% of the target's HP & MP, however, I've been having trouble with the absorb MP part of the equation. I tried using Yanfly's Life Steal plugin & placing a <MP Life Steal: 100%> tag in the Skill's Note window, but this results in the skill absorbing the target's MP equal to the target's HP rather than equal to the target's MP as is intended. Does anyone have any ideas on how I can get this skill to work properly?
  11. Blue Symphony said:
    @freebooter Hmmm, I think I undertand what you're trying to achieve. Altough I think you're right saying that it's easier for the player to only have one attack option, I feel like as a developer you're walking on a somewhat inefficient path IMO. I think the most convinient way is just making the weapons have different traits or effect depending on its type.
    Now let's anwer your questions. You can't write a list of numbers there, WpnType can only store one number, sadly, I don't how to efficiently check for multple weapon types. Also, with weapon type I'm talking about this:
    Spoiler
    View attachment 77627
    The weapon type number 0 is the "bare fist" weapon type. that's why I said you should count from 0. Since you just said you had 22 weapon types, I'd like to believe we're talking about different things.

    Thanks for your reply.

    Do you think it could work like this?

    <Damage Formula>
    value = a.atk * (100.0/(100.0 + b.def));
    if(a.isActor() && [6,7,8].some(function(e){return a.isWtypeEquipped($dataWeapons[e])})){
    value = 1000;
    }
    </Damage Formula>
  12. freebooter said:
    Thanks for your reply.

    Do you think it could work like this?

    <Damage Formula>
    value = a.atk * (100.0/(100.0 + b.def));
    if(a.isActor() && [6,7,8].some(function(e){return a.isWtypeEquipped($dataWeapons[e])})){
    value = 1000;
    }
    </Damage Formula>

    I tried it, but it doesnt work. anybody an idea what could be wrong?
  13. Guys,
    please, this cannot be that complicated for someone who is not a dumb noob like me. As I understand the only point is to implement an array so conditional checks if the weapon-type the active actor is wielding is one of the array-types [x, y, z].

    Here the details:
    I want the common attack-skill use a conditional damage formula. The reason is, that I want to have different damage formulas for melee-wepaons (formula based on atk) and one for bows and that kind (based on agi).

    So I now have this formula (the value = 1000 is just to experiment and will be replaced by a formula based on agi):

    <Damage Formula>
    value = a.atk * (100.0/(100.0 + b.def));
    var WpnType = x;
    if(user.isActor() && user.isWtypeEquipped(WpnType)){
    value = 1000;
    }
    </Damage Formula>

    x only takes one number. So I had to modify it in a way that I have four if-conditions, as I have 4 different types of long-range-weapons. This would work, maybe. But it would be more easier with an array and just 1 conditional.

    Anybody who knows how to implement this?

    Thanks in advance!
  14. @freeboter
    Oh, you were right, it wasn't nearly as hard as I expected it to be, I was looking on the wrong direction. This formula worked for me:

    Code:
    <Damage Formula>
    value = <default formula>;
    var meeleWpns = [1, 2, 3];
    var rangedWpns = [4, 5, 6];
    if(user.isActor() && meeleWpns.some(function(e){return user.isWtypeEquipped(e)})){
      value = <Meele formula>;
    } else if (user.isActor() && rangedWpns.some(function(e){return user.isWtypeEquipped(e)})){
      value = <Ranged formula>;
    }
    </Damage Formula>

    You only need to change the numbers with the id's of your weapon types.
  15. Thank you,
    @Blue Symphony ! You helped me a lot with this formula.
  16. Hi everyone,

    Does anyone know how add a modifier to a damage formula that takes into account the number of actors a skill targets? I want to have a skill whose outcome varies by how many enemies it hits.
  17. Hi, I left a post on this thread before in regards to a Damage Formula for my healing skills, but now I'd kinda like some more help with it.

    After taking BackwardsKey's advice, I started tinkering with the damage formula they gave:
    Backwardskey said:
    use a flat number to determine the power of the spell, and limit the influence of the caster's Magic stat.

    Code:
    power = 20
    healing = power * (2 + a.mat * (a.lvl + a.mat))/256

    Eventually, I got a formula I thought I liked.

    Code:
    b.mhp - ((b.level - 1) * (0.05 * b.mhp))

    Problem is...when I tested this out on one of my game's test files, I realized that it healed 0 damage at level 20ish (level 22 for the character I tested it on). So now I'm kinda stumped. Whatever I do, the formula heals too much or too little HP at level 20. I was thinking of maybe going for a formula that decreased by 5% every level, but I'd really like something that never dips below 25% or 15% or something, so that the spell won't heal 0 damage by level 50 (or in this case, 20).

    I have quite a few of Yanfly's Plugins, including the Skill Core. I suspect I might need to use a Lunatic Mode code in order to achieve this, but I don't know how to use Lunatic Mode. Anybody got any suggestions?
  18. Leaufai said:
    Hi everyone,

    Does anyone know how add a modifier to a damage formula that takes into account the number of actors a skill targets? I want to have a skill whose outcome varies by how many enemies it hits.

    If you're using Yanfly's damage core plugin you could write something like this:
    This way the damage of the formula is multiplied by the number of enemies. Not the targeted ones tho, but every enemy.
    Code:
    <Damage Formula>
    var dmg = user.atk * 4 - target.def * 2;
    var totalEnemies = target.friendsUnit().aliveMembers().length;
    value = dmg * totalEnemies ;
    </Damage Formula>
  19. I'm trying to make the formula first get a random number between 1 and 6 (like rolling a D6), then if the number is 1 then weak formula, if number is 6 then strong formula and add state, for all other the formula is normal. It's not working for me. Can anyone please show me what I've done wrong?

    Code:
    c = Math.randomInt(6)+1; c === 1 ? 1 + a.atk - b.def : c === 6 ? b.addState(10); a.atk * 6 - b.def * 2 : a.atk * 4 - b.def * 2
  20. @HumanNinjaToo

    Altough I'm not a big fan of large statements using the "?" operator, I admire the logic used to solve this.
    The problem you have is that this operator can't execute two different lines on it's own, this part:
    Code:
    b.addState(10); a.atk * 6 - b.def * 2
    It's the troubling one. You need to add proper parentheses and a comma operator to the formula in order for it to work:
    Code:
    var rnd = Math.floor(Math.random() * 6) + 1;(rnd == 1) ? 1 + a.atk - b.def : (rnd == 6) ? (b.addState(10), a.atk * 6 - b.def * 2) : a.atk * 4 - b.def * 2;

    Be aware that any stat added that has the "Remove by damage" thing will be instatly removed with this formula.

    Good luck!