This is apparently some fix concerning doors, taken from Julan the ashlander main script.
Spoiler
;cellchanges
set tempShort to 0
set prevX to currX
set currX to ( GetPos x )
set tempFloat to ( currX - prevX )
if ( doorDelay == -1 ) ;just warped, not a cellchange
set doorDelay to 0
elseif ( ScriptRunning, KS_Julan_Comehere == 1 ) ;summoned-warp, still move but wait until warp is done
set doorDelay to -2
elseif ( doorDelay == -2 )
set tempShort to 1
elseif ( doorDelay == 0 )
if ( CellChanged == 1 )
set tempShort to 2
elseif ( tempFloat > 256 )
set tempShort to 1
elseif ( tempFloat < -256 )
set tempShort to 1
endif
endif
if ( tempShort >= 1 )
set oldCell to currCell
set currCell to ( GetInterior )
set swimCheck to 0
set underwater to 0
if ( GetCurrentAIPackage == 3 )
if ( oldCell == 1 )
set doorDelay to 1
elseif ( currCell == 1 )
set doorDelay to 1
elseif ( tempShort == 1 )
set doorDelay to 1
endif
endif
endif
set warpTimer to ( warpTimer - GetSecondsPassed )
if ( wanderTimer < 500 )
set wanderTimer to ( wanderTimer - GetSecondsPassed )
if ( warpTimer < wanderTimer )
set warpTimer to wanderTimer
endif
if ( wanderTimer <= 0 )
set wanderTimer to 600
set KS_Jul_Nosay2 to 0
if ( jul_follow == 1 ) ;should follow
AIFollow player 0 0 0 0
elseif ( jul_follow == 0 ) ;should wait
AiWander 0 0 0 0 10 10 0 10 0 0 0 0
endif
endif
endif
;teleport door & fast travel fixes
if ( doorDelay > 0 )
if ( doorDelay > 6 )
if ( wanderTimer >= 500 ) ;we're finished
set doorDelay to 0
return
endif
elseif ( doorDelay == 4 ) ;check distance & warp to player if necessary
if ( GetDistance Player > 800 )
if ( ScriptRunning, KS_Jul_Doorfix == 0 )
StartScript KS_Jul_Doorfix
endif
elseif ( ScriptRunning, KS_Jul_Doorfix == 0 )
set doorDelay to 5
endif
elseif ( doorDelay == 5 ) ;wander to get out of pile-ups
set KS_Jul_Nosay2 to 1
AIWander 300 0 0 0
set wanderTimer to 1
set doorDelay to 6
elseif ( doorDelay != 4 )
set doorDelay to ( doorDelay + 1 )
endif
set warpTimer to 4
return
endif
set tempShort to 0
set prevX to currX
set currX to ( GetPos x )
set tempFloat to ( currX - prevX )
if ( doorDelay == -1 ) ;just warped, not a cellchange
set doorDelay to 0
elseif ( ScriptRunning, KS_Julan_Comehere == 1 ) ;summoned-warp, still move but wait until warp is done
set doorDelay to -2
elseif ( doorDelay == -2 )
set tempShort to 1
elseif ( doorDelay == 0 )
if ( CellChanged == 1 )
set tempShort to 2
elseif ( tempFloat > 256 )
set tempShort to 1
elseif ( tempFloat < -256 )
set tempShort to 1
endif
endif
if ( tempShort >= 1 )
set oldCell to currCell
set currCell to ( GetInterior )
set swimCheck to 0
set underwater to 0
if ( GetCurrentAIPackage == 3 )
if ( oldCell == 1 )
set doorDelay to 1
elseif ( currCell == 1 )
set doorDelay to 1
elseif ( tempShort == 1 )
set doorDelay to 1
endif
endif
endif
set warpTimer to ( warpTimer - GetSecondsPassed )
if ( wanderTimer < 500 )
set wanderTimer to ( wanderTimer - GetSecondsPassed )
if ( warpTimer < wanderTimer )
set warpTimer to wanderTimer
endif
if ( wanderTimer <= 0 )
set wanderTimer to 600
set KS_Jul_Nosay2 to 0
if ( jul_follow == 1 ) ;should follow
AIFollow player 0 0 0 0
elseif ( jul_follow == 0 ) ;should wait
AiWander 0 0 0 0 10 10 0 10 0 0 0 0
endif
endif
endif
;teleport door & fast travel fixes
if ( doorDelay > 0 )
if ( doorDelay > 6 )
if ( wanderTimer >= 500 ) ;we're finished
set doorDelay to 0
return
endif
elseif ( doorDelay == 4 ) ;check distance & warp to player if necessary
if ( GetDistance Player > 800 )
if ( ScriptRunning, KS_Jul_Doorfix == 0 )
StartScript KS_Jul_Doorfix
endif
elseif ( ScriptRunning, KS_Jul_Doorfix == 0 )
set doorDelay to 5
endif
elseif ( doorDelay == 5 ) ;wander to get out of pile-ups
set KS_Jul_Nosay2 to 1
AIWander 300 0 0 0
set wanderTimer to 1
set doorDelay to 6
elseif ( doorDelay != 4 )
set doorDelay to ( doorDelay + 1 )
endif
set warpTimer to 4
return
endif
And a separate script, called in the above code
Spoiler
Begin KS_Jul_Doorfix ;quick & silent warp, used for teleport door fix
short state
float timer
float warpx
float warpy
float warpz
float oldgamehour
If ( Menumode == 1 )
return
elseif ( GameHour == oldgamehour )
return
endif
set oldgamehour to GameHour
if ( state == 0 )
set timer to 0
set state to 1
elseif ( state == 1 )
if ( timer < 0.1 )
set timer to ( timer + GetSecondsPassed )
return
endif
set timer to 0
set warpx to ( player->GetPos x )
set warpy to ( player->GetPos y )
set warpz to ( player->GetPos z )
set state to 10
elseif ( state == 10 )
KS_Julan->SetPos x warpx
KS_Julan->SetPos y warpy
KS_Julan->SetPos z warpz
Set KS_Jul_Nosay2 to 1
KS_Julan->disable
KS_Julan->enable
KS_Julan->AIFollow player 0 0 0 0
set state to 20
return
elseif ( state == 20 )
if ( timer < 0.1 )
set timer to ( timer + GetSecondsPassed )
return
endif
set timer to 0
if ( KS_Julan->GetDistance Player > 2048 )
if ( KS_Julan->GetDistance Player < 99999 ) ;keep trying if in same cell
set state to 1
return
endif
endif
set state to 0
Set KS_Jul_Nosay2 to 0
StopScript KS_Jul_Doorfix
endif
end
short state
float timer
float warpx
float warpy
float warpz
float oldgamehour
If ( Menumode == 1 )
return
elseif ( GameHour == oldgamehour )
return
endif
set oldgamehour to GameHour
if ( state == 0 )
set timer to 0
set state to 1
elseif ( state == 1 )
if ( timer < 0.1 )
set timer to ( timer + GetSecondsPassed )
return
endif
set timer to 0
set warpx to ( player->GetPos x )
set warpy to ( player->GetPos y )
set warpz to ( player->GetPos z )
set state to 10
elseif ( state == 10 )
KS_Julan->SetPos x warpx
KS_Julan->SetPos y warpy
KS_Julan->SetPos z warpz
Set KS_Jul_Nosay2 to 1
KS_Julan->disable
KS_Julan->enable
KS_Julan->AIFollow player 0 0 0 0
set state to 20
return
elseif ( state == 20 )
if ( timer < 0.1 )
set timer to ( timer + GetSecondsPassed )
return
endif
set timer to 0
if ( KS_Julan->GetDistance Player > 2048 )
if ( KS_Julan->GetDistance Player < 99999 ) ;keep trying if in same cell
set state to 1
return
endif
endif
set state to 0
Set KS_Jul_Nosay2 to 0
StopScript KS_Jul_Doorfix
endif
end
I tried to google this stuff but no luck. So what I need is to know what this is, because I'm trying to learn advanced companion scripting. I already created a few scripts of my own including fixing companion getting lost on cell change when pushed aside before clicking door. But still cant understand what the above code is for.
I hope Im posting in the right section cause my thread got moved last time lol