How to use OnCellAttach

Post » Sat Aug 10, 2013 9:51 am

Hi,

I wish to spread certain scripts across the actors located in the cell the player is in.

So far I've been using the code below:

Event OnCellLoad()	Cell MyCell = PlayerRef.GetParentCell()		Int iIndex = MyCell.GetNumRefs(0x3E) 	While iIndex > 0		Actor Target = (MyCell.GetNthRef(iIndex, 0x3E) as actor)		iIndex -= 1		Target.AddSpell(aaTestSpell)   	EndWhileEndEventActor Property PlayerRef AutoSpell Property aaTestSpell Auto 

This code is good but it has at least one important limitation: the event OnCellLoad() seems to only fire when entering new cells is preceded by a loading screen. This makes this script useless for exteriors, where new cells can be entered without the need of loading screens.

In the creation wiki I found an event called:

OnCellAttach()

In the discussion page somebody speculates that this event triggers " every time the player enters the cell from another cell". So it seems I could use this event to solve the problems my code is experiencing in exteriors. Can anybody familiar with the event explain how would I go to accomplish that?

Thanks in advance.

User avatar
Mrs. Patton
 
Posts: 3418
Joined: Fri Jan 26, 2007 8:00 am

Return to V - Skyrim