Jump to content

Papyrus adding AI Packages or Animations question


OneOnOne1162

Recommended 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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

  • Recently Browsing   0 members

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