ID:146032
 
Code:
obj
item
verb
get()
set src in oview(1)
src.Move(usr)
drop()
src.Move(usr.loc)
tool
verb
equip()
//misc equipping code goes here
src.verbs -= /obj/item/tool/verb/equip
src.verbs -= /obj/item/verb/drop
src.verbs += /obj/item/tool/verb/unequip
return 1
unequip()
//unequip effect goes here
src.verbs -= /obj/item/tool/verb/unequip
src.verbs += /obj/item/verb/drop
src.verbs += /obj/item/tool/verb/equip
return 1
New()
..()
src.verbs -= /obj/item/tool/verb/unequip
hatchet
verb
chop()
set src in usr.contents
//chopping code
New()
..()
src.verbs -= /obj/item/tool/hatchet/verb/chop
equip()
. = ..()
if(.)
src.verbs += /obj/item/tool/hatchet/verb/chop
return .
unequip()
. = ..()
if(.)
src.verbs -= /obj/item/tool/hatchet/verb/chop
return .


Problem description:

Alright, this is an odd problem, as I've NEVER had this problem before. This has always worked for me, and I don't understand why it isn't working. My hatchet, when I pick it up, has the equip, unequip, get, drop, and chop. When I equip it, it doesn't lose the equip or drop verb. When I unequip it, it doesn't lose the unequip or chop verb. What the hell is going on? None of this stopped working until I overrode the equip(), unequip(), and New() procs. I've done this a hundred thousand times before, why doesn't it work now?
src/verbs += /obj/item/verb/drop

Slash instead of period?
Similar to things going wrong with me- A code segment thats worked before suddenly goes dead...
In response to Bobthehobo
That was just a typo, not really the problem.
src.verbs -= /obj/item/verb/drop

No idea what else to say other than that.
In response to Sinoflife
Again, a typo. I did not copy and paste any of this, I have a complex action/event system that I highly doubt many people on BYOND will understand. I cut out most of the tidbits, and reduced it to the basest level of functionality so that someone might be able to help me. if you see something else that looks like a little typo, assume that it shouldn't be there, and try to figure out what the MAIN problem is.
Anybody wanna take a shot at this?
In response to Ter13
This is my last bump on this one... Anyone?
Aren't you giving the verbs to the tool instead of the usr?
In response to Popisfizzy
Yes. Therefore, the verb will add those verbs to the user's list when it is in their inventory.
Have you put in debug statements to make sure those verb removal statements are getting executed?
In response to Crispy
Yep.
In response to Ter13
Okay, I messed around with this a bit, and I've found the problem. When you overriding equip and unequip, you're actually creating two new verbs, with different type paths. You need to make sure you add and remove those overrided verbs (/obj/item/tool/hatchet/equip and /obj/item/tool/hatchet/unequip) as well as the originals (/obj/item/tool/verb/equip and /obj/item/tool/verb/unequip).

Here's the test code I used, which appears to work:

obj
item
verb
get()
set src in oview(1)
src.Move(usr)
drop()
src.Move(usr.loc)
tool
verb
equip()
usr << "Tool equip() (src is [src])"
//misc equipping code goes here
src.verbs -= /obj/item/tool/verb/equip
src.verbs -= /obj/item/verb/drop
src.verbs += /obj/item/tool/verb/unequip
return 1
unequip()
//unequip effect goes here
src.verbs -= /obj/item/tool/verb/unequip
src.verbs += /obj/item/verb/drop
src.verbs += /obj/item/tool/verb/equip
return 1
New()
..()
src.verbs -= /obj/item/tool/verb/unequip
src.verbs -= /obj/item/tool/hatchet/unequip
hatchet
verb
chop()
set src in usr.contents
usr << "You chop mightily!"
New()
..()
src.verbs -= /obj/item/tool/hatchet/verb/chop
equip()
. = ..()
if(.)
usr << "Hatchet equip() (src is [src])"
src.verbs += /obj/item/tool/hatchet/verb/chop
src.verbs -= /obj/item/tool/hatchet/equip
src.verbs += /obj/item/tool/hatchet/unequip
return .
unequip()
. = ..()
if(.)
src.verbs -= /obj/item/tool/hatchet/verb/chop
src.verbs += /obj/item/tool/hatchet/equip
src.verbs -= /obj/item/tool/hatchet/unequip
return .

turf/text=" "
In response to Crispy
That makes sense... Kind of... Thanks, man.
In response to Ter13
Yeah, it's pretty unintuitive.

Thanks, man.

No problem!