ID:263027
 
Below is the code for the equip() command on a suit of armor. It seems to ignore the line with the [**] in front of it. the variable power is defined - in this item's case, it is set to 3. I unequip the armor, and it takes off 3 defense, and then when I re-equip it, it does not add any defense. Anyone have an idea as to why?
                verb
equip()
if(usr.arm)
var/obj/item/Equipped = usr.arm
Equipped.suffix = null
usr.def -= Equipped.power
if(Equipped.name == "Red Robe" || Equipped.name == "Green Robe" || Equipped.name == "Blue Robe")
usr.Mmapo -= Equipped.power
usr.mapo -= Equipped.power
usr.Mdef -= 2
usr << "You unequip the [usr.arm]!"
usr.overlays -= usr.armlay
usr << "You equip the [name]!"
suffix = "Worn on Body"
usr.arm = src
/*[**]*/ usr.def += src.power
usr.armlay = /obj/item/Def/armor2/overlay
usr.overlays += usr.armlay



--Vito

Well, why is /*[**]*/ even there?
In response to Derekjeterisgod
Derekjeterisgod wrote:
Well, why is /*[**]*/ even there?

Did you read the little description above it? It seems to ignore the line with the [**] in front of it.

Vito:

Try adding debug messages, see what everything is and see if perhaps power isn't being set equal to 0 somewhere else.

[EDIT]


Yeah, power being 0 is the only thing I can think of for this specific problem. I'd just add in a nice: src << src.power right before that. I don't think just one line would be ignored, if anything, an expression would pause the proc for a while (if not indefinitely?)
In response to Audeuro
Oh, I thought he meant it was like that with that there... Okay nvm :)
In response to Audeuro
Hmm... I'll check that.

EDIT: Wierder and wierder... It now works okay when you just equip and unequip, but unequip, drop, pick up, and re-equip ignores that line still. Note that this effect is different than it was before, and I changed nothing about items and equipping since I noticed the problem.

EDIT EDIT: Oh, wait, never mind that last bit - I was using two different types of armor. One ignores that line sometimes, the orther ignores it all the time. The problem stands.


--Vito
In response to Vito Stolidus
The line isn't skipped. As Audeuro said, use debug messages.

Throw a
usr << "power = [power]"

just before and just after the line that supposedly gets skipped. There's a good chance it equals 0, regardless of what you think it should equal.

Hiead
In response to Hiead
I did use debug messages. The variable power is equal to 3 just before and just after the usr.def += src.power line. That's annoying.

--Vito
In response to Vito Stolidus
DM Doesn't seem to like you.
In response to Vito Stolidus
Check usr.Def before and after. Perhaps that's being reset at one point, rather than src.power?
In response to KirbyRules
Apparently, it doesn't, does it? As to usr.def being modified, I doubt it. I'm going to check anyway, but the default value for that var is 0.

Checking...

Ohh, found it... In the drop code for equipped items:
                    if(src == usr.arm)
src.suffix = null
usr.def -= src.power
if(src.name == "Red Robe" || src.name == "Green Robe" || src.name == "Blue Robe")
usr.Mmapo -= src.power
usr.mapo -= src.power
usr.Mdef -= 2
usr << "You unequip the [src.name]!"
usr.overlays -= usr.armlay
usr.shi = null //<-- The issue is here - it takes off the shield
//, then when I reequip, it unequips the armor again.


That should, and now does read, usr.arm = null.

Thanks guys.


--Vito