Jump to content

Force an AI package?


CinnamonMods

Recommended Posts

Generally the way you control AI packages is through script variables. Give the NPC a script that has two variables, like SpeakingEnable and GoToPrimmEnable. Have your script initially set both of these to zero.

 

scn zzNPCScript

short DoOnce

int SpeakingEnable
int GoToPrimmEnable

Begin GameMode
If(DoOnce != 1)
Set SpeakingEnable to 0
Set GoToPrimmEnable to 0
Set DoOnce to 1
Endif
End

When you want the NPC to speak, use a script to set SpeakingEnable to 1 and GoToPrimmEnable to 0, followed by zzNPCRef.evp (replace zzNPCRef with your actual NPC's ref ID, of course). The evp command is evaluate package, which will force the NPC to go down through his or her AI package list until they find a package to run.

 

You also need to add a condition to each package so that it checks the appropriate variable. Your force conversation package should check SpeakingEnable == 1 and your GoToPrimm package should check GoToPrimmEnable == 1.

 

The NPC will evaluate which package to run by simply going down the list and running the first package that it comes to that has all of its conditions true. This is why it is very important to add the variable conditions. Without the condition to check the script variable SpeakingEnable == 1, this package will always run first and the travel package will never run. By having the speaking package only execute when the variable is set, setting SpeakingEnable to 0 and GoToPrimmEnable to 1 and then doing an evp will force the NPC to evaluate the speaking package, decide that its conditions are not met, then skip down to the travel package, decide its conditions are met, and running that package.

 

ETA:

 

To make this a little more clear, in the result script of your NPC's last line of dialog, add this:

 

Set SpeakingEnable to 0
Set GoToPrimmEnable to 1

zzNPCRef.evp

 

This will set the variable and force the NPC to evaluate their packages so that they will execute the travel package and go to Primm.

Edited by madmongo
Link to comment
Share on other sites

 

An NPC I made has two AI package.
One that forces a conversation and the other to make him walk to Primm.
It does the first package but after that, the NPC just stands there. How can I make the other package activate once he's done talking?

 

 

 

If you can force the conversation ... you can force the npc travel.

Link to comment
Share on other sites

The AI packages are sorted top-down. So the first package that has it's conditions pass, is the package that runs. For example:

PackageWaitAroundMarker (No conditions)
PackageMoveAfterWaiting (Get Global gWaitedAtMarker == 1)

 

 

Even if gWaitedAtMarker is set to 1, that package will never run. The first one will always be used by the NPC, since it's the first to pass it's conditions (of which there are none, so it automatically passes).

Link to comment
Share on other sites

Sometimes instead of the npc having a bunch of packages with variables to make them run.

It is better to just add and remove packages ... that way they only have one to work with , therefore no conflicts.

 

Packages still exist if they are not in the npc AI package list.

So you make them ahead of time ... just give npc 1 starter package.

Then use lines in coding to say.

 

MyNPCRef.RemoveScriptPackage

MyNPCRef.AddScriptPackage MyNewPackage

 

Next time

 

MyNPCRef.RemoveScriptPackage

MyNPCRef.AddScriptPackage MyNextPackage

Link to comment
Share on other sites

  • Recently Browsing   0 members

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