Talk:Detect Player Cell Change (Without Polling)

There are no discussions on this page.

I've tried this method, and I gotta say it's awesome when combined with the modEvent functions.

Unfortunately, the one flaw I'm trying to overcome is not being able to detect whether the cell change implied a different load zone or not. I'm assuming that any change except between exterior cells always imply load zones (maybe somebody can confirm this for me?), but you need to go through a door and load when going to Whiterun as well, which is considered "exterior" too (and I suppose that it's the same with all towns).

I tried using a GetDistance() function between the two references, asumming that you'd get a weird result between unconnected places, and while this helps for the most part (since you get a number almost forty digits long if the cells are not adjacent), it doesn't work for those cities either, I suppose because they're also placed on top of the normal worldmap.

So, is there any way that I've missed that could be used to detect loading zones? I've been wondering if there's any hint, even if not too obvious: detecting if camera/player controls give any imput when loading, or if the loading screen art might trigger some event. I've been working with CK for not too long, so I'm sorry in advance if I missed that part.

--Darkitow (talk) 2015-01-17T13:58:50 (EST)

Confirmed: this doesn't seem to work entirely well for load screens. Here is a method that does. DavidJCobb (talk) 2015-07-20T05:33:15 (EDT)

The method is great, but for me the tracker always stopped working quite soon.

When the player enters a new cell, the magic effect is applied, the event triggered and the invisible object gets moved to the player cell as intended. However, when the player runs around, he sometimes crosses multiple cell borders a second, even when running straight in one direction. In this case the player leaves the new cell, before the condition 'object is not in player cell' is checked again a second later. The condition then continues to evaluate to true for all times - unless the player re-enters the cell with the invisible object by chance, which is unlikely because he doesn't get informed about the glitch and continues to run until finally realizing something isn't right. The effect never finishes and the OnEffectStart event doesn't get triggered any more.

So you need to add code to move the invisible object again, if the effect starts but doesn't finish in due time:

      Event OnEffectStart(Actor akTarget, Actor akCaster)
 
           RegisterForSingleUpdate(<couple of seconds, I took 7>)

	   <do fancy stuff>
           Utility.Wait(0.1) ;maybe not necessary
           invisibleObject.MoveTo(playerRef)
		
	EndEvent

	
	Event OnUpdate()
		
 	    invisibleObject.MoveTo(playerRef)
	    RegisterForSingleUpdate(<couple of seconds, I took 4>)
	
	EndEvent

Granson (talk) 2015-10-24T14:19:19 (EDT)


I think I've found an easier and lighter solution to solve the existing problems with the original method. From my testing this works perfectly, I haven't been able to outrun it. First follow the directions of the original posted method - I suggest using a copy of the XMarker object rather than an invisible fork to prevent any havok interaction. The only necessary addition is a script on the ObjectReference of the placed invisibleObject itself with the following content:

Scriptname StalkerObjRefScript Extends ObjectReference
 
 Actor Property PlayerREF Auto
 
 Event OnCellDetach()
  MoveTo(PlayerREF)
  Debug.Trace(Self + ": Tracker detected cell detach, moved to to cell " + GetParentCell())
 EndEvent

The original spell & script will handle the moving of the invisibleObject whenever the PC walks between connected cells, and the OnCellDetach event on the ObjectReference will handle the moving between loadscreen doors. This event will also make the object 'catch up' in case it gets stuck somehow so there is no need for an OnUpdate event, keeping it polling free.

The only problem I have found with this method is that occasionally both of the scripts will fire when going through a load door. Somewhat depending on what you are doing with the tracker, it's usually trivial to solve that by setting a script flag or keyword in whatever code or effect you plan to run. --BeamerMiasma (talk) 2016-08-14T21:08:23 (EDT)

Return to "Detect Player Cell Change (Without Polling)" page.