PositionCell possible in local script?

Post » Fri Nov 18, 2011 8:01 am

I've been getting very frustrated over a script that I've been trying to pull off lately. It's a local script on an NPC that tries to position this NPC and another NPC into a different cell after a global variable is met. My question is: Can PositioncCell only work in global scripts? If not, should it be written differently in local scripts? Here's a snippet of the script that matters.


Begin ik_Ildran2Script

short nolore
short tripstate
short tripdone
short doOnce
;global ik_slaversenablestate
;global ik_hiddendooropen

if ( ik_slaversenablestate == 1 )
Enable
elseif ( ik_slaversenablestate == 3 )
Enable
else
Disable
endif

if ( ik_slaversenablestate == 2 )
if ( doOnce == 0 )
"ik_ildran_tistar2"->PositionCell 0, -192 -128 0 "Firemoth, Guard Quarters"
"ik_aendelin2"->PositionCell 0 -256 -128 0 "Firemoth, Guard Quarters"
Set tripstate to 0
Set tripdone to 0
Set doOnce to 1
return
endif
endif

....(more after this, but less important/all functioning)

Thanks guys.
User avatar
renee Duhamel
 
Posts: 3371
Joined: Thu Dec 14, 2006 9:12 am

Post » Fri Nov 18, 2011 4:57 am

According to this script, ik_ildran_tistar2 must be transferred into the cell AND disabled at the same time. Is this right?

Local scripts are only active when you're in the same cell with their bearers. If you switch ik_slaversenablestate when not in the same cell ik_ildran_tistar2 currently is, he won't be moved until you visit it (and not unless ik_slaversenablestate is changed further until then).

PositionCell can be glitchy *even* in global scripts if you issue it towards NPCs you never met yet.
User avatar
Red Bevinz
 
Posts: 3318
Joined: Thu Sep 20, 2007 7:25 am

Post » Fri Nov 18, 2011 4:29 pm

moving the object running the script should be last thing you do, because script will stop as soon as you position away as Kir explained, so next script command can't execute, I'd try something like this
	if ( doOnce == 0 )		"ik_aendelin2"->PositionCell 0 -256 -128 0 "Firemoth, Guard Quarters"		Set tripstate to 0		Set tripdone to 0		Set doOnce to 1		PositionCell 0, -192 -128 0 "Firemoth, Guard Quarters"  ; last thing done. You don't need the prefix for the object running the script, it is implicit		return	endif
if it still does not work, you can try moving from a global script, e.g.
	if ( doOnce == 0 )		Set tripstate to 0		Set tripdone to 0		Set doOnce to 1		stertscript jrkMoveScript		return	endif
begin jrkMoveScript"ik_aendelin2"->PositionCell 0 -256 -128 0 "Firemoth, Guard Quarters"  ; this line should work from a global script even if moved belowPositionCell 0, -192 -128 0 "Firemoth, Guard Quarters"  ; prefix still not needed as passed from the local scriptstopscript jrkMoveScriptend

User avatar
Big Homie
 
Posts: 3479
Joined: Sun Sep 16, 2007 3:31 pm

Post » Fri Nov 18, 2011 10:24 am

O :facepalm: Makes sense now. Seems that I forgot about the most basic of basics in local scripts: player location. Urg. Thank you both for your feedback.
User avatar
Elea Rossi
 
Posts: 3554
Joined: Tue Mar 27, 2007 1:39 am


Return to III - Morrowind