NPCs

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting(Redirected from HPL3/NPCs)
Jump to navigation Jump to search


SOMA includes cScrAgentHumanoidNPC : cScrAgentHumanoid in script/agents/Agent_Humanoid_NPC.hps.

Its Init sets mbCanBeTalkedTo to false and clears msVoiceName. Its SetupAfterLoad calls the parent setup method and creates a head-tracker component.

The humanoid NPC extends the humanoid agent with NPC animation and conversation behavior. NPC_SetMainAnimation sets its main animation and disables movement animations; NPC_PlayExtraAnimation plays an additional animation and returns to the main animation when finished.

Before you start

  1. Open the map script inside your own mod. Keep its generated includes, cScrMap : iScrMap class and callback structure. See Add your first script if you have not edited a map script yet.
  2. Add the helper include shown below alongside the script’s other includes.
  3. Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.

Follow the stock example

#include "helpers/helper_ai.hps"

NPC_SetMainAnimation

Sets and plays the main animation of the NPC. This will also turn off any movement animations.

Parameter Meaning
asNpcName name of the NPC. Wildcard supported.
asAnim The name of the animation
abPlayTransition If a transition animation should be played.
asCallbackFunc name of callback function. Only used if there is a transition animation. Syntax void Func(const tString &in asEntityName, const tString &in asAnimName)
afFadeTime time it takes to fade to the animation.
abGlobalSpace if the animation takes place in global space

In maps/chapter04/04_02_tau_inside/04_02_tau_inside.hps, SOMA calls NPC_SetMainAnimation as follows.

NPC_SetMainAnimation("Lindwall","idle_talk");
Parameter Value in this stock call
asNpcName "Lindwall"
asAnim "idle_talk"

This is an excerpt from that stock script; its referenced names and variables belong to that script.

NPC_PlayExtraAnimation

Plays an extra animation for the NPC. Will return to main animation (see NPC_SetMainAnimation) when done.

Parameter Meaning
asNpcName name of the NPC. Wildcard supported.
asAnim The name of the animation
afFadeTime The time it takes to fade in the animation.
asCallbackFunc name of callback function. Syntax void Func(tString &in asEntityName, tString &in asAnimName)
abGlobalSpace the animation will be played in global space coordinates (?)

Check your change

Save the script and restart the map in development mode with F5. If the script fails, open F1 and use Show Error List or Show HPL Log. See the development loop for the launch and debugging steps.

See also