Jump to content

Photo

Papyrus adding AI Packages or Animations question

papyrus script idle idles ai packages package

  • Please log in to reply
5 replies to this topic

#1
OneOnOne1162

OneOnOne1162

    Old hand

  • Premium Member
  • 589 posts

I want to force an NPC to assume an animation where they sit down with their hands behind their back as part of a script that I'm writing, however "playidle" doesn't work and while I can force them to do this by giving a specific NPC an AI Package and teleporting them to a marker this "spell" that I've created has to work on any NPC. In other words I can't add the correct package to every single NPC so I want to find a way to either add an AI Package through a script or cause them to go into the animation through scripting. Does anyone know how I can do this?



#2
Xander9009

Xander9009

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,340 posts

I don't know how to add one via scripts, but a Reference Alias has a spot for Packages. And you can for a reference to fill an alias using scripting. You'd have to either only use the spell on one person at a time or one alias per possible simultaneous usage and check which ones are filled before choosing an alias to fill. And, of course, empty the aliases when you're done with them. I can't guarantee it'll work, but it's what I would try.



#3
OneOnOne1162

OneOnOne1162

    Old hand

  • Premium Member
  • 589 posts

I don't know how to add one via scripts, but a Reference Alias has a spot for Packages. And you can for a reference to fill an alias using scripting. You'd have to either only use the spell on one person at a time or one alias per possible simultaneous usage and check which ones are filled before choosing an alias to fill. And, of course, empty the aliases when you're done with them. I can't guarantee it'll work, but it's what I would try.

 

I thought of that as well however while I've come across the "Alias" option in properties I don't actually know how to make the target assume an alias. I'm relatively new at using scripts (I made my first script two days ago).



#4
Xander9009

Xander9009

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,340 posts

In the Alias tab, right click and make a new Reference Alias and name it whatever you want. Then, in the script effect, when it starts, fill the alias using the ForceRefTo() function. For the example, pretend you've named your alias TargetToBindAlias.

ScriptName YourScriptsName extends ActiveMagicEffect

ReferenceAlias Property TargetToBindAlias Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	TargetToBindAlias.ForceRefTo(akTarget)
	akTarget.EvaluatePackage()
EndEvent

Now, the alias 'TargetToBindAlias' will be filled with the target of the spell. Anything filled in on the alias tab where you made it such as the package, or any scripts in the script section, should immediately be applied to the alias. After it's filled, though, you might have to kick-start the package processing with EvaluatePackage(), that's why I put it in there.

 

Just FYI, if you wanted to fill the alias with the player or any other specific person or thing, you can do that, too. But that's not necessary in this case.

 

Don't forget to check Start Game Enabled on the main quest tab. I'm pretty sure the aliases only work if the quest is running.



#5
OneOnOne1162

OneOnOne1162

    Old hand

  • Premium Member
  • 589 posts

In the Alias tab, right click and make a new Reference Alias and name it whatever you want. Then, in the script effect, when it starts, fill the alias using the ForceRefTo() function. For the example, pretend you've named your alias TargetToBindAlias.

ScriptName YourScriptsName extends ActiveMagicEffect

ReferenceAlias Property TargetToBindAlias Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	TargetToBindAlias.ForceRefTo(akTarget)
	akTarget.EvaluatePackage()
EndEvent

Now, the alias 'TargetToBindAlias' will be filled with the target of the spell. Anything filled in on the alias tab where you made it such as the package, or any scripts in the script section, should immediately be applied to the alias. After it's filled, though, you might have to kick-start the package processing with EvaluatePackage(), that's why I put it in there.

 

Just FYI, if you wanted to fill the alias with the player or any other specific person or thing, you can do that, too. But that's not necessary in this case.

 

Don't forget to check Start Game Enabled on the main quest tab. I'm pretty sure the aliases only work if the quest is running.

 

You won't believe how thankful I am right now. I absolutely couldn't get this to work but it works completely now. I was using ForceRefTo on a regular "Alias" property instead of a "Reference Alias."



#6
Xander9009

Xander9009

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,340 posts

I'm glad it's working :)







Also tagged with one or more of these keywords: papyrus, script, idle, idles, ai packages, package

IPB skins by Skinbox
Page loaded in: 1.152 seconds