0
\$\begingroup\$

I saw this question and was hopeful to find the answer to my question, but no such luck: How do I make someone walk in Skyrim?

I want to, using papyrus ONLY, make Actors that I spawn to travel/patrol to a PatrolIdleMarker, preferably one that I create in the Papyrus script and set the coordinates for.

Example: I want a bandit to appear at a random location but specific distance from the Player. Then I want the bandit to start moving towards the player, attacking the player. The script below works just fine for this:

ScriptName SomeQuestName extends Quest

ActorBase property LvlBanditMelee1H auto

Int[] BanditStatus Actor[] Bandits

Event OnInit() Int MaxBandits = 11 Bandits = new Actor[11] BanditStatus = new Int[11] int i=0 while(i

Event OnUpdate() Float SpawnDistance = 15000.0 Float ClearDeadDistance = 10000.0 Float ClearAllDistance = 20000.0 Int SpawnCounter = 0 Int MaxBandits = 10 if (PlayerRef.Z < 20000 && PlayerRef.GetWorldSpace() == Tamriel && (MQ101DragonAttack.IsCompleted() || MQ101DragonAttack.GetStage() > 195)) int i = 0 int j = 0 while(i if(VerboseDebug==1) Debug.Notification("Bandit #" + i + " has wrong BanditStatus.") EndIf Else Distance = PlayerRef.GetDistance(Bandits[i]) if((Bandits[i].IsDead() && Distance > ClearDeadDistance ) || Distance > ClearAllDistance ) If(BanditStatus[i]==2) Bandits[i].Delete() Bandits[i] = None BanditStatus[i]=0 EndIf if(BanditStatus[i]==1) Bandits[i].Disable(true) BanditStatus[i]=2 EndIf EndIf EndIf EndIf i+=1 EndWhile

    RegisterForSingleUpdate(30.0)

EndEvent

But lets say I wanted the Bandit to just patrol passed the player, replacing the bandit with say an Imperial guard?

ActorBase property LvlGuardImperial auto

Removing one row to stop spawned actor to start attacking the player from a distance: Bandits[i].StartCombat(PlayerRef)

And instead adding Bandits[i].EnableAI() won't work - the imperial guard will stand in one spot, only moving if combat starts close by or if the player comes into proximity and the guard is hostile to the player. If they are friendly the guard will simply stand/talk but not patrol or walk...

I need the codelines for adding creating a PatrolIdleMarker, LinkedReference or something else that I can set X,Y,Z to related to the Player, so that the spawned Actors will patrol passed the point where the player was when they spawned.

I have even tried to make them patrol to PatrolIdleMarkers already defined in vanilla Skyrim (Stable outside Solitude, Barracks in Falkreath etc), but the Actors will just not start patrolling/walking...

It also seems no forums are active anymore when it comes to Skyrim... I am so glad there will be a new release of Skyrim this fall (Skyrim Remastered) and hopefully some old modders will attend the forums again...

\$\endgroup\$
  • \$\begingroup\$ I have been able to do this using Creation Kit, creating a duplicate of the NPCs I want to use, giving them a patrol ai package with a linked ref xmarker as location. They start patrol and still attack their enemies and if instructed the player. Strange that there is no way of doing this with papyrus... at least I have not found any way to assign an ai package and set location of the package... \$\endgroup\$ – user3505708 Jul 16 '16 at 22:41
0
\$\begingroup\$

If you wanna move it around after, declare Objectreference PatrolMarker as a script global property like your arrays, then in any event (usually the first one, as redux's replace the current ref, but whenevr works best for ya) all you need to do is put PatrolMarker = Game.GetPlayer().PlaceAtme(PatrolIdleMarker, 1) If you declare it the way I wrote it the first time, it'll be a single-event-only property. The PatrolMarker from your OnInit() won't be usable when your OnLoad() event fires, and if you use PatrolMarker = Game.GetPlayer().PlaceAtme(PatrolIdleMarker, 1) again it'll make a new Marker. Since these are patrol markers, I recommend using this second approach if you read this, since you can then add StartTimer(300, 34543) to your OnInit() and Event Ontimer(int aiTimerId)
PatrolMarker.DIsableNoWait()
PatrolMarker.Delete()
EndEvent
to disable them. You can use whiles in your timer NP if you've got more than one ref, and obviously know how to setup and deal with arrays, I'll leave ya to it. The placeatme usage is in both games exactly the same I know for sure, but some of the rest might need to be adapted to your version of Papyrus. Idk about the timer in particular, pretty sure they were added in Fallout 4, since we dont have OnUpdate() or RegisterForUpdate() or anything, all timers. But there HAS to be a timer system in your Papyrus of some kind or it couldn't work, which I'm sure you know all about, so have fun, hope I helped.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks! This helped a lot. I have been able to get the bandits to move like I wanted. \$\endgroup\$ – user3505708 Aug 21 '17 at 1:31
0
\$\begingroup\$

In Fallout 4 I'd use objectreference PatrolMarker = Game.GetPlayer().PlaceAtme(PatrolIdleMarker, 1) just make sure to get the properties right. idk how that'd "mesh" with what you're doing, what I can see of your your script dont actually do anything besides delete or disable some bandits, but it's gotta be something not showing up properly, there's no way while(i

if(VerboseDebug==1)
can actually do anything in either game, since "i" has no comparable values and you never end any of your whiles.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ The editor of stackexchange messed up my code, but the examplecode you have given helped me a lot. \$\endgroup\$ – user3505708 Aug 21 '17 at 1:30
0
\$\begingroup\$

I will answer the question myself now that I know the answer: You use the PathToReference function or the above suggested Patrol functionality. Difference is that PathToReference only works once and puts a strain on the CPU everytime it is called, but will make the AI move toward the reference.

https://www.creationkit.com/index.php?title=PathToReference_-_Actor

Example:

; Make actor path to the player at half speed Bob.PathToReference(Game.GetPlayer(), 0.5)

This does not make the actor attack the player like StartCombat, but will make the Actor move toward the target (player in above example).

I also suggest using PlayerRef instead of Game.GetPlayer():

Actor property PlayerRef Auto

Bob.PathToReference(PlayerRef,0.5)

Hope this helps other struggling with this.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.