glowplug Posted July 29, 2016 Share Posted July 29, 2016 Having played around with the SetEventHandler examples in OBSE documentation I think I have got the general idea.I am seeing...Specific actor raising event for any actorAny actor raising event for any actor (when object:Reference is omitted from of example)...but not specific actor only raising event on another specified actor. The logical solution seems to be to test the primary arguement but I'm not sure what I'm doing wrong... scn triggerPlayerArrivalScript ;maybe make triggerPlayerArrival persistent reference? int iDoOnce ref refPlayerClone begin onTrigger playerRef if iDoOnce == 0 let iDoOnce := 1 let refPlayerClone := playerRef.createFullActorCopy call fnPositionWithinCell refPlayerClone, 0, 0, 0, 180 ;ref, xPos, yPos, zPos, zAngle refPlayerClone.addScriptPackage pkgUseChairAndEat refPlayerClone.evaluatePackage setEventHandler "OnActivate" fnMyOnActivateHandler object::PlayerRef endif end scn fnMyOnActivateHandler ref refActivated ref refActivator begin function { refActivated, refActivator } ;if refActivator.getName == ?? ;or if triggerPlayerArrival.refPlayerClone == refActivated ;or do all of this another way if whatever refActivated.look refActivator return ;will this bypass dialogue in an event handler?? else activate ;is this actually required? endif end ...so far I get no printc and the clone won't shut up. Link to comment Share on other sites More sharing options...
Surilindur Posted July 29, 2016 Share Posted July 29, 2016 (edited) Maybe I could check that a little later, when I get to my gaming PC. The OBSE Command Documentation says it should be possible to set both the activator and the activated ref when registering an event handler. Have you tried setting the thing like: let refPlayerClone := playerRef.createFullActorCopy SetEventHandler "OnActivate" fnMyOnActivateHandler "ref"::refPlayerClone "object"::PlayerRefAnd removing the handler before/when the copy dies and/or is removed? Or was that the one which did not work? Does it require a persistent ref? Also, I cannot remember if the quotation marks were necessary... maybe not. Tiny tip for comparing stuff: if you apply the OBSE/CSE compiler override thingy, you should be able to compare strings with the normal "==" operator, which you might have done, but I am not sure, the commented out part is unfinished. Adding an underscore before the script block name applies the override (you might need to check the CSE script editor settings, too, but I do not remember). Something like this: ref A ref B Begin _Function { A, B } MessageBoxEX "A: %n%rB: %n" A B If Eval ( ( A.GetName ) == ( B.GetName ) ) MessageBox "Refs have the same name" EndIf EndBut that could be completely off. I need to check if any of that compiles when I get to the desktop... so if none of that works, worry not, it is me suggesting stuff before checking if it works. I call it "throwing ideas around"... :whistling: Edited July 29, 2016 by Contrathetix Link to comment Share on other sites More sharing options...
glowplug Posted July 29, 2016 Author Share Posted July 29, 2016 Thank you, I must have done something wrong when I tried ref + object on the set handler - I did not know about the override and forgot about Eval.I should be right now but will post in due course either way Link to comment Share on other sites More sharing options...
glowplug Posted July 29, 2016 Author Share Posted July 29, 2016 I've since noticed that you use quotes on the ref and object filters.OBSE documentation does not outline this - why not?? In fact, I have found quite a number of head bangers with OBSE documentation. If required, I would be more than happy to do a graphic tutorial based OBSE for Modders - something like Blender Noob to Pro.Exercises with Know Steps for Known Outcomes so that if the user screws up they soon realise and can quickly back track.Something like my Blender to Oblivion but I can do better than that. Link to comment Share on other sites More sharing options...
forli Posted July 29, 2016 Share Posted July 29, 2016 (edited) return ;will this bypass dialogue in an event handler?? else activate ;is this actually required? Nope. OnActivate event handler doesn't prevent the object activation like the Begin OnActivate block, so the object will be activated anyway.For the same reason, activate in the OnActivate event handler will cause the object to be activated one more time, which cause the event handler to fire again, in an endless "recursive" call (until the Oblivion stack explode with a CTD). Quotes around "ref" and "object" filter are not required. The compiler thread them as strings anyway (if you don't put quotes the compiler may show a warning, but the script will works exactly the same). About this: If Eval ( ( A.GetName ) == ( B.GetName ) ) MessageBox "Refs have the same name" EndIf You could just use CompareNames If Eval (A.CompareNames B) == 0 MessageBox "Refs have the same name" EndIfBut if you need to compare two references, you could just do: If A == B Edited July 29, 2016 by forli Link to comment Share on other sites More sharing options...
glowplug Posted July 30, 2016 Author Share Posted July 30, 2016 Thanks for the support from both of you.While it looks like I can not stop a player clone from using dialogue I've certainly learnt useful information from both of you. It was for a mood affect as part of the player feeling 'pulled outside of time'. I'll simply find another way. There are some other places where I should have used an event handler but got lazy - I can solve these now thanks to you both. Link to comment Share on other sites More sharing options...
forli Posted July 30, 2016 Share Posted July 30, 2016 Oh, one more tip:Event handlers are not linked to savegame but to the game session, and they can be registered multiple times, which means:they are not saved in the savegame, so you need to register all event handlers you need again when the savegame is loaded.they are not destroyed between loading, so if you load a savegame, create some handlers, then reload the same or another savegame, it will maintain all event handlers registered.they are only destroyed when you close the game (exit to desktop) or when you use the command RemoveEventHandler.you can't overwrite an event handler, so the same event handler can be registered multiple times: if you register it two times (same event, same function, same filters), then the event will call the function twice; if you register it three times, then the event will call the function three times, and so on...So, when you register an event handler, you need to ensure the event handler is not already register. How to ensure this? There's no command "IsEventhHandlerRegistered", but you can use RemoveEventHandler to erase any previously registered handler (it's safe to use even if there's no event handler registered). Link to comment Share on other sites More sharing options...
glowplug Posted July 30, 2016 Author Share Posted July 30, 2016 Thanks for that, I did not know this. I obviously can not use if GetGameRestarted so will have to call RemoveEventHandler - as you say. The solution at this stage is binding an OnActivate event handler then set the clone unconscious.The event handler... scn kvFnOnActivateDuga02Clone ref refClone ref refPlayer begin function { refClone, refPlayer } messageEx "Has %n turned zombie or...", refPlayer, 3 end The clone is staring at a very rotten and half eaten corpse in a coffin with the name of...PlayerName...which is also emitting some rather disturbing sounds. The other things I'd like to do are...Leading up to that section, occasional screen shake and weird noise to seem like stabbing head pain. I can unequip all items ok but do not want to leave the clone naked. I'm trying to find zombie clothing, armor or race if anyone knows of such a mod. Link to comment Share on other sites More sharing options...
Surilindur Posted July 30, 2016 Share Posted July 30, 2016 Thank you, forli. That was quite informative for myself, too. I was wondering why some events were registering multiple times, and it seems I have forgotten to unregister upon loading a savegame. Time for me to update some mods, then. Thank you. :thumbsup: As for the issue of glowplug, I have been quite busy with a course assignment, I need to finish it by tomorrow, and I ran into a variety of issues today again. But if that info was enough, that is great. Maybe I can concentrate more on modding stuff next week if not tomorrow already. :( As forli said, the quotation marks around ref and object are not necessary, but they helped dispose of the compiler errors, so they do no harm, either. Link to comment Share on other sites More sharing options...
forli Posted July 30, 2016 Share Posted July 30, 2016 (edited) Well, GetGameRestarted is very useful, if used in a MenuMode 1044 Begin MenuMode 1044 If GetGameRestarted SetEventHandler "PostLoadGame" fnLoadGame ;the load game handler. A must for every mod ... ;you can set some event handler there. They will be registered only once EndIf EndThis block will run as soon as you reach the main menu and will register the event handlers you need.Using the "PostLoadGame" is faster than the "GetGameLoaded" check, because the event handler is not a check you do every frame (obviously!) and because it will fire just a while before entering GameMode (in the last seconds of the load screen), so it will surely runs before all GameMode blocks (so, everything is already initialized and ready when they run the first time). Little problem: as of OBSE v21, "PostLoadGame" seems to misfire for some Steam users. It has been reported and it's in the TODO list of OBSE v22. .The compiler thread them as strings anywayDamn! 2016 and I still confuse "treat", "threat" and "thread". Even if english is not my native language, this is unacceptable!!Ok, be right back after 3-4 seppuku... Edited July 30, 2016 by forli Link to comment Share on other sites More sharing options...
Recommended Posts