Jump to content

[LE] Scripting summoned creature to cast at hostiles then stop script upon death


Noober1

Recommended Posts

Yea it just drops to the floor lol.

 

Did some digging around and was reading about SetMotionType with the type set to 4 which says the object will nto be simulated by havok.

Could that work and if so would that script be on the magic effect or the actor?

Link to comment
Share on other sites

Maybe you can just use the actual trap bow then, instead of making it an actor. You can duplicate it and make your script extend ObjectReference again:

 

Activator Property WHA_Sentry Auto
Float Property Distance = 100.0 Auto 

Event OnEffectStart(Actor akTarget, Actor akCaster)
    ObjectReference WHA_SentryRef = akCaster.PlaceAtMe(WHA_Sentry, 1, 0, 1) ;place one sentry at caster
    ;(WHA_SentryRef as TWHA_SentryCombatScript).Owner = akCaster ;Set owner of sentry to the caster.
    Float A = akCaster.GetAngleZ()
    Float XDist = Math.Sin(A)
    Float YDist = math.Cos(A)
    YDist *= Distance
    XDist *= Distance
    
    WHA_SentryRef.MoveTo(akCaster, XDist, YDist, 50, True)
    WHA_SentryRef.Enable()
EndEvent

 

Link to comment
Share on other sites

Been messing around with it for a while now and for some reason after swapping it from an Actor to an Activator, both scripts compile but in game, the Sentry never spawns.

 

I've made sure to update my properties afterwards as well. This is the script that is currently on the trap activator

 

Scriptname WHA_SentryCombatScript extends ObjectReference
import Utility
Actor Property PlayerREF Auto
Float Property xOffset Auto
Float Property yOffset Auto
Float Property zOffset Auto
Float Property RandomOffsetX Auto
Float Property RandomOffsetY Auto
Float Property RandomOffsetZ Auto
Float Property PulseRate = 1.0 Auto
Float Property RandomRate Auto
Activator Property TargetType Auto
ObjectReference Property CurrentTarget Auto
Bool Property SpawnNode Auto
Spell Property WHA_SentryFirebolt Auto
FormList Property TargetTypeList Auto
Float Property SeekRange = 1000.0 Auto
Actor Property Owner Auto Hidden ;the actor that spawned this sentry
Float InitTime
Event OnInit()
InitTime = Game.GetRealHoursPassed()
RegisterForSingleUpdate(PulseRate)
EndEvent
Event OnUpdate()
Actor Target = Game.FindRandomActorFromRef(Self, SeekRange)
if Target
If Target.IsHostileToActor(Owner) ;only cast spell if hostile to owner.
WHA_SentryFirebolt.Cast(Self,Target)
Endif
endif
If ((Game.GetRealHoursPassed() - InitTime) > 0.016) || Self.IsDisabled() ==false
Self.Disable()
Self.Delete()
Else
RegisterForSingleUpdate(PulseRate + RandomFloat(0.0, RandomRate))
Endif
EndEvent
Link to comment
Share on other sites

I fixed it!! In addition....I got it to fire the spell straight out instead of coming from below ground. I switched it back to Actor, readjusted the scripts/properties then tinkered around in the Race menu. Under General Data, one of the tick boxes, "Uses Head Track Anims" had to be ticked.

 

So now the actor is spawned, turns toward any hostile enemy nearby, pelts them with firebolts and disappears after 60s. That is EXACTLY how I wanted this to turn out.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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