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

Inactive
Veteran
Joined
Jul 2, 2016
Messages
682
Reaction score
598
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

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top