A quick question about event handlers (my god I only just noticed they exist! :facepalm: ):
Say I want to set certain eventhandler for every NPC in the loaded area.
1. Is it costly to set the same eventhandler on the NPC every, say, second, or should I keep track of who has been treated already?
2. Is the handlers ever auto-removed? i.e. should I be very careful to remove them from every NPC once the player leaves the cell*?
*can I even remove handlers from references that just got cleared from memory?
I would appreciate some "best practice" tips on this. In essense I′m about to upgrade DR′s elemental magic effects so that any NPC that get hit by a certain magic effect can get treated by the special effects, without the need for "getcrosshairref" target acquiring and other "hit approximations".
So the question is how elegant a system I need to build to tag all NPCs in the memory with "onmagiceffecthit" handlers?
1. Not really. The code will notice the handler has already been registered and do nothing.
2. No, a handler isn't removed unless you explicitly remove it via script.
Best practice:
If you're only interested in an event affecting one or two specific actors/references, register an event handler for the specific refr(s).
If (as in this case) you are interested events affecting a larger number of actors/refrs, register a generic handler without specifying the refr. In your handler filter out refrs you're not interested in if necessary.
If you're too specific and register a large number of handlers for a particular event, than every time such an event occurs OBSE needs to check against each registered handler to determine if it should be invoked.
If on the other hand you're too generic and register a single handler or small number of handlers for a particular event, when you're not interested in the majority of those events, then OBSE has to create and execute your handler script for every event.
So the question is: of all the events of a specific type which are likely to occur, what percentage of them do you expect to be interested in processing? If it's a large percentage, use a generic handler. Small percentage, use one or more handlers for specific reference(s).
In this case it sounds like you're interested in OnMGEFHit events affecting any actor in the currently loaded area, which is pretty much what you'll get with a generic handler. You shouldn't need to explicitly target any actors.
Bad news, I'm afraid. Sorry for not catching this sooner, but it seems there's a bug in v19 that wasn't present in v18 to do with reading string input. I think this is the relevant script (not mine, so I'm not really sure about it):
[snip]
Is there any reason why this should stop working in v19?
At first glance, no. What's not working - GetInputText is returning an empty string? Was this reported elsewhere before you posted it here?
On second thought, that messes up when there are parameters following the formatString.
In this case, after adding two integer parameters the first is always clipped and somehow used by the initial (normal) string parameter.
Can I see the ParamInfo for the command in question?