EagleFour Posted November 26 Share Posted November 26 In my mod NPC Outfit Changer, the player and NPCs change outfit when the OnLocationChange event is triggered. This also worked perfectly until 1.14.70. Now I have accidentally noticed that this no longer works on Mars when entering Cydonia (airlock). The OnLocationChange event is no longer triggered for the player, but is still triggered for the NPCs. Very annoying, as I now have to rebuild the mod and consider less elegant solutions. I noticed this in Cydonia, whether other locations are affected I can't say yet. Link to comment Share on other sites More sharing options...
SKKmods Posted November 26 Share Posted November 26 The Starfield event system is, like a bunch of other engine functions, rather ... janky. e.g. Outpost built objects don't trigger event OnUnload(), but the outpost itself does. Trust no one event. Link to comment Share on other sites More sharing options...
LarannKiar Posted November 26 Share Posted November 26 2 hours ago, SKKmods said: The Starfield event system is, like a bunch of other engine functions, rather ... janky. e.g. Outpost built objects don't trigger event OnUnload(), but the outpost itself does. Trust no one event. Could you be a bit more specific when the event is not sent? If attached to the reference? Or the event registration is dropped? I built a Mannequin (base FormID: 10DAEF), called [ CQF QuestID RegisterForOnUnload RefID ] and received the Debug.MessageBox after I fast traveled from the Outpost. Tried it with Display Case (base FormID: 355B15) and event was sent. Scriptname onunloadfix extends Quest Const Function RegisterForOnUnload(ObjectReference ref) RegisterForRemoteEvent(ref, "OnUnload") EndFunction Function UnregisterForOnUnload(ObjectReference ref) UnregisterForRemoteEvent(ref, "OnUnload") EndFunction Function Unregister() UnregisterForAllEvents() EndFunction Event ObjectReference.OnUnload(ObjectReference akRef) Debug.MessageBox("OnUnload: " + Utility.IntToHex(akRef.GetFormID())) EndEvent Link to comment Share on other sites More sharing options...
LarannKiar Posted November 26 Share Posted November 26 6 hours ago, EagleFour said: In my mod NPC Outfit Changer, the player and NPCs change outfit when the OnLocationChange event is triggered. This also worked perfectly until 1.14.70. Now I have accidentally noticed that this no longer works on Mars when entering Cydonia (airlock). The OnLocationChange event is no longer triggered for the player, but is still triggered for the NPCs. Very annoying, as I now have to rebuild the mod and consider less elegant solutions. I noticed this in Cydonia, whether other locations are affected I can't say yet. Interesting.. I can't remember if it worked earlier but it might have now that you mention it.. (We shouldn't receive OnLocationChange though when entering the interior as the exterior is in Cydonia too. Maybe BGS fixed it). I answered your question about BSInputEvent from Cassiopeia not long ago so if dependency isn't an issue you can use ActorCellChangeEvent instead. Note: the native code actually sends two events (when the player leaves akPreviousCell and when enters akCurrentCell; originally, when I used this native event only in SFSE plugins it was sent once as far as I remember). I didn't want to change this behavior so you may need to filter the cells too. Function RegisterForPlayerCellChange() Form[] akFilter = new Form[0] akFilter.Add(Game.GetPlayer()) CassiopeiaPapyrusExtender.RegisterForNativeEvent("onunloadfix", "ActorCellChangeEvent", akFilter) EndFunction Function ActorCellChangeEvent(Actor akActor, Cell akPreviousCell, Cell akCurrentCell) Global Debug.MessageBox("ActorCellChangeEvent: " + Utility.IntToHex(akActor.GetFormID()) + " | " + CassiopeiaPapyrusExtender.GetTESFullName(akPreviousCell) + " | " + CassiopeiaPapyrusExtender.GetTESFullName(akCurrentCell)) EndFunction Link to comment Share on other sites More sharing options...
SKKmods Posted November 26 Share Posted November 26 @LarannKiar full defect report here (submitted to BSG via the VC programme, zero followup). https://www.nexusmods.com/starfield/articles/338 Link to comment Share on other sites More sharing options...
LarannKiar Posted November 26 Share Posted November 26 1 hour ago, SKKmods said: @LarannKiar full defect report here (submitted to BSG via the VC programme, zero followup). https://www.nexusmods.com/starfield/articles/338 I see, thanks for the article. I remember I read it last year but I had to reread it . I checked the event handlers in the native code and both OnLoad and OnUnload are called from the same function. BGS wanted to restrict what references can send the event and for some reason a function used to filter the references looks for WorkshopItemKeyword linkage too. I wrote a quick fix, I'm currently testing it.. (OnUnload works but I'll need to make sure other vanilla restrictions don't break). Link to comment Share on other sites More sharing options...
EagleFour Posted November 26 Author Share Posted November 26 @LarannKiar It definitely worked before 1.14.74. I had also thought at first that it was the same location and Beth had corrected that. But why do the NPCs trigger, they shouldn't trigger then either? Nah, I think that's a bug. And with all locations tested so far, a LocationChange event was triggered when a loading screen appeared. But I'll keep an eye on this to see if it occurs with other LocationChange events where the location doesn't change. 5 hours ago, LarannKiar said: Interesting.. I can't remember if it worked earlier but it might have now that you mention it.. (We shouldn't receive OnLocationChange though when entering the interior as the exterior is in Cydonia too. Maybe BGS fixed it). I answered your question about BSInputEvent from Cassiopeia not long ago so if dependency isn't an issue you can use ActorCellChangeEvent instead. Note: the native code actually sends two events (when the player leaves akPreviousCell and when enters akCurrentCell; originally, when I used this native event only in SFSE plugins it was sent once as far as I remember). I didn't want to change this behavior so you may need to filter the cells too. Reveal hidden contents Function RegisterForPlayerCellChange() Form[] akFilter = new Form[0] akFilter.Add(Game.GetPlayer()) CassiopeiaPapyrusExtender.RegisterForNativeEvent("onunloadfix", "ActorCellChangeEvent", akFilter) EndFunction Function ActorCellChangeEvent(Actor akActor, Cell akPreviousCell, Cell akCurrentCell) Global Debug.MessageBox("ActorCellChangeEvent: " + Utility.IntToHex(akActor.GetFormID()) + " | " + CassiopeiaPapyrusExtender.GetTESFullName(akPreviousCell) + " | " + CassiopeiaPapyrusExtender.GetTESFullName(akCurrentCell)) EndFunction ActorCellChangeEvent is a very good idea. However, I have been trying to trigger an event for over an hour now. It does not work. ActorCellChangeEvent is a very good idea. I can fix it with that. Thanks also for the code. I'll add it to the mod tomorrow. (By the way, I've already installed trigger boxes in the meantime, they work too, but they have disadvantages that I don't find so good) I wrote something about the BSInput issue, maybe you could take another look at it. At the moment I'm using V2.3, where the L-Shift key works. Link to comment Share on other sites More sharing options...
Recommended Posts