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
676
Reaction score
588
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 Profile Posts


finally, the B-tile is added to the forum and steam!
I hope my annual #DoItForHargon contest gets lots of entries this year (since a Playstation 5 is a pretty big prize lol) XD On further news - I'm back to game devving next week after hiatus cause of that tragedy of losing everything I own.
Rome Trastevere deserve a tileset. Mumble mumble...
Before the full time job, I can make 1 MZ plugin per day, even though it's still hard; With the full time job, making 1 such plugin per week becomes just as hard lol

Forum statistics

Threads
102,989
Messages
996,505
Members
134,463
Latest member
adafon
Top