Jump to content

Need help with scripting (Follower won't follow)


darkteutonic

Recommended Posts

Posted

Good day to all,
 
I would like to thank a thousand time any kind soul who take some of their time to help with this problem. OK so long story short I created a spell to summon a creature. I then added a script in hope of summoning 4 of said creature. (When casting the spell 4 creatures, are summoned). Problem is I can't get the other 3 to follow me, they are ally and will fight any hostile npc, but then they just stand there. Here is the script.

 

 

 

Scriptname SummonNPCLegionScript extends ActiveMagicEffect

{Summons up to 10 NPC's of ActorBase "NPCType"}

;*********************************************************
; PROPERTIES TO BE ASSIGNED IN THE CK
;*********************************************************

ActorBase Property NPCType auto ; the type of NPC to summon
Int Property SizeOfLegion = 10 auto ; the number of NPCs to summon (DEFAULT=10)
Explosion Property AppearExplosion auto ; the summon explosion effect (OPTIONAL). "ExplosionIllusionDark01" works well.
EffectShader Property Shader auto ; the shader to apply to the NPC when summoned (OPTIONAL). "TimeFadeIn01FXS" works well.
EffectShader Property Shader2 auto ; the shader to apply to the NPC when spell ends (OPTIONAL). "TimeFadeOut01FXS" works well.
Faction Property PlayerFaction auto ; Faction used to make the npc a friend of the player.
Faction Property CWPlayerAlly auto ; Faction used to make the npc an ally of the player


;*********************************************************

ObjectReference[] NPC ; an array to reference the summoned NPC's

;*********************************************************

Event onEffectStart(Actor akTarget, Actor akCaster)

NPC = new ObjectReference[10] ; arrays must be created within a function or event block. Arrays can be up to 256 in size.

If SizeOfLegion > NPC.Length
SizeOfLegion = NPC.Length ; just for safety
EndIf

int count = 0

While count < SizeOfLegion

NPC[count] = Game.GetPlayer().PlaceAtMe(NPCType)
(NPC[count] as Actor).RemoveFromAllFactions()
(NPC[count] as Actor).SetFactionRank(PlayerFaction, 5)
(NPC[count] as Actor).AddToFaction(CWPlayerAlly)

If AppearExplosion
NPC[count].PlaceAtMe(AppearExplosion)
EndIf

NPC[count].Enable()

If Shader
Shader.Play(NPC[count], 5)
EndIf

count += 1

EndWhile

EndEvent

;*********************************************************

Event OnEffectFinish(Actor akTarget, Actor akCaster)

int count = 0

While count < SizeOfLegion

If Shader
Shader2.Play(NPC[count], 3)
EndIf

If AppearExplosion
NPC[count].PlaceAtMe(AppearExplosion)
EndIf

NPC[count].DisableNoWait()
count += 1

EndWhile

EndEvent
 

;*********************************************************



What is missing in the script ? so that the summoned NPC will follow me ?

Posted

"Follow" is a package.

I don't see you adding a PackageOverride.

 

But probably it is better if you add this package to the actors (if they are custom.)

Posted

How would I go about adding this package ?, would you care to point me in the right direction and also thank you so much for your reply. Sorry I am kind of new to the scripting, I actually came across several forum about adding a scrip for a spell to summon an army of follower, and I kind of followed their instruction but I don't understand all of it. Still very much a novice.

Posted

Of course.

But right now I am just guessing, so bear with me.

 

1) The NPC is a well defined NPC.

--> Add to this guy a Package: type Travel, Target Player, destination 300, never ending.

 

2) The NPC is not a well defined NPC (generic or whatever)

--> Create a package "myModFollowPlayer", type Travel, target Player, destination 300, never ending.

--> When you spawn the NPCs do a ActorUtil.AddPackageOverride(theNPC, myModFollowPlayer, 60, false)

 

Now, if you want to spawn a bunch of followers with a spell, then it is not really complex to do it.

If you need help I will provide help.

 

Posted

:) thanks alot, I have found a way to make my npc follow me, after your initial reply, I was up 3 in the morning trying to figure out how to make this happen, I had actually never taken a deep look into the AI Package, I found the Follow player package, and that was pretty much it, although now I find that they are following from too far, not sure how to reduce the distance. I have been tinkering with it last night and early this morning, and I'm about to start again in a few minutes. I was hoping I could find a way to have them circle me, but one of them just kept bumping onto me and pushing me to the side, I have tried some normal playing and god, it got on my nerve I almost killed one of my follower lol, I was trying to aim with a bow, and kept being push to the side and closest to the cliff, I was like are you seriously pushing me toward the edge of the mountain - you m***f** lol anyways.

I have just read your second reply and will be trying to use that information into the script, as using the follow package could get in the way of using sandbox animation at a later point. Anyways thank you very much again.

Hope you have a great day!

Ian

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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