:brokencomputer:
;check for cell change - need to know if one or both; cells are interior. This triggers the door-fix wander;Problem is that on game load the x-pos is wrong value first time; so also check for game load via startscriptset tmpS to 0set prevX to currXset currX to ( GetPos x )set tmpF to ( currX - prevX )if ( doorFix == -1 ) ;just warped, false alarm set doorFix to 0elseif ( doorFix == 0 ) if ( followNow == 0 ) elseif ( mel_reload == 1 ) ;game load = false alarm elseif ( tmpF > 512 ) set tmpS to 1 elseif ( tmpF < -512 ) set tmpS to 1 endifendifif ( tmpS >= 1 ) set oldCell to curCell set curCell to ( GetInterior ) set swimChk to 0 if ( oldCell == 1 ) ;if a cell is interior, do the fix set doorFix to 1 elseif ( curCell == 1 ) set doorFix to 1 elseif ( tmpS == 1 ) ;this will kick in with e.g. scripted teleports set doorFix to 1 endifendifset pcDist to ( GetDistance player )set warpTmr to ( warpTmr + GetSecondsPassed )if ( wndrTmr < 500 ) set wndrTmr to ( wndrTmr - GetSecondsPassed ) set warpTmr to 0 if ( wndrTmr <= 0 ) set wndrTmr to 512 if ( followNow == 1 ) AIFollow player 0 0 0 0 else AIWander 256 0 0 30 35 5 10 5 10 5 0 0 ;replace idles and distance with your defaults/whatever you want endif endifendifif ( doorFix > 0 ) if ( mel_reload != 0 ) ;if it got past the first check, catch it here set wndrTmr to 0.1 ;this should hopefully put her back in follow mode set doorFix to 0 return elseif ( doorFix > 7 ) if ( wndrTmr > 500 ) set doorFix to 0 ;all done return endif elseif ( doorFix == 4 ) if ( pcDist < 800 ) ;don't need to warp set doorFix to 6 elseif ( ScriptRunning illy_loaddoorfix == 0 ) set doorFix to 5 StartScript illy_loaddoorfix ;warp companion back to player if she's got lost endif elseif ( doorFix == 5 ) if ( pcDist > 800 ) ;wait for script to do its job return elseif ( ScriptRunning illy_loaddoorfix == 0 ) set doorFix to 6 endif elseif ( doorFix == 6 ) AIWander 512 0 0 0 ;this also helps get companion out of the post-door pile-up set wndrTmr to 2 set doorFix to 7 else set doorFix to ( doorFix + 1 ) endif set warpTmr to 4 returnendif
begin mel_checkloadfloat timerif ( timer < 0.5 ) set timer to ( timer + GetSecondsPassed ) if ( mel_reload == 0 ) set mel_reload to 1 endifelse set timer to 0 set mel_reload to 0 StopScript mel_checkloadendifend
First, do you have Pursuit Enhanced?
Game load detection (to stop companion wandering on game load as well). For this you need to add a global variable (called "mel_reload" here, you can use that or change it if you want). The variable should just have default settings (short, default 0).
Game load detection (to stop companion wandering on game load as well). For this you need to add a global variable (called "mel_reload" here, you can use that or change it if you want). The variable should just have default settings (short, default 0).
Load door fix/warp (this is called from the companion local script when you go through a loaddoor, use fast travel, teleport with the companion, etc)begin illy_loaddoorfix;quick warp, used for teleport door fix when companion ends up too far away (disappears);must be targeted script as local script setPos is not reliable here;this script can be used for other followers as well (but if there are many followers at; once I'd have a few different scripts, since they'll have to wait til one's available)short statefloat timerfloat warpxfloat warpyfloat warpzif ( MenuMode == 1 ) returnelseif ( GetHealth < 1 ) ;mostly a check for script losing its target (GetHealth set state to 0 ; will return 0 if that happens) set timer to 0 StopScript illy_loaddoorfix returnelseif ( state == 0 ) if ( timer < 0.2 ) 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 10elseif ( state == 10 ) SetPos x warpx SetPos y warpy SetPos z warpz disable enable AIFollow player 0 0 0 0 set state to 20 returnelseif ( state == 20 ) if ( timer < 0.1 ) set timer to ( timer + GetSecondsPassed ) return endif set state to 0 set timer to 0 if ( ( GetDistance player ) > 2048 ) ;if still too far away, try again if ( ( GetDistance player ) < 999999 ) ;but give up if actually in a different cell! return endif endif StopScript illy_loaddoorfixendifend