Difference between revisions of "Talk:Detect Player Cell Change (Without Polling)"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>DavidJCobb
m (i found a thing)
imported>Granson
Line 10: Line 10:


:Confirmed: this doesn't seem to work entirely well for load screens. [[Talk:IsPlayerMovingIntoNewSpace#Exact methodologies|Here is a method that does.]] [[User:DavidJCobb|DavidJCobb]] ([[User talk:DavidJCobb|talk]]) 2015-07-20T05:33:15 (EDT)
:Confirmed: this doesn't seem to work entirely well for load screens. [[Talk:IsPlayerMovingIntoNewSpace#Exact methodologies|Here is a method that does.]] [[User:DavidJCobb|DavidJCobb]] ([[User talk: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
[[User:Granson|Granson]] ([[User talk:Granson|talk]]) 2015-10-24T14:19:19 (EDT)

Revision as of 13:19, 24 October 2015

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)