Jump to content

[LE] Spawn a npc with script


Wooty

Recommended Posts

I FIGURED OUT THE PROBLEM

 

Hello everyone,

 

I'm trying to place an actor near me but when I do so and make either an ActorBase or Actor property to set

in the creation kit I cannot find my npcs that I have created, I can only find ones that I have not created.

 

So does anyone know how to set my npc as an actor or actor base so I can use them in my script

Here is the script for reference:

 

 

Scriptname wtyTestScript extends ActiveMagicEffect
{Just something I use to test stuff.}
Import Game
Import Spell
Import ObjectReference
ObjectReference Property PlayerREF Auto
Actor Property NPCToSummon Auto <- Here is where I am unable to set the npc to my npc in the creation kit
;ActorBase Property NPCToSummon Auto <- and here
int Property spellAmount Auto
Float Property OffsetX Auto
Float Property OffsetY Auto
Float Property OffsetZ Auto
Float Property RotationOffset Auto
ObjectReference currentNPC
Event OnEffectStart(Actor akTarget, Actor akCaster)
int counter = 0
;currentNPC = PlayerRef.PlaceAtMe(NPCToSummon)
currentNPC = PlayerRef.PlaceActorAtMe(NPCToSummon)
;places NPC at an offset to the Player
currentNPC.MoveTo(PlayerRef, OffsetX * Math.Sin(PlayerRef.GetAngleZ() + RotationOffset), OffsetY * Math.Cos(PlayerRef.GetAngleZ() + RotationOffset), OffsetZ)
EndEvent
Edited by Wooty
Link to comment
Share on other sites

So, to answer question even though you figured it out - In CK you have to fill the property on the magic effect the script is attached to.

Correct?

 

Also ....

I've worked on OBIS for long time and also with TonyCubed2's Sands of Time mod - Spawning NPCs via script is integral to both mods.

For OBIS it works really well to not use the PlaceActorAtMe(). Instead it uses PlaceAtMe() As Actor with the Initially Disabled set to true. Then use Enable() after that.

So for your example it would look like this...

CurrentNPC = PlayerRef.PlaceAtMe(NPCToSummon, 1, abInitiallyDisabled = True) As Actor
CurrentNPC.MoveTo(PlayerRef, OffsetX * Math.Sin(PlayerRef.GetAngleZ() + RotationOffset), OffsetY * Math.Cos(PlayerRef.GetAngleZ() + RotationOffset), OffsetZ)
CurrentNPC.Enable(True) ; with fade in

Link to comment
Share on other sites

  • Recently Browsing   0 members

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