[v1.7.0+] Activatable Object Cleanup

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
Zizzo
Sher'Tul Godslayer
Posts: 2517
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

[v1.7.0+] Activatable Object Cleanup

#1 Post by Zizzo »

Okay, this one's a doozy. :? It's been reported elsewhere that the various rods from my Utility Supplies addon were leaving behind stale "activate object" talents listed in the Use Talents dialog. Well, I finally tracked down what's causing that.

So, here's (some of) the sequence of events that happens when you pick up, say, a rod of trap detection off the floor:
  • Actor:pickupFloor() puts the rod in your inventory via ActorInventory:addObject(). This triggers the :‍onAddObject() callback.
  • :‍onAddObject() says, "Aha, this object can be activated, so we should create an activate-object talent for it."
  • After the above, :addObject() says, "We just picked up this item from the floor, so it should go in the transmo chest."
Suppose you then transmogrify the rod (perhaps because you already have one). That sequence of events goes:
  • Actor:transmoInven() removes the object from your inventory via ActorInventory:removeObject(). This triggers the :‍onRemoveObject() callback.
  • :‍onRemoveObject() says, "This object is in the transmo chest, so it can't be activated, so we don't need to clean up any activate-object talent for it."
See what just happened there? :o Now, since this is a general game bug that can happen to any object that's activatable from inventory and can be found in random drops, I'm putting the bugfix in a separate addon, Activatable Object Cleanup. Basically, we jump in just before the regular :‍onRemoveObject() handling and check whether the object would be activatable if it weren't in the transmo chest, and if so, we do the usual activate-object talent cleanup for it. We also do a sweep at character load time to clear up all the stale activate-object talents you've accumulated.

[And since this is a bugfix addon, as per my usual procedure, I'm reluctant to include it in ZOmnibus or ZOmnibus Lite, since we'd have to claw it back out if/when the bug is fixed in the future.]

[Implementation notes:]

Code: Select all

Hooks:
  ToME:runDone [to clean up orphaned activate-object talents]
Superload:
  mod.class.Actor:
    onRemoveObject() [to clean up behind transmo'd activatable objects]
"Blessed are the yeeks, for they shall inherit Arda..."

Post Reply