NWN1 Platinum/Diamond, plus CEP, in single-player mode.
I have some placeables that interact, and I’ve been trying to use user-defined events to have them communicate. Two examples:
- Secret doors (placeables): when one is opened, the matching one is opened as well. (Or closed.)
- A door and a lever. When the lever is toggled, the door should open and close accordingly. And contrariwise; when the door opens or closes, the lever should be moved to match.
- A secret door that can be opened, used, or closed – rather than just opened (once) or used.
So I have a single script for OnUserDefined that knows how to do these things, run the appropriate animations, and set the appropriate variables.
When I had unique scripts for each of the items and hard-coded the related tags, it worked fine. My first foray into trying to do it with signals works thus:
- A test secret door placeable (with no matching other end) has a unique OnUsed script. If the door is closed, the script calls SignalEvent(OBJECT_SELF) to open the door. The UDE handler plays the appropriate animation. If the door is already open, ActionStartConversation() is called so the player has a choice between using the door and closing it.
All of the changes made to the door are done through its action queue, with Action* and AssignCommand() calls.
What happens, however, is that when the door is opened through the UDE handler, either from the OnUsed script (by clicking on the door) or signaled from a lever, the visual is of the door opening and then quivering. Nor does clicking on the door do anything once it’s open (which is when the OnUsed script calls ActionStartConversation() – and it does get called, I’ve checked), although the open/close signals sent by toggling the lever work, and the door can be re-closed that way.
{Ramble, ramble; it’s late, I’m sorry}
The first thing that came to mind was some sort of threading conflict, such as immediate versus queued actions. E.g., the UDE handler script was still blocking other actions. I think I’ve ruled that out by putting everything into the placeable’s action queue. Also, if the placeable had been set uncommandable somehow, the lever wouldn’t be able to cause it to change state by sending it an event.
Is there some sort of interaction I’m missing? Some list of things that shouldn’t be done in OnUserDefined scripts in conjunction with others? I’ve instrumented the crap out of the scripts to log client messages, and I can’t figure it out. Everything looks like it’s working – but once the door-open animation is played, the door’s OnUsed script can’t be invoked.
Thanks for any ideas!