Is there a weapon/armor attack/defense value that can put into damage formula?

Hi I'm trying to see if it's possible to use the equipped stats rather than make attack/defense stats. I cannot find it though checking the damage formula 101. There are these lines.
> hasWeapon() - is actor wielding a weapon (true/false)
> hasArmor() is actor wearing any armor (true/false)
I assume if nothing is equipped, the value for them is 0?
I'm looking for the damage for main hand weapon, and defendse for main armor slot to put into damage/state formula, thanks.
Hi there!

You access the equipment status with the script calls:
JavaScript:
$dataWeapon[ID].params[paramId]
$dataArmors[ID].params[paramId]
I think you can get the skill caster equipments' stat with:
for weapon:
var stat1 = a.equips()[0] ? a.equips()[0] : 0
for amors,: (1= helmet / 2 = armor...) You can check TYPES tab in Database to find
var stat1 = a.equips()[1] ? a.equips()[1] : 0
Thank you for your replies. I've tried to put these into damage formula, but all damage turn to zero.

a.atk - b.$dataArmors[ID].params[paramID]

a.atk – b.($dataArmors[ID].params[paramID])

a.atk - $dataArmors[ID].params[paramID]


When putting into stats like below, they all crash.

<Custom Passive Condition>
var stat1 = a.equips()[1]?a.equips(1):0
if (var stat1 <= 2) {
condition = true;
} else {
condition = false;
}

<Custom Passive Condition>
if (var stat1 <= 2) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>


<Custom Passive Condition>
if ($dataArmors[].params[] <= 2) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>

crash.jpg


When put it this way, the character would automatically get the passive state regardless their defense(armor at defense 3 or 4 still grant state).

<Custom Passive Condition>
if ($dataArmors[ID].params[paramID] <= 2) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>

Sorry but I don't really understand script. Where did I do wrong here?
Thank you for your replies. I've tried to put these into damage formula, but all damage turn to zero.

a.atk - b.$dataArmors[ID].params[paramID]

a.atk – b.($dataArmors[ID].params[paramID])

a.atk - $dataArmors[ID].params[paramID]


When putting into stats like below, they all crash.

<Custom Passive Condition>
var stat1 = a.equips()[1]?a.equips(1):0
if (var stat1 <= 2) {
condition = true;
} else {
condition = false;
}

<Custom Passive Condition>
if (var stat1 <= 2) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>


<Custom Passive Condition>
if ($dataArmors[].params[] <= 2) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>

View attachment 203561

When put it this way, the character would automatically get the passive state regardless their defense(armor at defense 3 or 4 still grant state).

<Custom Passive Condition>
if ($dataArmors[ID].params[paramID] <= 2) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>

Sorry but I don't really understand script. Where did I do wrong here?
a.equips()[1]?a.equips(1):0 was supposed to be used in Damage Formula box
If it was to put in State Notebox. It should be user.equips()[1]?user.equips(1):0
Thank you for your replies. I've tried to put these into damage formula, but all damage turn to zero.

a.atk - b.$dataArmors[ID].params[paramID]

a.atk – b.($dataArmors[ID].params[paramID])

a.atk - $dataArmors[ID].params[paramID]
That's not what Eli told you to type. b is referring to the defending battler, and a battler does not contain the database for items. He also didn't have any parentheses around it...and you need to replace the letters ID with an ID, a number as shown in your database.

And then as far as the code in your states go, you have the completely wrong syntax because you changed what vietanhdang told you, and he missed the typos when giving you the correction. I would also give you the advice that there's no point in declaring a variable that gets used once.

So, I'm not sure exactly what you're trying to look at in your state because your syntax is so off and, as far as I can see, you never said. But if it's the defense parameter of your body armor, the code would be:
Code:
<Custom Passive Condition>
condition=(user.equips()[4] ? $dataArmors[user.equips()[4].id].params()[3] : 0)<=2;
</Custom Passive Condition>
Presuming that Body is still Equipment Type 4 in your database,
I apologize but really don't understand this.

Does it mean I've to put all possible type of armors into the first []? I've changed from 1 to 5 in the second [] but it automatically determines the condition is met.

<Custom Passive Condition>
if ($dataArmors[1,2,3,4].params[5] <= 2) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>


<Custom Passive Condition>
if (user.equips()[1,2,3,4,5]?user.equips(1,2,3,4,5):0 <= 2) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>


This also automatically passes the condition without being met.

<Custom Passive Condition>
condition=(user.equips()[1,2,3,4] ? $dataArmors[user.equips()[1,2,3,4].id].params()[3] : 0)<=2;
</Custom Passive Condition>

Have tried singular number in [] but they all pass without meeting the requirements.


<Custom Passive Condition>
condition=(user.equips()[1,2,3,4] ? $dataArmors[user.equips()[1,2,3,4].1,2,3,4].params()[3] : 0)<=2;
</Custom Passive Condition>

<Custom Passive Condition>
if((user.equips()[4] ? $dataArmors[user.equips()[4].id].params()[3] : 0 <=2)){
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>


For these, I've changed the no.4 armor type and make sure the defense is above 2, but it still ignores the requirement.

<Custom Passive Condition>
if (user.equips()[4] ? $dataArmors[user.equips()[4].id].params()[3] : 0)<=2;{
condition = true;
} else {
condition = false;
}


<Custom Passive Condition>
condition=(user.equips()[4] ? $dataArmors[user.equips()[4].id].params()[3] : 0)<=2;
</Custom Passive Condition>


Crashes when I put like these.

(with or without the first { both crash)

</Custom Passive Condition>

<Custom Passive Condition>
condition=(user.equips()[1,2,3,4] ? $dataArmors[user.equips()[1,2,3,4].1,2,3,4].params()[3] : 0)<=2;
</Custom Passive Condition>

I'd like to ask if it works, does this mean the formula work on enemies (despite they have no equipment)? Since they've no weapons nor armor, not sure how would the lack of item slot work for them.
I apologize but really don't understand this.
I'm sorry, but I'm not going to try to help much in this post because you're not providing information to help anyone help you:
I'm not sure exactly what you're trying to look at in your state because...you never said.
And you still haven't said, so I can't give you help.
Does it mean I've to put all possible type of armors into the first []? I've changed from 1 to 5 in the second [] but it automatically determines the condition is met.
Does what mean? The code I gave you will do exactly what I said it does. I did not say you should change anything. If you want it to do something different than what I said, then what?
<Custom Passive Condition>
All the rest of your post just doesn't make any sense to me. If you don't know how to write JavaScript, why are you trying to make things up? Of course anything you randomly type in is going to either not work or crash your game.
I'd like to ask if it works, does this mean the formula work on enemies (despite they have no equipment)? Since they've no weapons nor armor, not sure how would the lack of item slot work for them.
If you intend for this state to also exist on enemies, it's a very simple few extra words of code to check for that. But you need to say so (in addition to clearly saying what you want the state to do, instead of writing these long posts of code you're trying to make up). You've done it twice now, and I don't get why.
Sorry, I didn't know formulas for damage and state are different.

I was planning to get it for damage and states, especially states. For example, if player or enemy has defense lower than 2, with the skill he would have an evasion boost. So if an enemy's dodge is too high, player can cast a defense up spell on the enemies to tune down its evasion. I had copied the exact lines but the game didn't react, seems this is beyond me even with help. Sorry I've caused this trouble.
Sorry, I didn't know formulas for damage and state are different.
You were told that in post #5.

I was planning to get it for damage and states, especially states. For example, if player or enemy has defense lower than 2, with the skill he would have an evasion boost.

This is still very confusing. Nothing in the post you just typed talks about looking at a specific piece of armor. You talk about "player or enemy has defense lower than 2," but the game has a built in way to see a battler's defense, which is the sum of all of their gear, their class, any buffs.

Is there some reason you don't want to just use that number? You didn't say anything that will help anyone to give you the code you need.
So if an enemy's dodge is too high, player can cast a defense up spell on the enemies to tune down its evasion.
This is a pretty confusing way to approach it. Why wouldn't you just give armor, in your database, a penalty to evasion? And then any spells that should lower an enemy's evasion can just do that.

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-weapon-armor-attack-defense-value-that-can-put-into-damage-formula.141145/