HOW TO RETURN THE ATK VALUE OF WEAPON?

arashiya

Veteran
Veteran
Joined
Jun 19, 2019
Messages
116
Reaction score
5
First Language
english
Primarily Uses
RMMV
I want to show the atk value of the weapon which is equipped
how can I do it?
 

Zenpai

Villager
Member
Joined
Jul 5, 2019
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMMV
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.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,783
Reaction score
4,726
First Language
English
Primarily Uses
RMMZ
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).
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
First Language
German
Primarily Uses
RMMV
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.
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,783
Reaction score
4,726
First Language
English
Primarily Uses
RMMZ
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.
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
First Language
German
Primarily Uses
RMMV
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.
 
Last edited:

arashiya

Veteran
Veteran
Joined
Jun 19, 2019
Messages
116
Reaction score
5
First Language
english
Primarily Uses
RMMV
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
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,608
Reaction score
1,514
First Language
English
Primarily Uses
RMMV
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) :D

<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>

:D
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,783
Reaction score
4,726
First Language
English
Primarily Uses
RMMZ
@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.
 

Latest Threads

Latest Posts

Latest Profile Posts

My new cutscene system makes it so much easier to add parallel stuff happening in the background, I can easily fill the whole screen with action.

I remember once when I was at Disney's Animal Kingdom and I got to dance with some of the cast members! It was so much fun! After the show my dad and I got frozen lemonade and some ice cream. It makes me feel better remembering the good things about my dad... maybe I will return to Orlando.
spending almost entire day to mod skyrim but it still couldn't run properly :(
My friend has become one with the glitter. @ImaginaryVillain, got any room in the Cult of the Sporkle?
I still cannot wrap my head around how to edit and use arrays in RPG Maker MV o_O

Forum statistics

Threads
107,717
Messages
1,031,635
Members
139,857
Latest member
ShadowGray
Top