OnLocationChange script not working

Post » Mon Jan 26, 2015 5:43 pm

I've got a script on a a player alias in a Start Game Enabled quest. The relevant part is the OnLocationChange. All properties are set, the alias is filled, and yet the global never changes:

Scriptname CYRBrumaMS04PlayerAliasScript extends ReferenceAlias  ReferenceAlias Property RenodLute Auto Location Property CYRCapstoneCaveLocation Auto Faction Property BanditsLikePlayer Auto Faction Property PlayerFaction Auto Location Property JerallViewInnLocation Auto GlobalVariable Property JerallViewEntered Auto{Number of times Jerall View has been entered, only counts to 2}Event OnInit()	AddInventoryEventFilter(RenodLute.GetReference())EndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	If akItemReference == RenodLute.GetReference()		GetOwningQuest().SetStage(140)	EndIf	EndEventEvent OnPlayerLoadGame()	(GetOwningQuest() as CYRBrumaMS04Script).Maintenance()EndEventEvent OnLocationChange(Location akOldLoc, Location akNewLoc)	If akNewLoc == CYRCapstoneCaveLocation		BanditsLikePlayer.SetEnemy(PlayerFaction)	ElseIf akNewLoc == JerallViewInnLocation && JerallViewEntered.Value != 2.0		JerallViewEntered.Mod(1.0)	EndIfEndEvent

I've tried debug.notifications just inside the event but they never fire.

User avatar
Jack
 
Posts: 3483
Joined: Sat Oct 20, 2007 8:08 am

Post » Mon Jan 26, 2015 12:33 pm

try this:

If ( akNewLoc == CYRCapstoneCaveLocation )

ElseIf ( ( akNewLoc == JerallViewInnLocation ) && ( JerallViewEntered.Value != 2.0 ) )

EndIf

edit: ...and apply same principle to rest of script too :-)

User avatar
phil walsh
 
Posts: 3317
Joined: Wed May 16, 2007 8:46 pm

Post » Mon Jan 26, 2015 6:29 pm

I... Do not know why that worked but it did. Thank you so much/

User avatar
Katy Hogben
 
Posts: 3457
Joined: Mon Oct 30, 2006 12:20 am

Post » Mon Jan 26, 2015 4:19 pm

I was actually just working on a similar problem this morning, only with NPC's. Apparently the OnLocationChange() does not play well with quest aliases, especially if they are filled with the Player. (With an NPC, it only fired for me when the actor moved into the same cell as the player, not when leaving it or otherwise changing cells).

I came across this solution that might work for you: creationkit . com / Detect_Player_Cell_Change_(Without_Polling) (I can't post links, so you'll have to fix the address)

I tried a few other things (putting triggers inside and outside of the doors in the cells I wanted to track, adding OnActivate() to the doors themselves -- this may work for a player character, but for NPCs the triggers and door OnActivate() didn't fire unless the player was in the same cell). I ended up using registerforsingleupdate() and checking the NPC every few seconds, which is not good practice, but since the quest was short and in an area without combat potential, I decided to take the easy route.

Edited to add: I see you found a solution. Odd that it worked when the event didn't previously fire for you, but much easier than the above!

User avatar
Cool Man Sam
 
Posts: 3392
Joined: Thu May 10, 2007 1:19 pm

Post » Mon Jan 26, 2015 12:41 pm

because the paranthesis make it unambigious what to == or && with what (just like "if MyVariable" alone is a valid statement already after all)

glad it worked anyway :-)

User avatar
Nina Mccormick
 
Posts: 3507
Joined: Mon Sep 18, 2006 5:38 pm


Return to V - Skyrim