Jump to content

Teleport script causing random CTDs


Aintiarna

Recommended Posts

The following script is attached to a magical effect that is run by a lesser power. It summons a custom vampire follower I created and works flawlessly 39 times out of 40. 1 time in 40 it causes a CTD and I cannot figure out why. There is nothing relevant in the papyrus logs despite me putting lots of debugging code in (which I've removed for readability). The magical effect gets as far as applying the image space modifier, then CTD. i.e. none of the special effects in the script show on screen, just the imod defined in the base magical effect.

 

Anyone have a clue why it's breaking?

 

Thanks.

 

 

 

Scriptname TMMSummonFollowerScript extends ActiveMagicEffect

 

;Fade in visual Effects for actor

EffectShader Property DLC1VampireBatsReformFXS auto

EffectShader Property DLC1VampireBatsReformBATSFXS auto

 

; Add Bats

Activator Property DLC1VampLordBatsFXActivator auto

ObjectReference MyBatsFXObjectRef= None

 

; Reference to NPC to summon.

Actor Property FollowerToSummon auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

Actor actorRef = FollowerToSummon as Actor

 

;Where to place NPC

Float afDistance = 150.0

Float afZOffset = 0.0

 

; keep the bats effect tracking the actor

Float fTranslationSpeed = 512.0

; simple counter

Int aiStage = 0

 

; Make sure actor isn't disabled.

if actorRef.IsEnabled()

While aiStage < 7

aiStage += 1

If aiStage == 1 ; disable the actor before moving them

actorRef.DisableNoWait(true)

ElseIf aiStage == 2 ; Move the actor in front of the player

actorRef.MoveTo(akCaster, Math.Sin(akCaster.GetAngleZ()) * afDistance, Math.Cos(akCaster.GetAngleZ()) * afDistance, afZOffset)

ElseIf aiStage == 3 ; Play special effects and re-enable the actor

MyBatsFXObjectRef = (actorRef.placeatme(DLC1VampLordBatsFXActivator))

MyBatsFXObjectRef.EnableNoWait(false)

actorRef.EnableNoWait(false)

DLC1VampireBatsReformFXS.Play(actorRef, 0.2)

DLC1VampireBatsReformBATSFXS.Play(actorRef, 0.2)

ElseIf aiStage == 4 ; Translate bats with actor

MyBatsFXObjectRef.TranslateToRef(actorRef,fTranslationSpeed,1)

ElseIf aiStage == 5

MyBatsFXObjectRef.TranslateToRef(actorRef,fTranslationSpeed,1)

ElseIf aiStage == 6

MyBatsFXObjectRef.TranslateToRef(actorRef,fTranslationSpeed,1)

Endif

Utility.Wait(0.6)

EndWhile

; clean up

MyBatsFXObjectRef.disable()

MyBatsFXObjectRef.delete()

MyBatsFXObjectRef = None

EndIf

EndEvent

 

 

 

Edited by tirnoney
Link to comment
Share on other sites

You're trying to play effects on an actor but also used EnableNoWait. My experience is that trying to do anything graphical without checking that the 3d is fully loaded either results in failure (but there might be situations where it could cause a crash).

 

Try playing the DLC1VampireBatsReformFXS and DLC1VampireBatsReformBATSFXS effects on the MyBatsFXObjectRef instead of ActorRef. If that isn't possible then try waiting for the 3D of the actorRef to be loaded before you apply those two effects.

Link to comment
Share on other sites

  • 5 years later...

I'm sorry it's past so many years, I have a teleport script with pyrotx [/size]Sky Ai Teleporting NPCs at Skyrim Nexus - Mods and Community with him permission, that cause CTD. But your strings script are different from pyrotx one.

 

 

 

Scriptname teleportability extends activeMagicEffect

import Game
Import Utility

;=========================================================================================
; PROPERTIES
;============================

Activator property teleportActivator Auto
{The activator that will be placed and teleported to}
Activator property TeleportFXStart Auto
{The Fx that will be placed before teleporting}
Activator property TeleportFXFinish Auto
{The Fx that will be placed after teleporting}

Int Property TeleportChance = 20 Auto
{The Chance that an NPC will be able to use this ability (Default 20) + 2/3's of the NPC's Level}
Int Property TeleportChanceHit = 60 Auto
{If allowed to teleport at all, this is the chance to be allowed to teleport by being hit (Default 60)}
Int Property TeleportChanceTimed = 60 Auto
{If allowed to teleport at all, this is the chance to be allowed to teleport on a timer (Default 60)}

Int Property CountMin = 3 Auto
{Minimum number of times the script updates before teleporting (Default 3)}
Int Property CountMax = 7 Auto
{Maximum number of times the script updates before teleporting (Default 7)}

Int Property HitCountMin = 2 Auto
{Minimum number of hits until teleport (Default 3)}
Int Property HitCountMax = 7 Auto
{Maximum number of hits until teleport (Default 7)}
Float Property UpdateTime = 2.5 Auto
{How often the script updates (Default 2.5 seconds)}
Float Property fRadius = 2048.0 Auto
{Radius to search for a teleport point (2048.0 Auto)}

Bool Property bTimebased = True Auto
{Allows user to teleport after the script updates a certain number of times. (Default True)}
Bool Property bHitbased = True Auto
{Allows user to teleport after being hit a certain number of times. (Default True)}

;=========================================================================================
; VARIABLES
;============================

ObjectReference ActivatorRef
ObjectReference casterRef
ObjectReference FXStartLoc
ObjectReference FXFinishLoc
ObjectReference targetLoc
actor caster

int RandTeleport
int RandTeleportHit
int RandTeleportTimed
int hitCount
int updateCounter
int teleportTimed
int teleportHit
int level

;=========================================================================================
; EVENTS
;============================

Event OnEffectStart(Actor akTarget, Actor akCaster)
caster = akCaster
casterRef = (caster as ObjectReference)
level = (caster.getLevel() * 2/3)
RandTeleport = Utility.RandomInt(0,100)
if RandTeleport <=(TeleportChance + (level as Int))
ActivatorRef = casterRef.placeAtMe(teleportActivator)
RandTeleportHit = Utility.RandomInt(0,100)
RandTeleportTimed = Utility.RandomInt(0,100)

if RandTeleportHit <= TeleportChanceHit
bHitBased = true
elseIf RandTeleportHit > TeleportChanceHit
bHitBased = false
endIf

if RandTeleportTimed <= TeleportChanceTimed
bTimeBased = true
elseIf RandTeleportTimed > TeleportChanceTimed
bTimeBased = false
endIf

if bTimeBased == true
updateCounter = 0
teleportTimed = Utility.RandomInt(CountMin, CountMax)
endIf
if bHitBased == true
hitCount = 0
teleportHit = Utility.RandomInt(HitCountMin, HitCountMax)
endIf
if bHitBased == True || bTimeBased == True
registerForSingleUpdate(0.5)
endIf
endIf
EndEvent

Event OnUpdate()
ActivatorRef = casterRef.placeAtMe(teleportActivator)
if caster.isInCombat() && caster.isDead() == false
if bTimeBased == True
updateCounter+= 1
If updateCounter >= teleportTimed
Teleport()
updateCounter = 0
teleportTimed = Utility.RandomInt(CountMin, CountMax)
endif
endIf
ActivatorRef
registerForSingleUpdate(UpdateTime)
endIf
EndEvent

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
if bHitbased == True
HitCount += 1
if HitCount >= TeleportHit
Teleport()
HitCount = 0
if updateCounter != 0
updateCounter -= 1
endIf
teleportHit = Utility.RandomInt(HitCountMin, HitCountMax)
endIf
endIf
EndEvent

Function Teleport()
targetLoc = Game. FindRandomReferenceOfTypeFromRef(TeleportActivator, casterRef, fRadius)
FXStartLoc = casterRef.placeAtMe(TeleportFXStart)
FXFinishLoc = targetLoc.placeAtMe(TeleportFXFinish)
FXStartLoc
targetLoc
FXFinishLoc
casterRef.moveTo(targetLoc)
EndFunction

 

 

Edited by morismark
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...