ToME: the Tales of Maj'Eyal

[v1.3.0+] Enhanced Wield Replace
Page 1 of 1

Author:  Zizzo [ Tue May 20, 2014 3:57 am ]
Post subject:  [v1.3.0+] Enhanced Wield Replace

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: [3.92 KiB]
Downloaded 171 times

Author:  Zizzo [ Sun May 17, 2015 3:13 am ]
Post subject:  Re: [v1.3.0+] Enhanced Wield Replace

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:]
    doWear() [overloaded, to produce the candidates popup list as needed]
    wearObject() [overloaded, to allow adding the object into a specific inventory position]
    init() [to suppress on_select() tooltips if the candidates popup is up]

Author:  Zizzo [ Tue Jan 26, 2016 12:06 am ]
Post subject:  Re: [v1.3.0+] Enhanced Wield Replace

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:

Author:  Zizzo [ Tue Feb 02, 2016 3:41 am ]
Post subject:  Re: [v1.3.0+] Enhanced Wield Replace

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.

Author:  Zizzo [ Sat Jun 25, 2016 1:52 am ]
Post subject:  Re: [v1.3.0+] Enhanced Wield Replace

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:

Author:  Zizzo [ Mon Jun 11, 2018 1:05 am ]
Post subject:  Re: [v1.3.0+] Enhanced Wield Replace

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.

Author:  Zizzo [ Thu Jul 19, 2018 2:25 am ]
Post subject:  Re: [v1.3.0+] Enhanced Wield Replace

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.™

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group