TyburnKetch Posted July 7, 2020 Author Share Posted July 7, 2020 (edited) Ok.So I have added Locations to the exterior cells (the cell the triggerbox is in - and the parent cell of the interior I'm trying to get my npc to moveto if the player is in that interior). Every cell has a location and every parent cell has a location. Looking at location heirachy I have added RiftHold as the parent cell of my exterior cells, as that's where they are.IsInLocation does not fire still ... but interestingly nor does GetCurrentLocation.Something very odd going on here. On the CK wiki it does say to use IsInLocation for Actors, but still. Odd that nothing I've tried to call based around obtaining if the player is in a certain place (cell/location) is coming back with anything ... Update edit*Right. If I set the player location to be the same as the triggerboxs location then my npc moves to the interior cell. So IsInLocation is working, when the playerref is in the same location as the script. I have also tried it with the playerref being in the adjacent exterior cell (and location) and that also works! All locations and cells are custom.What is going on with my main interior cell!!? I have changed the parent cell to rifthold, I have added a map marker ref. Would having an encounter zone set for mannequins be an issue (although I don't see how as it is exactly the same set up as a noreset zone)? Would the fact I have got a giant triggerbox around my whole interior be an issue? That the cell has show sky ticked? (I am clutching at straws now)Something is stopping IsInLocation from firing when I am in my interior cell. Any advice of what that might be would be very appreciated. Edited July 8, 2020 by TyburnKetch Link to comment Share on other sites More sharing options...
ReDragon2013 Posted July 8, 2020 Share Posted July 8, 2020 maybe next is a new view to your issue tykPlayerAliasScript Scriptname tykPlayerAliasScript extends ReferenceAlias ; https://forums.nexusmods.com/index.php?/topic/8886138-isinlocation-papyrus-problem/page-2 GlobalVariable PROPERTY PlayerIsInTyburnHall auto ; new created globalVar with CK by YOU Location PROPERTY TyburnHall auto ; the location for observation ; -- EVENTs -- EVENT OnInit() Debug.Trace(" OnInit() - has been received for " +self) ; for debugging only ENDEVENT EVENT OnPlayerLoadGame() ENDEVENT EVENT OnLocationChange(Location akOldLoc, Location akNewLoc) IF (akNewLoc == TyburnHall) ; player is in specific location PlayerIsInTyburnHall.SetValue(1) ELSE ; player is somewhere else PlayerIsInTyburnHall.SetValue(0) ENDIF ENDEVENT tykJacksBalconyTriggerScript Scriptname tykJacksBalconyTriggerScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/8886138-isinlocation-papyrus-problem/page-2 ; Ishara: "the trigger volume box that the script is attached to is located in " ; Answer: "Basically I have a giant window in my player home and when my npc walks past the window, ; if the player is inside the interior (looking out of the window) I want my npc to move to the interior cell ; but outside the window. To look as though he is walking past on the outside." GlobalVariable PROPERTY PlayerIsInTyburnHall auto ; new created with CK by YOU ; Set a global variable to a specific value, ; use that global variable at that specific value as a condition in the NPCs trigger volume box. Quest PROPERTY myQuest auto ; the quest for player aliases Actor PROPERTY Jack auto ; the Actor we want to move ObjectReference PROPERTY JackMovingLocation auto ; the place jack should be, if player is in TyburnHall ; -- EVENTs -- EVENT OnInit() Debug.Trace(" OnInit() - has been received for " +self) ; for debugging only ENDEVENT EVENT OnTriggerEnter(ObjectReference akTriggerRef) IF (akTriggerRef == Jack as ObjectReference) myF_Action() ENDIF ENDEVENT ; -- FUNCTION -- ;-------------------- FUNCTION myF_Action() ;-------------------- IF (PlayerIsInTyburnHall.GetValue() == 1.0) PlayerIsInTyburnHall.SetValue(0) Jack.Disable() ; switch off Jack.MoveTo(JackMovingLocation) ; move him to target location Jack.Enable() ; switch on Utility.Wait(0.1) Jack.EvaluatePackage() ; reinit his AI package ENDIF ;;; self.Disable() ; switch off the trigger script, we do not need it anymore IF myQuest.IsStageDone(10) ; quest stage was already set ELSE myQuest.setStage(10) ; go on with quest ENDIF ;;; self.Delete() ; remove the triggerbox from game, as soon as possible ENDFUNCTION Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 8, 2020 Author Share Posted July 8, 2020 This is exactly the route I was about to start going down. Thank you very much for the time and effort to write such a complete script! Will update. Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 8, 2020 Author Share Posted July 8, 2020 (edited) Ok. So. Thank you again for the scripts above. I have to confess that I have not implemented them as they are however I have used the logic extensively. I have tried the GV route, and it is probably just me and my lack of experience with GVs but I could not get it to work. On their own anyway. But perhaps my issue was not that they did not work but my explanation below ... A simple quest stage approach has produced far better results for me, but I have tested this more thoroughly. After quite a lot of testing I think I have discovered my particular problem. No matter what logic I use, no matter where I place it (I have tried trigger boxes, doors) the only time I can get my NPC to acknowledge and trigger the script is when I, the player, am loaded in the same cell or an adjacent cell. As soon as I move into my interior cell the triggerbox does not fire. Which strikes me as the reason IsInLocation did not work. Or rather, it worked when I was in the same cell as the npc and the triggerbox, but as soon as I moved into my Interior cell the triggerbox script would not fire. Which leads me to believe that it is perhaps a persistence issue, which I have zero idea about. Has the triggerbox and script been unloaded when I enter my interior cell? It certainly feels like this. Like I say, using a simple setstage/getstage script combination works, but only if I, the player, am in the same cell as the npc triggerbox. I have run the console command getstage when in the interior cell and it is always the stage I would expect.(10) So. ActorAlias scripts. I guess I need to learn how this works as it could well be an answer. Or is there another route in making the triggerbox stay persistent when the player is in the interior cell? Slowly working it out. Thanks for all the help. Can not believe something so seemingly simple is such a pain in the **** Edit while researching and away from CK*So I stumbled on this: https://github.com/xanderdunn/skaar/wiki/Understanding-Forms,-Object-References,-Reference-Aliases,-and-Persistence Would I be able to make the triggerbox persistent this way? How? Would that make a difference? I have no knowledge of aliases at the moment. Edit* Have not had a chance to try this yet, but am I right in thinking that because the playeralias quest script for location change (above from ReDragon) gets mentioned/actioned in the triggerbox script that it will make the triggerbox persistent? Edited July 10, 2020 by TyburnKetch Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 9, 2020 Author Share Posted July 9, 2020 (edited) Right. So I have managed to do some more testing and now I am convinced my issue lies with the triggerbox. I have managed to add both scripts kindly offered by Redragon using both a Global Varibale and also adapting it to call quest stages instead for the quest that the playeralias is attached to. The script works for the playeralias. If I move in and out of my interior location my quest stages change as I would expect (so i presume that the global variable does too.) However, the script for my npc to move, placed on a triggerbox in the exterior cell does not work. Or rather, it does work If I adapt the alias script to be the opposite ...i.e. if the player is NOT in the interior, and adapt the triggerbox script accordingly. To test I removed the GV part of the npc move script ... so it is simply when the npc enters the trigger he moves to the target location. If I am in my interior the script simply does not fire. If I am in the exterior cell ... then yes. The npc moves to the interior cell. So it must be a problem with the triggerbox not being loaded. I have added a reference to the triggerbox in the quest alias for the player that I created, but I do not really know what i am doing with aliases so needless to say it has not made a difference. How would I go about keeping the triggerbox loaded and therefore allowing my npc to walk into it when I am in my interior? I am pretty sure my npc stays loaded. When I see him approaching the triggerbox I dart into my interior and when he should appear in the interior (never does) I go back outside and he has moved on past the window as his AI package dictates. Please do not give up on me people! It is driving me crazy but I am sure an answer can not be too hard to find ... Edited July 9, 2020 by TyburnKetch Link to comment Share on other sites More sharing options...
Evangela Posted July 9, 2020 Share Posted July 9, 2020 Uhm, are you sure PlayerRef is filled? Link to comment Share on other sites More sharing options...
Evangela Posted July 9, 2020 Share Posted July 9, 2020 (edited) edit: doubled Edited July 9, 2020 by Rasikko Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 9, 2020 Author Share Posted July 9, 2020 Ha. Always worth checking :) The scripts I am now using do not reference the player. But yes. When I was it was filled. I am using the scripts provided by ReDragon, give or take. Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 9, 2020 Author Share Posted July 9, 2020 (edited) Could .moveto be the problem? Am I right in thinking that .moveto will not move an object if that objects 3d has unloaded? Although this suggests that my npc has been unloaded even though he is still doing his AIpackage. Can that even happen without being 3d loaded?So if not my npc, would 3d loaded be an issue with the triggerbox? *Edit: So I am now looking at a player alias script for my npc. Putting a moveto function in a reference alias script has him move into the interior whilst I am in there (using the playeralias script to determine if the player is in the interior or not) Now I just need to find an event that works realistically. I have tried OnLocationhange for my npc script, and although it works, it is not really practical as the exterior cell covers a lot of his AI package (not just the bit in front of the window) The Window also, conveiniently bridges two exterior cells! If anyone has any suggestions or ideas, please feel free. The Triggerbox is most definately the issue I have been having. Looking at other ways to move my npc whilst the player is in the interior seems the logical step. Unless someone can suggest a way to make the triggerbox actually trigger when the cell is not loaded .... Edited July 9, 2020 by TyburnKetch Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 10, 2020 Author Share Posted July 10, 2020 In case anyone is interested I have decided to go the route of attaching everything relating to this to the player alias, calling on specific packages to determine when the npc is outside the window. It is a fair bit more work but will actually give me more control over the issue. So, long story short. IsInLocation was not the problem. The problem was that the trigger volume box was simply not around when the player moved to the interior cell. If I could work out a way to make it stick around I would (purely for knowledge) but doing it this new way is going to work well. Thanks for all the help with this one. Learning how to work with aliases has been good for me! Link to comment Share on other sites More sharing options...
Recommended Posts