MW mods in 2012 - Start fixing stuff.

Not about OpenMW? Just about Morrowind in general? Have some random babble? Kindly direct it here.
Post Reply
User avatar
Star-Demon
Posts: 73
Joined: 11 Aug 2011, 03:17
Location: New York
Contact:

MW mods in 2012 - Start fixing stuff.

Post by Star-Demon »

Hey guys -
I've recently revved up Morrowind just to see how my wizard tower was doing, and I realized something:

Sara N'trasha is still a ghost and won't shut up.

I was really frustrated at this bug. She's an important character and while I'd like to find a way to fix the script myself, I've had trouble finding the time and the proper fix for it.

Then it came to me: there must be small updates to behavior or quests for some mod's scripts that are out there that just aren't applied or available. I was wondering what you folks thought of trying to update or fix some buggy things, or have some of your own fixes you want to share with others so they can fix it, too?
Tarius
Posts: 574
Joined: 24 Oct 2011, 19:29

Re: MW mods in 2012 - Start fixing stuff.

Post by Tarius »

Go ask on the Bethesda main forums under the MW modding section and you will likely get an answer.
User avatar
heilkitty
Posts: 158
Joined: 11 Aug 2011, 07:57
Location: Vivec City, MW
Contact:

Re: MW mods in 2012 - Start fixing stuff.

Post by heilkitty »

Star-Demon wrote:and won't shut up
She's a woman after all.
Srsly, what stage of the quest are you at?
User avatar
Star-Demon
Posts: 73
Joined: 11 Aug 2011, 03:17
Location: New York
Contact:

Re: MW mods in 2012 - Start fixing stuff.

Post by Star-Demon »

I don't think it had much to do with her quest - I had given her the shrine, and she was happy, (although the shrine has not appeared due to teleporting out of cell, another bug) but the bug I'm describing is:

http://www.youtube.com/watch?v=CemRZKt7gXk

It happens if you teleport her back and forth from home. I know it has to do with how her teleport executes and her many teleport and follower states, but I never took full balance of everything having to do with sara.
User avatar
Star-Demon
Posts: 73
Joined: 11 Aug 2011, 03:17
Location: New York
Contact:

Re: MW mods in 2012 - Start fixing stuff.

Post by Star-Demon »

Here are most of Sara's scripts. I'm not sure how I can purposely set a state through the console, but I think one of two of these are mostly responsible for her disappearance.

One thread seemed to say she was far below the grotto, but I can't seem to find her. I'll try taking a closer look at the scripts.

Code: Select all

Begin gp_Sara_AIFix

Short state
Float timer

If ( state == -1 )
	Set state to 0
	Set timer to 0
	Set gp_sara_NoSay to 0 ;variable to block attack voices
	StopScript gp_Sara_AIFix
	Return
Elseif ( gp_npc_sara->GetHealth < 1 )
	Set state to -1
	Return
Elseif ( ScriptRunning gp_sara_Revenge == 1 ) ;quest related stuff
	Set state to -1
	Return
Elseif ( MenuMode )
	Return
Elseif ( state == 0 )
	Set timer to ( timer + GetSecondsPassed )
	If ( gp_npc_sara->GetWeaponDrawn ) ;don't start if just gone into combat
		Set state to -1
		Return
	Elseif ( gp_npc_sara->GetSpellReadied )
		Set state to -1
		Return
	Elseif ( timer < 1 )
		Return
	Endif
	Set timer to 0
	Set state to 1
Elseif ( state == 1 )
	If ( gp_npc_sara->GetCurrentAIPackage != -1 )
		Set state to -1
		Return
	Endif
	If ( uvi_sara_portflw > 0 )
		gp_npc_sara->AIFollow Player 0 0 0 0
	Else
		gp_npc_sara->AIWander 512 5 0 50 20 10 20 10
	Endif
	Set gp_sara_NoSay to 1
	Set state to 2
Elseif ( state == 2 )
	Set timer to ( timer + GetSecondsPassed )
	If ( timer < 1 )
		Return
	Endif
	Set timer to 0
	If ( gp_npc_sara->GetCurrentAIPackage == 3 )
		Set state to -1
		Return
	Elseif ( gp_npc_sara->GetCurrentAiPackage != -1 )
		If ( uvi_sara_portflw < 1 )
			Set state to -1
			Return
		Endif
	Elseif ( gp_npc_sara->GetDistance Player > 9999 ) ;check for different cell
		Set state to -1
		Return
	Endif
	gp_npc_sara->StartCombat Player
	Set state to 3
Elseif ( state == 3 )
	If ( gp_npc_sara->GetWeaponDrawn == 0 )
		If ( gp_npc_sara->GetSpellReadied == 0 )
			Set timer to ( timer + GetSecondsPassed )
			If ( timer < 1 )
				Return
			Endif
		Endif
	Endif
	gp_npc_sara->StopCombat
	Set state to 1
	If ( uvi_sara_portflw > 0 )
		gp_npc_sara->AIFollow Player 0 0 0 0
	Else
		gp_npc_sara->AIWander 512 5 0 50 20 10 20 10
	Endif
Endif

End

Code: Select all

Begin gp_Sara_FollowPortS
;slightly modified from CDCooley's Companion Teleporting

short state
short ScrTrans
short combatFlag

float timer
float ScrTimer

If ( gp_npc_sara->GetCurrentAiPackage != 3 )
	If ( Uvi_Sara_flw == 1 )
		Set Uvi_Sara_flw to 0
	Endif
Endif

If ( MenuMode == 1 )
	Return
Endif

;If ( cdc_teleportation != 0 ) ;cdc_teleportation is on
;	Return
;Endif

If ( gp_sara_travelstate == -1 )
	Set Uvi_Sara_portflw to 0
Endif

If ( state == 0 )   ;check for player teleporting
	if ( Uvi_Sara_portflw != 1 )   ;stop if not following
		StopScript gp_Sara_FollowPortS
		return
	elseif ( player->GetEffect sEffectRecall == 1 )
		set state to 10
		return
	elseif ( player->GetEffect sEffectDivineIntervention == 1 )
		set state to 10
		return
	elseif ( player->GetEffect sEffectAlmsiviIntervention == 1 )
		set state to 10
		return
	elseif ( gp_sara_travelstate == 2 )
		set state to 10
		return
	endif
elseif ( state == 10 )   ;wait a bit
	set timer to ( timer + GetSecondsPassed )
	if ( timer < 1 )
		return
	else
		gp_npc_sara->StopCombat
		set state to 20
		set timer to 0
		return
	endif
elseif ( state == 20 )
	if ( gp_npc_sara->GetDistance Player < 9999 )   ;check if companion is already in active cell
		set state to 30
	elseif ( GetInterior == 0 )   ;get him on the right cell grid
		gp_npc_sara->PositionCell 0 0 0 0 "Wilderness"
		set state to 30
		return
	elseif ( GetInterior == 1 )   ;fake exteriors have to be done individually
		if ( GetPCCell "Mournhold, Godsreach" == 1 )
		gp_npc_sara->PositionCell 0 0 0 0 "Mournhold, Godsreach"
		set state to 30
		return
	elseif ( GetPCCell "Mournhold, Great Bazaar" == 1 )
		gp_npc_sara->PositionCell 0 0 0 0 "Mournhold, Great Bazaar"
		set state to 30
		return
	elseif ( GetPCCell "Mournhold, Plaza Brindisi Dorom" == 1 )
		gp_npc_sara->PositionCell 0 0 0 0 "Mournhold, Plaza Brindisi Dorom"
		set state to 30
		return
	elseif ( GetPCCell "Mournhold, Temple Courtyard" == 1 )
		gp_npc_sara->PositionCell 0 0 0 0 "Mournhold, Temple Courtyard"
		set state to 30
		return
	elseif ( GetPCCell "Mournhold, Royal Palace: Courtyard" == 1 )
		gp_npc_sara->PositionCell 0 0 0 0 "Mournhold, Royal Palace: Courtyard"
		set state to 30
		return
	else
		return   ;wait until player is outside or in supported interior
	endif
	endif
elseif ( state == 30 )   ;warp to player
	if ( ScriptRunning, gp_Sara_WarpS == 0 )
		StartScript gp_Sara_WarpS
	endif
	set state to 40
	return
elseif ( state == 40 )   ;start monitoring again once warping has finished
	if ( ScriptRunning, gp_Sara_WarpS == 0 )
		set state to 0
		return
	endif
endif

if ( GetPCCell "Andasreth, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Berandas, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Falasmaryon, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Falensarano, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Hlormaren, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Indoranyon, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Indoranyon, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Marandus, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Rotheran, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Telasero, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Valenvaryon, Propylon Chamber" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Caldera, Guild of Mages" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Ebonheart, Grand Council Chambers" == 1 )
	set ScrTrans to 1
elseif ( GetPCCell "Mournhold, Royal Palace: Reception Area" == 1 )
	set ScrTrans to 1
else
	set ScrTrans to 0
	set ScrTimer to 0
endif

if ( ScrTrans == 1 )
	if ( ScriptRunning, gp_sara_FollowScrTransS == 0 )
		set ScrTimer to ( ScrTimer + GetSecondsPassed )
		if ( ScrTimer < 1 )
			return
		else
			StartScript gp_sara_FollowScrTransS
			set ScrTimer to 0
		endif
	endif
endif

End

Code: Select all

Begin gp_sara_FollowScrTransS
;slightly modified from Kateri's Julan
;simple comparison of cells to see if player has used standard scripted transport

Short state
Short StoredCell
Short NewCell

Float timer

If ( MenuMode == 1 )
	Return
EndIf

If ( state == 0 )
	If ( gp_npc_Sara->GetCurrentAiPackage != 3 ) 	;check if she's still following
		StopScript gp_sara_FollowScrTransS
	Return
	ElseIf ( GetPCCell "Andasreth, Propylon Chamber" == 1 )
		Set StoredCell To 1
	ElseIf ( GetPCCell "Berandas, Propylon Chamber" == 1 )
		Set StoredCell To 2
	ElseIf ( GetPCCell "Falasmaryon, Propylon Chamber" == 1 )
		Set StoredCell To 3
	ElseIf ( GetPCCell "Falensarano, Propylon Chamber" == 1 )
		Set StoredCell To 4
	ElseIf ( GetPCCell "Hlormaren, Propylon Chamber" == 1 )
		Set StoredCell To 5
	ElseIf ( GetPCCell "Indoranyon, Propylon Chamber" == 1 )
		Set StoredCell To 6
	ElseIf ( GetPCCell "Marandus, Propylon Chamber" == 1 )
		Set StoredCell To 7
	ElseIf ( GetPCCell "Rotheran, Propylon Chamber" == 1 )
		Set StoredCell To 8
	ElseIf ( GetPCCell "Telasero, Propylon Chamber" == 1 )
		Set StoredCell To 9
	ElseIf ( GetPCCell "Valenvaryon, Propylon Chamber" == 1 )
		Set StoredCell To 10
	ElseIf ( GetPCCell "Caldera, Guild of Mages" == 1 )
		Set StoredCell To 11
	ElseIf ( GetPCCell "Ebonheart, Grand Council Chambers" == 1 )
		Set StoredCell To 12
	ElseIf ( GetPCCell "Mournhold, Royal Palace: Reception Area" == 1 )
		Set StoredCell To 13
	EndIf
	If ( StoredCell > 0 )
		Set state To 10
	Else
		StopScript gp_sara_FollowScrTransS
		Return
	EndIf
ElseIf ( state == 10 )
	If ( GetPCCell "Andasreth, Propylon Chamber" == 1 )
		Set NewCell To 1
	ElseIf ( GetPCCell "Berandas, Propylon Chamber" == 1 )
		Set NewCell To 2
	ElseIf ( GetPCCell "Falasmaryon, Propylon Chamber" == 1 )
		Set NewCell To 3
	ElseIf ( GetPCCell "Falensarano, Propylon Chamber" == 1 )
		Set NewCell To 4
	ElseIf ( GetPCCell "Hlormaren, Propylon Chamber" == 1 )
		Set NewCell To 5
	ElseIf ( GetPCCell "Indoranyon, Propylon Chamber" == 1 )
		Set NewCell To 6
	ElseIf ( GetPCCell "Marandus, Propylon Chamber" == 1 )
		Set NewCell To 7
	ElseIf ( GetPCCell "Rotheran, Propylon Chamber" == 1 )
		Set NewCell To 8
	ElseIf ( GetPCCell "Telasero, Propylon Chamber" == 1 )
		Set NewCell To 9
	ElseIf ( GetPCCell "Valenvaryon, Propylon Chamber" == 1 )
		Set NewCell To 10
	ElseIf ( GetPCCell "Caldera, Guild of Mages" == 1 )
		Set NewCell To 11
	ElseIf ( GetPCCell "Ebonheart, Grand Council Chambers" == 1 )
		Set NewCell To 12
	ElseIf ( GetPCCell "Mournhold, Royal Palace: Reception Area" == 1 )
		Set NewCell To 13
	Else
		Set state To 0
		StopScript gp_sara_FollowScrTransS
		Return
	EndIf
	If ( NewCell == StoredCell )
		Return
	Else
		Set state To 20
	EndIf
ElseIf ( state == 20 )
	If ( GetPCCell "Andasreth, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 540 730 -430 270 "Andasreth, Propylon Chamber"
	ElseIf ( GetPCCell "Berandas, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 540 1124 -686 270 "Berandas, Propylon Chamber"
	ElseIf ( GetPCCell "Falasmaryon, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 227 579 -430 270 "Falasmaryon, Propylon Chamber"
	ElseIf ( GetPCCell "Falensarano, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 410 998 -558 270 "Falensarano, Propylon Chamber"
	ElseIf ( GetPCCell "Hlormaren, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 4022 3823 12690 180 "Hlormaren, Propylon Chamber"
	ElseIf ( GetPCCell "Indoranyon, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 489 866 -430 270 "Indoranyon, Propylon Chamber"
	ElseIf ( GetPCCell "Marandus, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 244 988 -430 270 "Marandus, Propylon Chamber"
	ElseIf ( GetPCCell "Rotheran, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 427 737 -430 270 "Rotheran, Propylon Chamber"
	ElseIf ( GetPCCell "Telasero, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 333 842 -558 270 "Telasero, Propylon Chamber"
	ElseIf ( GetPCCell "Valenvaryon, Propylon Chamber" == 1 )
		gp_npc_sara->PositionCell 215 853 -558 720 "Valenvaryon, Propylon Chamber"
	ElseIf ( GetPCCell "Caldera, Guild of Mages" == 1 )
		gp_npc_sara->PositionCell 763 802 412 180 "Caldera, Guild of Mages"
	ElseIf ( GetPCCell "Ebonheart, Grand Council Chambers" == 1 )
		gp_npc_sara->PositionCell 1173.285 613.156 -120.847 0 "Ebonheart, Grand Council Chambers"
	ElseIf ( GetPCCell "Mournhold, Royal Palace: Reception Area" == 1 )
		gp_npc_sara->PositionCell 2.730 959.274 -105.817 180 "Mournhold, Royal Palace: Reception Area"
	EndIf
	Set state To 30
	Return
ElseIf ( state == 30 )
	Set timer To 0
	Set state To 0
	StopScript gp_sara_FollowScrTransS
EndIf

End

Code: Select all

Begin gp_Sara_MeetingPlaceS
;Makes Sara return to Tel Uvirith Dungeon

Short strongholdtravel
Short spellcastcheck
Float recall_timer

If ( "gp_npc_sara"->GetCurrentAiPackage == 0 )
	If ( "gp_npc_sara"->GetDistance Player < 1000 )
		If ( strongholdtravel == 0 )
			If ( spellcastcheck == 0 )
				"gp_npc_sara"->Cast "Uvi_dummy_travel" Player
				Set spellcastcheck to 1
				Set strongholdtravel To 1
				Set recall_timer to 0
				return
			Endif
		ElseIf ( strongholdtravel == 1 )
			Set recall_timer To ( recall_timer + GetSecondsPassed )
			If ( recall_timer > 2 )
				"gp_npc_sara"->PositionCell 4638 1385 -2855 0 "Tel Uvirith Dungeon, Deep Tunnels"
				Set recall_timer To 0
				Set strongholdtravel To 0
				Set spellcastcheck to 0
				Set gp_sara_travelstate to -1
				StopScript gp_Sara_MeetingPlaceS
			EndIf
		EndIf
	Else
		If ( strongholdtravel == 0 )
			"gp_npc_sara"->PositionCell 4638 1385 -2855 0 "Tel Uvirith Dungeon, Deep Tunnels"
			Set gp_sara_travelstate to -1
			StopScript gp_Sara_MeetingPlaceS
		Endif
	Endif
Elseif ( "gp_npc_sara"->GetCurrentAiPackage == 3 )
	AiWander 60 5 0 60 20 10 0 0 0 0 0 0
	Return
Else
	"gp_npc_sara"->PositionCell 4638 1385 -2855 0 "Tel Uvirith Dungeon, Deep Tunnels"
	Set gp_sara_travelstate to -1
	StopScript gp_Sara_MeetingPlaceS
EndIf

End

Code: Select all

Begin gp_Sara_RingScript
; Sara's telepathy ring

Short OnPCEquip
Short PCSkipEquip
Short button

Set PCSkipEquip to 1

If ( MenuMode == 1 )
	Return
Endif

If ( OnPCEquip == 1 )
	If ( gp_npc_Sara->GetHealth > 0 )
		MessageBox "Contact Sara?" "Yes" "No"
		Set Button To -1
		Set OnPCEquip To 2
	Else
		MessageBox "Sara is dead. You will need more than a ring to contact her now."
		Set OnPCEquip To 2
	EndIf
ElseIf ( OnPCEquip == 2 )
   Set button To GetButtonPressed
   If ( button == -1 )
      Return
   ElseIf ( button == 0 )
      If ( "gp_npc_sara"->GetCurrentAiPackage == 3 ) 	;follow mode
         Set gp_sara_FGs To 1
      ElseIf ( "gp_npc_sara"->GetCurrentAiPackage == 0 ) 	;wander mode
         Set gp_sara_FGs To 2
      ElseIf ( GetInterior == 0 ) 	;exterior
         Set gp_sara_FGs To 4
      ElseIf ( GetPCCell "Mournhold, Godsreach" == 1 ) 	;Trib fake exteriors
         Set gp_sara_FGs To 4
      ElseIf ( GetPCCell "Mournhold, Great Bazaar" == 1 )
         Set gp_sara_FGs To 4
      ElseIf ( GetPCCell "Mournhold, Plaza Brindisi Dorom" == 1 )
         Set gp_sara_FGs To 4
      ElseIf ( GetPCCell "Mournhold, Temple Courtyard" == 1 )
         Set gp_sara_FGs To 4
      ElseIf ( GetPCCell "Mournhold, Royal Palace: Courtyard" == 1 )
         Set gp_sara_FGs To 4
      ElseIf ( ( "gp_npc_sara"->GetDistance player ) < 123456789 ) 	;wall-examining mode
         Set gp_sara_FGs To 3
      Else 	;not same cell and not an accessible cell
         Set gp_sara_FGs To 5
      EndIf
      Set OnPCEquip To 3
      Set "gp_npc_sara".Companion To 0
      "gp_npc_sara"->ForceGreeting
      Return
   Else
      Set OnPCEquip To 0
      Return
   EndIf
ElseIf ( OnPCEquip == 3 )
   Set gp_sara_FGs To 0
   Set OnPCEquip To 0
   Set button To -1
   Set "gp_npc_sara".Companion To 1
EndIf

End

Code: Select all

begin gp_Sara_WarpQS
;quick & silent warp, used for teleport door fix

short state

float timer
float warpx
float warpy
float warpz

if ( MenuMode == 1 )
	return
elseif ( gp_npc_sara->GetHealth < 1 )
	set timer to 0
	set state to 0
	StopScript gp_Sara_WarpQS
	Return
elseif ( ScriptRunning gp_Sara_WarpS == 1 ) ;warp has already been initiated, stop this script
	set timer to 0
	set state to 0
	StopScript gp_Sara_WarpQS
	Return
elseif ( 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 )
	gp_npc_sara->SetPos x warpx
	gp_npc_sara->SetPos y warpy
	gp_npc_sara->SetPos z warpz
	gp_npc_sara->disable
	gp_npc_sara->enable
	gp_npc_sara->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 ( gp_npc_sara->GetDistance Player > 2048 )
		if ( gp_npc_sara->GetDistance Player < 99999 )	;keep trying if in same cell
			If ( gp_npc_sara->GetSpell Uvi_comp_lev == 1 ) ;remove problematic spell effects while attempting warp
				gp_npc_sara->RemoveSpell Uvi_comp_lev
				gp_npc_sara->RemoveSpellEffects Uvi_comp_lev
			Elseif ( gp_npc_sara->GetSpell Uvi_comp_slowfall == 1 )
				gp_npc_sara->RemoveSpell Uvi_comp_slowfall
				gp_npc_sara->RemoveSpellEffects Uvi_comp_slowfall
			Endif
			set state to 1
			return
		endif
	endif
	set state to 0
	If ( gp_npc_sara->GetCurrentAIPackage == -1 ) ;check for invalid AI, usually followed with visibility problems in this case
		gp_npc_sara->Disable
		gp_npc_sara->Enable
		If ( ScriptRunning gp_Sara_AIFix == 0 )
			StartScript gp_Sara_AIFix
		Endif
	Endif
	StopScript gp_Sara_WarpQS
endif

end

Code: Select all

Begin gp_Sara_WarpS
;Script by CDCooley, from CDCooley's Companion Teleporting.

Short portWarp
Short Silent
Float portTimer
Float warpx
Float warpy
Float warpz
Float pa

If ( MenuMode == 1 )	; Wait until menus are closed.
	Return
ElseIf ( portWarp == -2 )	; Stop this script when it's no longer needed.
	Set portWarp To 0
	StopScript gp_Sara_WarpS
	Return

ElseIf ( portWarp == 0 )
	Set warpz To ( Player->GetPos z )
	SetPos z warpz
	Set portWarp To 2

ElseIf ( portWarp == 2 )	; Player is outside or NPC is in the same cell, so calculate position  just in front of player
	Set portTimer To portTimer + GetSecondsPassed
	If ( portTimer < 1 )
		Return
	EndIf
	Set warpx To ( Player->GetPos x )
	Set warpy To ( Player->GetPos y )
	Set pa To ( Player->GetAngle z )
	If ( pa < 60 )
		If ( pa > -60 )
			Set warpy To warpy + 50
		ElseIf ( pa < -120 )
			Set warpy To warpy - 50
		EndIf
	ElseIf ( pa > 120 )
		Set warpy To warpy - 50
	EndIf
	If ( pa > 30 )
		If ( pa < 150 )
			Set warpx To warpx + 50
		EndIf
	ElseIf ( pa < -30 )
		If ( pa > -150 )
			Set warpx To warpx - 50
		EndIf
	EndIf
	Set portWarp To 3
ElseIf ( portWarp == 3 )	; Move companion and play a sound as a distraction
	If ( Silent == 0 )
		gp_npc_sara->PlaySound3D "mysticism hit"
	Endif
	Set warpz To ( Player->GetPos z )
	Set warpz To warpz - 25
	gp_npc_sara->SetPos x warpx
	gp_npc_sara->SetPos y warpy
	gp_npc_sara->SetPos z warpz
	gp_npc_sara->Disable
	gp_npc_sara->Enable
	Set portWarp To 4
	Set portTimer To 0
ElseIf ( portWarp == 4 )	; Try to force the NPC visible and active again
	Set portTimer To portTimer + GetSecondsPassed
	If ( portTimer < 0.25 )
		Return
	EndIf
	If ( gp_npc_sara->GetDistance Player > 2048 )
		If ( gp_npc_sara->GetDistance Player < 99999 )	;keep trying if in same cell
			If ( gp_npc_sara->GetSpell Uvi_comp_lev == 1 ) ;remove problematic spell effects while attempting warp
				gp_npc_sara->RemoveSpell Uvi_comp_lev
				gp_npc_sara->RemoveSpellEffects Uvi_comp_lev
			Elseif ( gp_npc_sara->GetSpell Uvi_comp_slowfall == 1 )
				gp_npc_sara->RemoveSpell Uvi_comp_slowfall
				gp_npc_sara->RemoveSpellEffects Uvi_comp_slowfall
			Endif
			Set Silent to 1
			Set portWarp to 2
			Return
		Else ;not in same cell, so stop
			Set portWarp to -2
			Return
		Endif
	Endif
	gp_npc_sara->Disable
	gp_npc_sara->Enable
	gp_npc_sara->AiFollow player 0 0 0 0
	Set portWarp To 5
	Set portTimer To 0
ElseIf ( portWarp == 5 )	; Repeat the visibility code and check the AI package.
	Set portTimer To portTimer + GetSecondsPassed
	If ( portTimer < 0.75 )
		Return
	EndIf
	gp_npc_sara->Disable
	gp_npc_sara->Enable
	gp_npc_sara->AiFollow player 0 0 0 0
	Set portTimer To 0
	Set portWarp To 6

ElseIf ( portWarp == 6 )	; Ensure character isn't left in a combat stance.
	If ( gp_npc_sara->GetWeaponDrawn == 1 )
		gp_npc_sara->AddItem "silver dagger" 1
		gp_npc_sara->Equip "silver dagger" 
		gp_npc_sara->RemoveItem "silver dagger" 1
	ElseIf ( gp_npc_sara->GetSpellReadied == 1 )
		gp_npc_sara->Cast Uvi_comp_lev_bog player
	EndIf
	Set portWarp To 7
ElseIf ( portwarp == 7 )
	If ( gp_npc_sara->GetHealth <= 0 )	; Companion is dead!
		Set portWarp To -2
	ElseIf ( gp_npc_sara->GetCurrentAiPackage != -1 )	; Companion has valid AI package so we are finished.
		Set portWarp To -2
	Else 	; Companion  is probably walking into walls (AI glitch)
		Set portWarp To 8
	EndIf
ElseIf ( portWarp == 8 )	; Try to reset the AI by starting and stopping combat
	Set gp_sara_NoSay To 1
	gp_npc_sara->StartCombat Player
	Set portWarp To 9
ElseIf ( portWarp == 9 )
	If ( gp_npc_sara->GetWeaponDrawn == 0 )
		If ( gp_npc_sara->GetSpellReadied == 0 )
			Set portTimer To portTimer + GetSecondsPassed
			If ( portTimer < 1.0 )
				Return
			EndIf
		EndIf
	EndIf
	gp_npc_sara->StopCombat
	gp_npc_sara->AiFollow player 0 0 0 0
	Set gp_sara_NoSay To 0
	Set Silent to 0
	Set portTimer To 0
	Set portWarp To 6 	; Keep trying until the AI is reset  or the character is dead.
EndIf

End
Worse comes to worst, I'll just start over - it's not like I haven't done it before.
Post Reply