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
696
Reaction score
622
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

i want to make videogame, though i am burned out on games with RPG elements, but the only gamedev tool i know how to use is rpg maker. :/
Rakon wrote on xizorandy's profile.
Hello! I found a post of lightning strike pictures you posted. You said you made them, am I allowed to use them in my commercial project. Would be really cool!^^
evhht2zr.png

Have a nice day!
It's almost 3 month and this piece of drawing is still not finished yet.
aaaa.jpg

Really busy with other stuffs like commission and coping with personal problem.
Stella & Elyune, maybe used for promotional art if my game project finished one day.

Forum statistics

Threads
112,256
Messages
1,066,849
Members
145,866
Latest member
Hallistra
Top