Issues Getting Values From Armor Notetags

BodkinsOdds

Villager
Member
Joined
Jul 26, 2014
Messages
8
Reaction score
2
First Language
English
Primarily Uses
Hello, I'm writing a plugin to add old school AD&D style THAC0 and AC, but I'm having trouble getting the data out of my armor note tags. I've got Harold wearing cloth with <ac: 8> and a shield with <ac: 1>, so this should result in him having an AC of 7. Instead my code is giving him the default AC of 10.

Relevant Code

Does anyone know what I'm doing wrong here?

EDIT: Still not working, updated the code.
 
Last edited:

waynee95

Lunatic Coder
Veteran
Joined
Jul 2, 2016
Messages
646
Reaction score
543
First Language
German
Primarily Uses
RMMV
You had some errors inside that code. this.armors is a function, so you need to use () there.

Code:
Object.defineProperty(Game_Actor.prototype, "ac", {
    get: function() {
        var ac = 10;
        var bonus = 0;
        var armors = this.armors();
        for(var i = 0, length = armors.length; i < length; i++) {
            var armor = armors[i];
            // If armor is in the body slot.
            if (armor.etypeId === 4) {
                ac = armor.meta.ac || ac;
            } else {
                bonus += armor.meta.ac || 0;
            }
        }
        return ac - bonus;
    }
});
 

BodkinsOdds

Villager
Member
Joined
Jul 26, 2014
Messages
8
Reaction score
2
First Language
English
Primarily Uses
Thank you, that almost fixed everything. I knew I had to be doing something dumb.

For some really odd reason though, I had to switch to this:
Code:
if (armor.meta.ac) {
    if (armor.etypeId === 4) {
        ac = armor.meta.ac;
    } else {
         bonus += armor.meta.ac;
    }
}
When I was using armor.meta.ac || default I kept getting -2 instead of 7.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Writing out an idea for the No Travel Game Jam. I have a general plot and challenge written out, it's just a matter of filling the rest in and making it interesting.
A definite difficult time right now. How is everyone doing during this pandemic? I already have seen furloughs and layoffs.
Hollow 1977 wrote on Archeia's profile.
Hope you and your family are doing well during this difficult time. :)
My elderly neighbor whom I've been buying groceries for just got carried out of his home on a stretcher by guys with hazmat suits. Considering I've been his only point of contact for the past month it's probably safe to say my boss was right to tell me to stay home once I developed a mild cough after all.
Damn. All these new features to the forums. Takes some getting used to.

Forum statistics

Threads
95,642
Messages
930,674
Members
125,963
Latest member
highchloride
Top