HOW TO RETURN THE ATK VALUE OF WEAPON?

I want to show the atk value of the weapon which is equipped
how can I do it?
Using Control Variable in an event, you can grab the actors attack number. I don't know if this pulls the current total actor attack amount (including all boosts/buffs) or if it just pulls the core attack amount. try a few experiments where you print the value of the variable using \V[n] where n is the number of the variable you want to read using a text display, and print it without the weapon equipped, and again with the weapon equipped and see if the value changes. If it does change, then it pulls the current total attack amount.

Unfortunately, I don't see a way to dynamically pull the data each time, unless you look for an addon that will do it for you. As im not well versed in the ins and outs of this program, it's possible someone knows a way to pull this off in vanilla.

However, if that test above works, you'd just need to figure out a way to trigger some data storage when equipment changes, to measure the existing attack value, and then record the new attack value, subtract the difference and you have the attack value of the equipped weapon.
Code:
var actor    = $gameParty.members()[0]; // change this number to change member. 0 = member 1, 1 = member 2, etc.
var totalAtk = 0;
var weapons  = actor.weapons();

for (var i = 0 ; i < weapons.length; i++) {
    totalAtk += weapons[i].params[2];
}

$gameVariables.setValue(20, totalAtk); // change the 20 to the variable ID

This code will calculate the sum of the atk parameter of all weapons the first party member has equip:
  • To change which hero it checks, change the number on the first line. The number indicates the party member id (0 = member 1; 1 = member 2; 2 = member 3, etc.)
  • To change which variable it stores the value in, change the "20" to your variable ID on the last line.
You can insert the code in a script call. What will happen is that it will store the value inside the indicated variable. Please note that I haven't run the code, so I do not guarantee that I made no error in the code.

EDIT: Also, to answer the above post, the atk parameter of the actor is the combination of his base stats + equipment (weapon and armor) + buffs + anything else that other plugins might add (like abilities or something).
Dependend on where you want to show the weapon attack you can use this script or set a variable with the script tab inside the variable command:

$gameActors.actor(1).equips()[0].params[2]

Character ID (look at the number in the actors tab in your database)
Equip ID (look at the number in the types -> equipment types part of your database. 0 is mainhand, 1 is offhand etc.)
Param ID
hp = 0
mp = 1
atk = 2
def = 3
mat = 4
mdf = 5
agi = 6
luk = 7

Edit:
For Dual wield
$gameActors.actor(1).equips()[0].params[2]+$gameActors.actor(1).equips()[1].params[2]
This will simply sum weapon 1's atk with weapon 2's atk.
The above post works generally, but it will not work with dual-wield. If you want something that works with everything, regardless of with or without dual-wield, pick my method.
The above post works generally, but it will not work with dual-wield. If you want something that works with everything, regardless of with or without dual-wield, pick my method.
$gameActors.actor(1).equips()[0].params[2]+$gameActors.actor(1).equips()[1].params[2]
What's the problem?

But I agree. Mushrooms Variant might be more elegant as you do not need if checks.
I use the script that I suggested mainly for the formula tab of skills to let the attack do x% mainhand or offhand damage.
thanks very much for all the replies and it greatly helps!
now I also know how to show the other values (HP, def, etc...)
thanks a lot
Dependend on where you want to show the weapon attack you can use this script or set a variable with the script tab inside the variable command:

$gameActors.actor(1).equips()[0].params[2]

Character ID (look at the number in the actors tab in your database)
Equip ID (look at the number in the types -> equipment types part of your database. 0 is mainhand, 1 is offhand etc.)
Param ID
hp = 0
mp = 1
atk = 2
def = 3
mat = 4
mdf = 5
agi = 6
luk = 7

Edit:
For Dual wield
$gameActors.actor(1).equips()[0].params[2]+$gameActors.actor(1).equips()[1].params[2]
This will simply sum weapon 1's atk with weapon 2's atk.
Note that this only works if the weapons are in the first and second slots (0 and 1) and you have to know if the user is a dual wielder or not because otherwise, you'll be counting shield atk (if any) or whatever is in the slot right after. It's highly encouraged that you use weaons() instead of equips() for that reason. To total up every equipped weapon's atk for single wielders, dual wielders, quad wielders, and whatever else:

$gameActors.actor(1).weapons().reduce((a, c) => a + c.params[2], 0)

(At least it should work, I didn't give it a proper test) 😀

<Shameless>Note that one of the plugins in my signature lets you access weapon stats directly and easily via the formula box: a.weaponAtk for example</Shameless>

😀
@Nilom Your method works, I'm not saying it's working. But like you said, you need conditionals.

For OP, if you don't use third party plugins that add multiple weapons, or if you don't have any dual-wield, Nilom's method is shorter (single) and works perfectly. My method is longer, but will work in every scenario.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-return-the-atk-value-of-weapon.110711/