Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
So I've been using the <On Creation Eval> for my weapons for some time now with great success. Now, I want to use the same approach for armor as well. Basically, I add the following to each piece of armor in the game:
<On Creation Eval> item._armorVal = 10; </On Creation Eval>
This is all fine and good since I'm using independent items. Now the issue comes to when I want to utilize the "_armorVal" I just created. I use YEP_ArmorScaling as well and need to find the sum of all the "_armorVal" that the actor has equipped. If I were simply trying to reference, say the Body slot, then it would be as simple as:
target.isActor && target.equips()[3] ? target.equips()[3]._armorVal : target.level * 10;
But I need to find the sum of all the equipped items... (and I don't think nesting a bunch of if statements would be the way to go, surely there's a better way).
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
I was hoping for something like this? But I'm not sure if I did it right...
JavaScript:
if (target.isActor) {
    var totalArmor = 0;
    for (var i = 0; i < target.equips().length; i++) {
        if (target.equips()[i]) {
            totalArmor += target.equips()[i]._armorVal;
        }
    }
    return totalArmor;
} else {
    target.def;
}
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,819
Reaction score
2,875
First Language
EN
Primarily Uses
RMMZ
Try if (target.isActor()) { instead: you want to check the result of evaluating isActor on target, rather than whether the function exists on target. :kaohi:
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
Try if (target.isActor()) { instead: you want to check the result of evaluating isActor on target, rather than whether the function exists on target. :kaohi:
Ah, thank you! That's where my typo was...forgot the parenthesis.
 

Latest Threads

Latest Posts

Latest Profile Posts

Food for thought. Factorio: Spaghetti belts make your factory inefficient as you fight for space constantly. Satisfactory: Spaghetti belts and massive clipping is the most efficient way to run your factory since it's the shortest distances.
ScreenShot_8_19_2022_8_51_4.png
Both Mike and Ray here are in a "HYPE!" state after Mike uses "Wild Party", which also heals everyone. they'll do more damage and counter more often, but defense is lower along with hit rate.
WHEEL3.gif
Ooker spookers and fun attack mechanics! What a Friday!
Not today... Not today...
I guess I should send my CV to Hasbro. I've made Monopoly cheaters edition more fun and challenging. I've developed custom cheats and chest/chance cards for it. And I've cleared many nightmares through my cards and rules.

Forum statistics

Threads
124,710
Messages
1,165,422
Members
163,521
Latest member
Balalaika
Top