[v1.3.0+] Enhanced Wield Replace

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.3.0+] Enhanced Wield Replace

#1 Post by Zizzo »

Urrgh... I still can't get this to work quite right, but I could use feedback on it, and maybe some help.

This addon is for the Rogues and Shadowblades that just found a cool new dagger to replace one of the ones they're wielding, or the Stone Wardens that want to swap in Titanic, or any character that just wants to replace one of their rings. Normally in a case like this, to make sure you're swapping out the one you mean to, you have to take that one off specifically before wielding the new item. This addon pops up a dialog to let you choose the one you want to swap out.

Now, I think I've got this mostly working; the wielded item goes to the right place, the replaced item properly goes back into inventory, nothing gets lost or duplicated (some of my early attempts at this were horrific...), monsters don't move until you're finished wielding, and you can cancel out of the dialog safely without using energy. The problem is that it leaves the inventory dialog in a bad state: Player:doWear() returns immediately thanks to the dialog before we can get around to wielding anything, and by that time, it's too late to tell the inventory dialog to update itself to reflect the changes. I haven't figured out the right combination of coroutines to get this to work; perhaps someone here whose Lua-fu is stronger than mine can tell me what I'm missing... :oops:

Since this is only a mostly functional addon, I'm not uploading it to the website yet; instead, I've attached it here. I believe the appropriate procedure is to rename the file from .zip to .teaa (the latter of which the forum squawks on, apparently) and stick it in your addons directory. And this comes with the usual WARNING: I'm pretty sure this won't actually break anything, but don't use this on a character you'd really hate to lose.
Attachments
tome-wield-replace.zip
(3.92 KiB) Downloaded 595 times
Last edited by Zizzo on Sun May 17, 2015 3:14 am, edited 1 time in total.
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#2 Post by Zizzo »

And after further testing, I think I trust this addon enough now to go live with it. I've added a few improvements since the testing version: the replacement candidates dialog now has a tooltip display for the selected item in the style of the inventory dialog, and you can even use <ctrl> to compare the selected item to the item you're about to wield.

NOTE: If you're using this addon in conjunction with Enhanced Object Compare (directly or via ZOmnibus), you'll want to upgrade it to the latest version (3b or 13d, respectively), which includes a fix to allow the above-mentioned <ctrl>-comparing.

[Technical info:]

Code: Select all

Superload:
  mod.class.Player:
    doWear() [overloaded, to produce the candidates popup list as needed]
    wearObject() [overloaded, to allow adding the object into a specific inventory position]
  mod.dialogs.ShowEquipInven:
    init() [to suppress on_select() tooltips if the candidates popup is up]
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#3 Post by Zizzo »

So, it turns out that way back in 1.3.0, the T4 module added functionality to the Player:doWear() method that would have made my job in this addon a lot easier, and I was blindly clobbering it. :oops: AFAICT this was in support of being able to mouse-drag an object from inventory onto whichever worn/wielded item you wanted to replace — which means that this addon was probably screwing that up. :oops: :oops: That's fixed in release v1a, just pushed out. Also of note, Enhanced Wield Replace is now officially included in ZOmnibus, for your convenience. :wink:
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#4 Post by Zizzo »

Fun fact: it turns out it is possible, as Snow discovered, to attempt to wield an unwieldable object by dragging it around in the inventory dialog. Now, the game recovers from this gracefully — but it does so after the code added by this addon, which wasn't expecting that... :oops: This is fixed in v1a.1, just pushed out.
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#5 Post by Zizzo »

So I recently noticed when trying to change my golem's gems that this addon's candidates list dialog doesn't get used, which is vaguely annoying now that I'm used to it. v1b, just pushed out, is an attempt to fix that. This involves moving the superload of :doWear() from mod.class.Player to mod.class.Actor; it's supposed to check that the actor is the player or the golem before kicking in, but let me know if you start getting prompted for which ring Urkis should swap out or something... :shock: :oops:
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#6 Post by Zizzo »

Déjà vu all over again… :wink: Ran into the exact same problem as above trying to change weapons for my Writhing One's worm that walks (currently named Doug :mrgreen: ). This may only kick in when manipulating its inventory via Interact with the Worm, but it was easy enough to fix by slightly expanding the golem fix from before. That's pushed out as v1c.
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#7 Post by Zizzo »

And in using this with my worm that walks, I tripped over another wrinkle: I sized the replacement candidate dialog on the assumption that there would be only two candidates, but the worm that walks can wear four rings. They're all still choosable using the up/down arrow keys, but that's less than ideal, so I fixed it in v1c.1, just pushed out, to adjust the dialog height according to the number of candidates. As always, We Apologize for the Inconvenience.™
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#8 Post by Zizzo »

I keep running into this problem… :? :wink: As with the golem and the worm that walks, the Annihilator's mecharachnid needs this dialog when swapping in new steamguns, so v1c.2 further expands the previous fixes to include it. I'd like for this to be extensible to addon-provided player sidekics like I did with Enhanced Object Compare, but there's no obvious place to put a list of sidekick fields for addons to hook into; I may add one later if I think of something.
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#9 Post by Zizzo »

Zizzo wrote:I'd like for this to be extensible to addon-provided player sidekics like I did with Enhanced Object Compare, but there's no obvious place to put a list of sidekick fields for addons to hook into; I may add one later if I think of something.
Okay, thought of something. :wink: Specifically, inspired by my recent changes to Enhanced Object Compare, v1d.1 now makes our replacement candidates dialog available for any party member, which should buy us any future sidekick added by DLC or addons for free.
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#10 Post by Zizzo »

Having added horizontal "ping-pong" scrolling to the attach-tinker dialog in Tinkers for Sidekicks, it occurred to me that the sae feature would be useful in this addon's "which wielded thing do you want to replace with the thing you're about to wield?" dialog. That's going out as v1d.2:
wield-pingpong.png
wield-pingpong.png (70.15 KiB) Viewed 5075 times
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#11 Post by Zizzo »

Just ran into a bug in the wield-replace candidates dialog: you're supposed to be able to <ctrl>-compare the object you're trying to wield with the replace candidates in the candidates dialog, but it turns out I was doing that wrong. :oops: That's fixed in v1d.3. We Apologize for the Error.™
"Blessed are the yeeks, for they shall inherit Arda..."

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

Re: [v1.3.0+] Enhanced Wield Replace

#12 Post by Zizzo »

Dabbling with a Mekurabe character from mannendake's Youkai Pack addon, which, among other things, can't wear cloaks. I tried wearing the Cloak of Deception anyway, just to see what happened, and was faced with an empty list of replace candidates, which is obviously suboptimal. v1d.4 catches that case now.

(Actually, it turns out that the base game doesn't handle that case too well, either; this release also adds a quick wrapper around ActorInventory:takeoffObject() to cover that.)
"Blessed are the yeeks, for they shall inherit Arda..."

Post Reply