WhiteWolf424242 Posted December 15, 2020 Share Posted December 15, 2020 (edited) Hello, Unfortunately I'm not very familiar with how Load and Unload events work, so I might need some help.Here's what I'd like to do:The player and an Actor are together in an interior cell. A quest is moved to a stage.I'd like then to have an event that fires when either the player or the Actor move out of this cell (so they are no longer in the same cell and can no longer see each other).The quest stage is unique and thus can be used to filter on. The Actor and the Player are in quest aliases, and the script can be attached to those. I tried the following: Scriptname WW42FailedWeddingCleanupScript extends ReferenceAlias Quest Property WW42WeddingDress Auto Event OnDetachedFromCell() If(WW42WeddingDress.GetStage() == 25) ; stuff that should happen endif EndEvent But this plainly doesn't do anything. It doesn't matter if the player moves out of the cell or the npc, nothing happens.What would be the correct event to use here? EDIT:Seems to work with OnLocationChange(Location akOldLoc, Location akNewLoc), so I guess it's solved ^^ I should google first, only post second. Edited December 16, 2020 by WhiteWolf424242 Link to comment Share on other sites More sharing options...
maxarturo Posted December 16, 2020 Share Posted December 16, 2020 (edited) You should do something like this: Event OnDetachedFromCell() If ( ActorA.GetParentCell() != ActorPLAYER.GetParentCell() ) && ( ActorPLAYER.IsInInterior() ) If ( ActorA.IsInInterior() ) && ( ActorPLAYER.IsInInterior() ) ; Do Your Stuff EndIf EndIf EndEvent * "IsInInterior()" is optional, it surves as a "Fail Safe" so that this event won't fire in an exterior cell / world space. Edited December 16, 2020 by maxarturo Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted December 16, 2020 Author Share Posted December 16, 2020 Hmm, when I used OnDetachedFromCell() in the OP's first code, with just the quest stage condition (which was set there properly), it didn't work like at all. I don't see how adding more conditions to it would help. Also, does a city count as an interior? I doubt it, so then the even wouldn't fire when the player leaves the interior and enters the city. So I think the IsInInterior condition breaks the goal of the event. But it works now well with the OnLocationChange event. Is there a reason why I shouldn't use it and should use something else instead? I've read the some of these load/unload type events are more reliable than others so maybe there's something I should be aware of? Link to comment Share on other sites More sharing options...
maxarturo Posted December 16, 2020 Share Posted December 16, 2020 (edited) You posted that: "The player and an Actor are together in an interior cell. A quest is moved to a stage. I'd like then to have an event that fires when either the player or the Actor move out of this cell" "Also, does a city count as an interior?" No. "OnLocationChange" is used for exterior cells. "OnCellDetached - Attached" have all the same issue: * This event will NOT fire in the first cell(s) loaded while loading from a save game. "OnLoad" has the issue that it will never fire on Player Alias script Unfortunately, some things needs to be accurate in order for your script to do what you want. Anyway, i have a fully functional script that checks for either, if the Player and the Actor are in the same interior cell or exterior cell, and it goes like this: If ( Self.GetParentCell() == ActorPlayer.GetParentCell() ) && ( Self.IsInInterior() ) GoToTelePlayer() ElseIf ( Self.IsInInterior() == False ) GoToTelePlayerEx() EndIf * Further checks for cells are done in every 'Function'. Edited December 16, 2020 by maxarturo Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted December 16, 2020 Author Share Posted December 16, 2020 (edited) Okay, my terminology may not be very well defined (cell, location, etc.), and maybe I use them too interchangeably, sorry for that :sad: (But then again, the wiki doesn't go into great detail about accurately defining what is what)To be absolutely specific for my case:The player and the Actor are in the Temple of Mara. I'd like to hook up the event for when either of them walk out the door. OnLocationChange worked on the player alias when I walked out the door and loaded into Riften.There is this warning in the wiki though: "Keep in mind that Locations can be large groups of multiple cells, sometimes including numerous interior and exterior cells. As a result, this event may not be ideal for use as a general purpose cell movement tracker. Try OnCellLoad or OnCellAttach instead."This makes me wary, but since I don't need the event to fire multiple times, just the first time someone walks out of the Temple of Mara, and that seems to work, maybe I can get away with it? Although it would still be useful to learn how to do a proper cell tracking event. :smile: But when I tried just this on the player alias: Event OnDetachedFromCell() If( just a quest condition that was TRUE - I checked in the console) ; stuff that should happen endif EndEvent "Stuff" didn't happen when I walked out the door. Edited December 16, 2020 by WhiteWolf424242 Link to comment Share on other sites More sharing options...
Evangela Posted December 16, 2020 Share Posted December 16, 2020 You are right to feel wary, for locations can be vast, or they can be a single cell. If you expect this to work in interiors, the location must be set to the interior only and not any exteriors, or it will fire as soon as you get the cell that holds the entrance/map marker. Thus this isn't reliable for vanilla locations. Link to comment Share on other sites More sharing options...
RichWebster Posted December 16, 2020 Share Posted December 16, 2020 You could make use of the condition function GetInSameCell, and adapt the method described in this tutorial: https://www.creationkit.com/index.php?title=Detect_Player_Cell_Change_(Without_Polling) Link to comment Share on other sites More sharing options...
maxarturo Posted December 16, 2020 Share Posted December 16, 2020 (edited) What you want to achieve is very simple since your scene is 'Pre-Fixed' and it can be done with multiple ways, but in this case i would recommend the simplest one. Put the "Load Door" on an alias and then check for the actor that activates it, example: Event OnActivate(ObjectReference akActionRef) If ( akActionRef == ActorA ) DoMyStuff() ElseIf ( akActionRef == ActorPLAYER ) DoMyStuff() EndIf EndEvent Function DoMyStuff() ; My Stuff Endfunction "Although it would still be useful to learn how to do a proper cell tracking event." There isn't one proper way to do this, but it always depends on what you are trying to achieve. * Always the simplest produces the marvelous... I hope it helps. Edited December 16, 2020 by maxarturo Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted December 16, 2020 Author Share Posted December 16, 2020 (edited) Thanks for the hints, this is super useful :smile: There isn't one proper way to do this, but it always depends on what you are trying to achieve.I agree. And for this case, I'll probably stick to the OnLocationChange way.Using the door as an activator makes it too specific - IIRC the Temple of Mara has two doors, one main entrance and one in the basement, and this would then be incompatible with mods that let the player fast travel from interiors (which is something I also use), or otherwise create ways to exit without using a door.I checked in the CK - the Temple Of Mara is actually it's own Location. So for this specific example, I think the OnLocationChange is the most reliable, because no matter how the player or the actor exit this place, this will always trigger (and it's worked perfectly with my tests). Thanks everyone :smile: Edited December 16, 2020 by WhiteWolf424242 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 19, 2020 Share Posted December 19, 2020 (edited) ; -- initialization -- EVENT OnInit() ; it runs once on new game (or saved game if first time ingame) ; all properties and script variables has been loaded and properly assigned ENDEVENT EVENT OnPlayerLoadGame() ; runs only for player ReferenceAlias script every time a game has been loaded ENDEVENT; -- location change --A location can be named by CK, that means location is valid.It is also possible a location is NONE, that means this location may exist but is not valid to use for functions. EVENT OnLocationChange(Location akOldLoc, Location akNewLoc) ; this event may run more than once within a second, because an actor cross the border of locations IF ( akNewLoc ) ; (akNewLoc == None) ELSE RETURN ; - STOP - akNewLoc is NONE ENDIF ;--------------------- ENDEVENT; -- parent cell system -- will not called for playeralias scripts EVENT OnCellAttach() ; object in this cell has been attached to "players parent cell" ENDEVENT EVENT OnCellDetach() ; object in this cell has been detached from "players parent cell" ENDEVENT EVENT OnAttachedToCell() ; normally an actor goes into "players parent cell" ENDEVENT EVENT OnDetachedFromCell() ; almost only actors left "players parent cell" ENDEVENT; -- 3d load system -- EVENT OnReset() ; resets the whole cell (from object ..) in case this cell has reset area ; https://www.creationkit.com/index.php?title=OnReset_-_ObjectReference ENDEVENT EVENT OnLoad() ; a single object got 3D loaded at time ENDEVENT EVENT OnCellLoad() ; all objects in a cell got 3D loaded (from object that script is attached) ; "only this event is called within playeralias scripts" ENDEVENT EVENT OnUnLoad() ; a single object lost 3D for whatever reason ENDEVENT ; -- the trigger system -- https://www.creationkit.com/index.php?title=OnTriggerEnter_-_ObjectReference EVENT OnTrigger(ObjectReference akActionRef) ; Caution: this event will be sent every so often, while a Ref is/stays inside the trigger box. ENDEVENT EVENT OnTriggerEnter(ObjectReference akActionRef) ENDEVENT EVENT OnTriggerLeave(ObjectReference akActionRef) ENDEVENT Edited December 19, 2020 by ReDragon2013 Link to comment Share on other sites More sharing options...
Recommended Posts