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,808
Reaction score
2,868
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

As you get older you notice how things you always used to do is starting to cause pain XD
I've always sitted on my feet for exemple and now I've started to develop knee pains that always occur after I sit in a way that I've ALWAYS done.
And am I going to stop doing it? Eh, likely not before it is causing me massive pain....:kaoswt:
Yay me...
Taking screenshot from later part of the game, to use as foreshadowing in earlier parts. :kaoblush:
So close to being finished with this portion, feels like it's been taking forever
Tukold2.PNGTukold3.PNGTukold1.PNG

Forum statistics

Threads
124,451
Messages
1,163,756
Members
163,272
Latest member
Krull
Top