Event on Carrying?

NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Locked
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Event on Carrying?

Post by Knight Captain »

Is there a similar Usecode event for when you pick something up and add it to the party's inventory? Similar to the equip/unequip for some items?
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by Knight Captain »

Event == 0x0008 is POLYMORPHED but it's not clear how/when that is triggered.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by marzo »

There is no 'on carrying' event, no. The polymorphed event is actually not used by Exult: the original SI did not save polymorph shapes on the save game, but only the polymorph flag, and executed the NPC's usecode with this event when the game was loaded to set the polymorph shape back. Exult just saves the polymorph shape instead.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by marzo »

Just something else: the polymorph event also wasn't known about for a long time after Exult had implemented it the way I described. It was only when I dumped all usecode with ucxt and went looking for unimplemented stuff which made me find this, and no one thought it was a good idea to replicate the original's behavior.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by Knight Captain »

That would seem to explain why de-polymorphing on death doesn't work.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by marzo »

No, it does not.

What does explain that is the completely stupid way that SI implemented polymorph: when an NPC is polymorphed, SI would overwrite the shape data in memory to that of the target shape; when you polymorph back it reloads the original shape data. Thus keeps the shape number, so when loooking for body shape (which was hard-coded in stock), it finds the stock body.

The downsides of this is that (1) the game needed to overwrite shape data when loading the save (thus the polymorph event hack) and (2) every single NPC that used the original shape is also effectively polymorphed.

You can test these by: (1) polymorph an NPC that does not have code for a polymorph event, saving and reloading, to see him revert back to original shape; (2) polymorph an NPC that does have a polymorph event, but polymorph him into a shape which is not used in said polymorph event, then save and reload; (3) polymorph (say) a pikeman and see that every other pikemen will also change shape.

All told, the way Exult handles this is superior in every way, except that it does not currently handle reverting back to the original body shape on death (but this is easily fixed, except I never heard of this until now).
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by Knight Captain »

It would be easy to test a fix. Start a new game and teleport to the Order Shrine antechamber.

The mod I'm working on sets the shape on the NPC and resets it via per-NPC Usecode but I haven't tested it in a while.
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by Knight Captain »

The reason I asked the original question was to see if I could create Usecode that would place all money in a specific money bag, perhaps similar to the keyring. It would also be handy for Serpent Teeth and reagents, and perhaps even spell scrolls, potions, etc. Work around the poor item management in other words.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by marzo »

The keyring is actually hard-coded; which is why I added the option of using it on the avatar to add all keys to it in BG Keyring.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: Event on Carrying?

Post by Knight Captain »

Hmm, an event == DOUBLECLICK on each money type might work.
Locked