Detect Player Cell Change (Without Polling)
Revision as of 09:02, 25 April 2014 by imported>Egocarib (added category)
A method to track every cell change the player makes, including cell changes in open wilderness cells.
- Make a new object in the CK. I made a MiscObject based on BasicFork, though I am thinking something static (without any havok) would be even better. Make sure your object is small and give it an invisible texture (Edit the Model path and change all entries to NullTextureSet). Uncheck the playable flag.
- Place your object somewhere in the world. Doesn't matter where, it just needs to have a specific reference that we can access later when we set up our condition.
- Set up a new Magic Effect in the CK: Script -- Constant Effect -- Self -- Hide in UI
- Attach this script to your new magic effect, and makes sure to fill both properties:
Scriptname TrackInSameCell extends ActiveMagicEffect
{ability that will be activated when player is not in the same cell as invisibleObject}
Actor property playerRef auto
ObjectReference property invisibleObject auto
Event OnEffectStart(Actor akTarget, Actor akCaster)
debug.notification("player changed cells")
Utility.Wait(0.1) ;maybe not necessary
invisibleObject.MoveTo(playerRef)
EndEvent
- Now make a new spell: Ability -- Constant Effect -- Self
- Add your scripted magic effect as an entry to the spell.
- Now add a condition to your spell entry, it should look like this:
- Your object should be the reference chosen in the condition.
- Add your new ability to the player, probably the easiest way is through a reference alias (that's what I did)
Now head in game and test it out, you'll notice that you see the debug every time the player changes cells anywhere. The nice thing is this is very resource friendly, and it doesn't require any sort of polling.