Yanfly's Damage core can I get the weapon's atk?

Hello everybody.
I was wondering if I could use in the damage formula the weapon the user is using currently?
Plugin link for convenience: http://yanfly.moe/2015/11/07/yep-25-damage-core/

I think this will work:
Code:
user.weapons()[0].params[2]
To refer to the second weapon (e.g. for a dual-wielding skill) try replacing the 0 with a 1. 🙂

If this formula will be used for enemies, you may want to use something like this to avoid errors (by default enemies have no weapons):
Code:
user.isActor() ? user.weapons()[0].params[2] : user.atk
This should return the atk of the user's primary weapon for actors, and the user's atk for enemies.
Thank you so much!
I just realized that using "user.weapons()[1].params[2]" still refers to the first weapon.
How can I check the second weapon?
Oh, yes, it seems that happens if the actor has only one weapon equipped, in their off-hand. The weapons() function just returns all the "weapon" type equips on the actor, but it skips empty equip slots. Whoops. 😴

With that in mind, equips() is probably a better option:
Code:
user.equips()[0].params[2]
Just change the 0 to match the weapon's equip slot ID (0 is first slot, 1 is second slot, etc).
Thank you for the help!
I have a problem though.
I'm trying to come up with a formula you see, so what I did is this:
Code:
<damage formula>
if (user === user.isActor()) {
var weapon1 = user.equips()[0].params[2]
var weapon2 = user.equips()[1].params[2]
value = (weapon1 + weapon2) / 2
} else {
value = user.atk
}
</damage formula>
but when I try to test it it just returns the weapons atk.
Also, my weapon atk is 500 but the game returns 498 as damage. Why is that? Variance is 0% so it doesn't make sense.
user.isActor() becomes either true or false depending on whether or not the user is an actor, then your if statement checks "is the battler using this skill true/false?"...which will always be false, since they're different types (object vs boolean).

Not sure why your formula is returning 498 for you rather than 500, though...maybe that actor has some armor or something with -2 atk on it? Or a trait that multiplies their atk by something, and their combined attack, scaled down, just happens to be a little less than 500? Or perhaps some extra step in your damage formula, maybe check Damage Core's parameter settings. 😅

Try something like this formula instead! I've put comment lines (starting with //) to help explain it, but you can delete those lines if you want~
Code:
<damage formula>
// get weapon objects
var w1 = user.equips()[0];
var w2 = user.equips()[1];
// null off-hand object if it's not a weapon
if (!DataManager.isWeapon(w2)) w2 = null;
// count number of equipped weapons
var wCount = user.weapons().length;
// check if user is an actor
if (user.isActor()) {
  // check if actor has at least one weapon equipped
  if (w1 || w2) {
    // get atk values from equipped weapon(s)
    var d1 = w1 ? w1.params[2] : 0;
    var d2 = w2 ? w2.params[2] : 0;
    // get mean value, rounded to nearest integer
    value = Math.round((d1 + d2) / wCount);
  } else {
    // otherwise, is actor with no weapons equipped
    value = user.atk / 2;
  }
} else {
  // if not an actor
  value = user.atk;
}
</damage formula>
Wow, this works flawlessly!
Thank you so much again!

EDIT: For some reason enemies don't do damage at all, even if I change the value to 5000 they still do just 0.
Press F8 during playtest to open the console, it'll show you any scripting errors that happen. If there's a scripting error, it'll output zero damage rather than crash your game (at least, that's how the default works not sure about YEP damage core)

The issue is probably that enemies don't have a "equips()" function, so check the error message to see if that's the case. If so, try moving the isActor() check to the top
Yes I moved the condition for actor to the top and now it works correctly.
Thank you Aloe and caethyril so much!!!

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-damage-core-can-i-get-the-weapons-atk.106024/