HPL3/Amnesia: Rebirth/Scripting/Agents/Ghouls

From Frictional Wiki
< HPL3‎ | Amnesia: Rebirth‎ | Scripting
Revision as of 11:51, 14 November 2020 by Crater (talk | contribs) (minor error)
Jump to navigation Jump to search


Wip icon.png Basic overview of agent


Contents

Basic Overview

Modes vs Commands

Each mode contains a subset of behaviors. They define what the 'default' action for the agent should be and can be used to give different agents of the same type unique behaviors.

A command is an order issued to the agent independent of the current mode. They can be used to override the agents current action.

Unlike previous HPL titles, agents should only be controlled through modes and commands, NOT through changing the agent state.

General Functions

Ghoul_Mode_Set

void Ghoul_Mode_Set(const tString &in asAgentName, eGhoulMode aMode, bool abForce = false)

Puts the ghoul into a mode, which determines its behavior when it's not reacting to the player's presence.

Parameters

  • asAgentName (tString) — Name of the agent.
  • aMode (tString) — Which mode to put the ghoul in.
  • abForce (bool) — If true the ghoul will switch the behavior instantly regardless of state, otherwise it will do so more naturally on the next best opportunity.

Returns:

  • void

Modes

eGhoulMode_Idle

This is the ghouls default mode. In this mode the ghoul will remain stationary when not reacting to the player.

TODO - Verify there are no idle specific functions.

eGhoulMode_Patrol

A ghoul in patrol mode will move to specified patrol path nodes when not reacting to the player.

Ghoul_ModePatrol_Setup

void Ghoul_ModePatrol_Setup(const tString &in asAgentName, bool abRandom = false, eGhoulSpeed aSpeed = eGhoulSpeed_Walk)

Sets up the basic parameters for the ghoul's patrol mode.

Parameters

  • asAgentName (tString) — Name of the agent.
  • abRandom (bool) — If nodes should be picked randomly, otherwise they will be picked in the order added.
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.

Returns:

  • void

Ghoul_ModePatrol_AddNode

void Ghoul_ModePatrol_AddNode(const tString &in asAgentName, const tString&in asNodeName, float afMinWaitTime = 0, float afMaxWaitTime= - 1,
								const tString &in asAnimName = "", bool abLoopAnim = false)

Adds a node to the list of nodes to patrol in patrol mode.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asNodeName (tString) — Name of the node.
  • afMinWaitTime (float) — The minimum amount of time how long the ghoul should wait at this node.
  • afMaxWaitTime (float) — The maximum amount of time how long the ghoul should wait at this node.
  • asAnimName (tString) — Name of the animation that should play when the ghoul reaches this node.
  • abLoopAnim (bool) — If the animation should loop.

Returns:

  • void

Ghoul_ModePatrol_ClearNodes

void Ghoul_ModePatrol_ClearNodes(const tString &in asAgentName)

Removes all the nodes from the patrol mode list.

Parameters

  • asAgentName (tString) — Name of the agent.

Returns:

  • void

Ghoul_ModePatrol_SetSpeed

void Ghoul_ModePatrol_SetSpeed(const tString &in asAgentName, eGhoulSpeed aSpeed = eGhoulSpeed_Walk)

Sets the speed of movement for the current patrol mode.

Parameters

  • asAgentName (tString) — Name of the agent.
  • eGhoulSpeed (tString) — Name of the agent.

Returns:

  • void

eGhoulMode_RandomWanderArea

A ghoul in the random wander area will move to random nodes within a specified area when not reacting to the player.

Ghoul_ModeRandomWanderArea_Setup

void Ghoul_ModeRandomWanderArea_Setup(const tString &in asAgentName, const cVector3f &in avAreaCenter, float afMinRadius, float afMaxRadius)

Makes the ghoul randomly wander inside a specified area.

Parameters

  • asAgentName (tString) — Name of the agent.
  • avAreaCenter (cVector3f) — The center of the area.
  • afMinRadius (float) — The closest distance the nodes can be picked from.
  • afMaxRadius (float) — The furthest distance the nodes can be picked from.

Returns:

  • void

eGhoulMode_Guard

TODO - Guard mode overview TODO - Guard vs Enthralled

Ghoul_ModeGuard_Setup

void Ghoul_ModeGuard_Setup(const tString &in asAgentName, const tString &in asLookAtEntity, const tString &in asStandPosEntity, const tString &in asIdleAnim,
						   const tString &in asIdleSound, const tString &in asDisturbAnim, eGhoulSpeed aSpeedState = eGhoulSpeed_FastWalk)

Makes the ghoul enter the Guard state.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asLookAtEntity (tString) — Name of the entity to be turned toward.
  • asStandPosEntity (tString) — Name of the entity to stand at.
  • asIdleAnim (tString) — Name of the idle animation.
  • asIdleSound (tString) — Name of the sound entity placed in the map that will be played when guarding.
  • asDisturbAnim (tString) — Name of the disturbed animation.
  • aSpeedState (eGhoulSpeed) — Speed state of the ghoul when moving to the stand pos.

Returns:

  • void

eGhoulMode_Enthralled

A ghoul in enthralled mode will move to a specified location when not reacting to the player.

Ghoul_ModeEnthralled_Setup

void Ghoul_ModeEnthralled_Setup(const tString &in asAgentName, const tString &in asLookAtEntity, const tString &in asStandPosEntity, const tString &in asIdleAnim)

Puts the ghoul in the enthralled state.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asLookAtEntity (tString) — Name of the entity to be turned toward.
  • asStandPosEntity (tString) — Name of the entity to stand at.
  • asIdleAnim (tString) — Name of the idle animation.

Returns:

  • void

eGhoulMode_Hunt

A ghoul in hunt mode will be always hunting the player.

TODO - Verify no hunt specific funcs

eGhoulMode_StalkThroughHoles

Mode behavior and functionality currently unknown.

Ghoul_ModeStalkThroughHoles_Setup

void Ghoul_ModeStalkThroughHoles_Setup(const tString &in asAgentName, const tString &in asHoleNetwork, const tString &in asPlayerPath = "", const tString &in asHoleConnections = "", bool abHideUntilDisturbed = false)

Sets up the basic parameters for the StalkThroughHoles mode.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asHoleNetwork (tString) — The name of the group of ghoul holes the ghoul should move between, use wildcard *.
  • asPlayerPath (tString) — The name of the group of nodes that represent the general path the player will take, used to determine if a hole is ahead or behind the player, use wildcard *.
  • asHoleConnections (tString) — The name of a group of areas that represent the connections between holes, the ghoul will move along these areas and make noise, use wildcard *.
  • abHideUntilDisturbed (bool) — If the ghoul shouldn't emerge unless the player makes noise.

Returns:

  • void

eGhoulMode_Trapped

TODO - Verify that this mode does nothing.

Commands

General

Ghoul_Command_Remove

void Ghoul_Command_Remove(const tString &in asAgentName, bool abForce = true)

Removes the current command that is set for the ghoul to execute.

Parameters

  • asAgentName (tString) — Name of the agent.
  • abForce (bool) — If the ghoul should abandond the command immediately, or wait to finish what it's doing.

Returns:

  • void

Ghoul_CommandRetreat_Execute

void Ghoul_CommandRetreat_Execute(const tString &in asAgentName, bool abForce = false, bool abAutomaticRetreat = true, const cVector3f &in avPos = cVector3f_Zero, const tString &in asCompletedCallback = "")

Executes the retreat command.

Parameters

  • asAgentName (tString) — Name of the agent.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • abAutomaticRetreat (bool) — If the ghoul should pick an appropriate node to retreat to, otherwise a position needs to be provided with the avPos argument.
  • avPos (cVector3f) — The position the ghoul should retreat to, will only be considered when abAutomaticRetreat is true.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul_CommandUseDoor_Execute

void Ghoul_CommandUseDoor_Execute(const tString &in asAgentName, const tString &in asDoorName, bool abBreak = false, bool abForce = false, eGhoulSpeed aSpeed = eGhoulSpeed_Walk, const tString &in asCompletedCallback = "")

Executes the command that makes the ghoul move to and interact with a door.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asDoorName (tString) — The name of the door the ghoul should interact with.
  • abBreak (bool) — If the ghoul should break the door, otherwise it will attempt to open it.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul_CommandSmell_Execute

void Ghoul_CommandSmell_Execute(const tString &in asAgentName, bool abForce = false, const tString &in asCompletedCallback = "")

Executes the smell command.

Parameters

  • asAgentName (tString) — Name of the agent.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul_CommandWakeUp_Execute

void Ghoul_CommandWakeUp_Execute(const tString &in asAgentName, const tString &in asWakeUpAnim, bool abForce = false, const tString &in asCompletedCallback = "")

Executes the wake up command.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asWakeUpAnim (tString) — Name of the wake up animation.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Patrol Commands

Ghoul_CommandPatrol_AddNode

void Ghoul_CommandPatrol_AddNode(const tString &in asAgentName, const tString&in asNodeName, float afMinWaitTime = 0, float afMaxWaitTime= - 1,
								const tString &in asAnimName = "", bool abLoopAnim = false)

Adds a node to the list of patrol nodes for a patrol command.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asNodeName (tString) — Name of the node.
  • afMinWaitTime (float) — The minimum amount of time how long the ghoul should wait at this node.
  • afMaxWaitTime (float) — The maximum amount of time how long the ghoul should wait at this node.
  • asAnimName (tString) — Name of the animation that should play when the ghoul reaches this node.
  • abLoopAnim (bool) — If the animation should loop.

Returns:

  • void

Ghoul_CommandPatrol_ClearNodes

void Ghoul_CommandPatrol_ClearNodes(const tString &in asAgentName)

Removes all the nodes from the patrol command list.

Parameters

  • asAgentName (tString) — Name of the agent.

Returns:

  • void

Ghoul_CommandPatrol_SetSpeed

void Ghoul_CommandPatrol_SetSpeed(const tString &in asAgentName, eGhoulSpeed aSpeed = eGhoulSpeed_Walk)

Sets the speed of movement for the current patrol command.

Parameters

  • asAgentName (tString) — Name of the agent.
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.

Returns:

  • void

Ghoul_CommandPatrol_SetSpeed

void Ghoul_CommandPatrol_SetSpeed(const tString &in asAgentName, eGhoulSpeed aSpeed = eGhoulSpeed_Walk)

Sets the speed of movement for the current patrol command.

Parameters

  • asAgentName (tString) — Name of the agent.
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.

Returns:

  • void

Ghoul_CommandPatrol_Execute

void Ghoul_CommandPatrol_Execute(const tString &in asAgentName, bool abForce = false, int alLoopCount = 1, bool abRandom = false, eGhoulSpeed aSpeed = eGhoulSpeed_Walk, const tString &in asCompletedCallback = "")

Executes the patrol command.

Parameters

  • asAgentName (tString) — Name of the agent.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • alLoopCount (int) — How many times the ghoul should patrol the node set, only positive values are allowed, use the patrol mode for infinite loops.
  • abRandom (bool) — If nodes should be picked randomly, otherwise they will be picked in the order added.
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul_CommandSmellPatrol_Execute

void Ghoul_CommandSmellPatrol_Execute(const tString &in asAgentName, bool abForce = false, int alLoopCount = 1, bool abRandom = false, eGhoulSpeed aSpeed = eGhoulSpeed_Walk, const tString &in asCompletedCallback = "")

Executes the smell patrol command, where the ghoul will patrol while sniffing. If the ghoul actually catches the player's scent and begins tracking them down, the smell patrol becomes a normal patrol.

Parameters

  • asAgentName (tString) — Name of the agent.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • alLoopCount (int) — How many times the ghoul should patrol the node set, only positive values are allowed, use the patrol mode for infinite loops.
  • abRandom (bool) — If nodes should be picked randomly, otherwise they will be picked in the order added.
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul Hole Commands

Ghoul_CommandGoToSpecificHole_Execute

void Ghoul_CommandGoToSpecificHole_Execute(const tString &in asAgentName, const tString &in asHole, bool abForce = false, bool abInstant = false, bool abDeactivateAfter = false, eGhoulSpeed aSpeed = eGhoulSpeed_Walk, const tString &in asCompletedCallback = "")

Executes the command that makes the ghoul move to and enter a specified ghoul hole.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asHole (tString) — The name of the hole the ghoul should retreat to.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • abInstant (bool) — If the ghoul should start hiding in a hole instantly, being teleported then and hidden.
  • abDeactivateAfter (bool) — ?
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul_CommandGoToHole_Execute

void Ghoul_CommandGoToHole_Execute(const tString &in asAgentName, const cVector3f &in avPos, bool abForce = false, bool abInstant = false, bool abDeactivateAfter = false,
									bool abClosest = true, eGhoulSpeed aSpeed = eGhoulSpeed_Walk, float afMinRadius = -1.0f, float afMaxRadius = -1.0f, bool abOnlyFree = false,
									bool abOnlyOutOfPlayerSight = false, const tString &in asCompletedCallback = "")

Executes the command that makes the ghoul move to and enter a hole based on certain parameters.

Parameters

  • asAgentName (tString) — Name of the agent.
  • avPos (cVector3f) — The position to which distances will be calculated.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • abInstant (bool) — If the ghoul should start hiding in a hole instantly, being teleported then and hidden.
  • abDeactivateAfter (bool) — ?
  • abClosest (bool) — If the closest node to avPos should be picked, otherwise a random node that fits the other parameters will be chosen.
  • aSpeed (eGhoulSpeed) — The speed with which the ghoul will move.
  • afMinRadius (float) — The minimum distance from avPos that a ghoul hole can be at.
  • afMaxRadius (float) — The maximum distance from avPos that a ghoul hole can be at.
  • abOnlyFree (bool) — If only free holes (that aren't occupied by other ghouls) should be chosen.
  • abOnlyOutOfPlayerSight (bool) — If only holes that are out of the player's sight should be chosen.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul_CommandEmergeFromHole_Execute

void Ghoul_CommandEmergeFromHole_Execute(const tString &in asAgentName, const tString &in asHole, bool abForce = false, const tString &in asCompletedCallback = "", const tString &in asCustomAnim = "", const tString &in asCustomAnimEntity = "")

Executes the command that makes the ghoul emerge from a hole. If the ghoul is not hiding, it will be teleported to the hole and play the emerge animation.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asHole (tString) — The name of the hole the ghoul should retreat to.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).
  • asCustomAnim (tString) — Name of the custom animation.
  • asCustomAnimEntity (tString) — Entity to play the custom anim at.

Returns:

  • void

Threaten Player Commands

Ghoul_CommandThreatenPlayer_Execute

void Ghoul_CommandThreatenPlayer_Execute(const tString &in asAgentName, int afAggroLevel = 1, bool abThreatenGestures = true, bool abAdjustSpeed = false, float afMinSpeedDist = -1, float afMaxSpeedDist = -1, bool abForce = false, const tString &in asCompletedCallback = "")

?

Parameters

  • asAgentName (tString) — Name of the agent.
  • afAggroLevel (float) — The level of aggressiveness, values 0-7 with 0 being stopped, and 7 being the most aggressive.
  • abThreatenGestures (bool) — If the ghoul should use threatening gestures.
  • abAdjustSpeed (bool) — If the ghoul should slow down as it appraoches the player.
  • afMinSpeedDist (float) — When using abAdjustSpeed, the distance at which the ghoul will reach minimum speed, -1 is default,
  • afMaxSpeedDist (float) — When using abAdjustSpeed, the distance at which the ghoul will have maximum speed, -1 is default.
  • abForce (bool) — If the command should be executed immediately, or at a more appropriate time.
  • asCompletedCallback (tString) — The function that will be called after the command is completed, syntax: void Func(const tString &in asEntity).

Returns:

  • void

Ghoul_CommandThreatenPlayer_SetAggressiveness

void Ghoul_CommandThreatenPlayer_SetAggressiveness(const tString &in asAgentName, int afAggroLevel)

?

Parameters

  • asAgentName (tString) — Name of the agent.
  • afAggroLevel (float) — The level of aggressiveness, values 0-7 with 0 being stopped, and 7 being the most aggressive.

Returns:

  • void

Callbacks

Ghoul_SetCallback_EmergeCompleted

void Ghoul_SetCallback_EmergeCompleted(const tString &in asAgentName, const tString &in asFunction, bool abAutoRemove = false)

Set a callback in the map to be called once the ghoul has emerged from hole.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asFunction (tString) — Name of the function, syntax: void Func(const tString &in asGhoul, const tString &in asHole).
  • abAutoRemove (bool) — If the callback should automatically be removed.

Returns:

  • void

Ghoul_SetCallback_EnterHideInHole

void Ghoul_SetCallback_EnterHideInHole(const tString &in asAgentName, const tString &in asFunction, bool abAutoRemove = false)

Set a callback in the map to be called when the ghoul starts to hide in a hole.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asFunction (tString) — Name of the function, syntax: void Func(const tString &in asEntity, const tString &in asHoleName).
  • abAutoRemove (bool) — If the callback should automatically be removed.

Returns:

  • void

Ghoul_SetCallback_EnterHunt

void Ghoul_SetCallback_EnterHunt(const tString &in asAgentName, const tString &in asFunction, bool abAutoRemove = false)

Sets the name of the callback called when entering hunt.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asFunction (tString) — Name of the function, syntax: void Func().
  • abAutoRemove (bool) — If the callback should automatically be removed.

Returns:

  • void

Ghoul_SetCallback_ThrowAnimationOver

void Ghoul_SetCallback_ThrowAnimationOver(const tString &in asAgentName, const tString &in asFunction, bool abAutoRemove = false)

Sets the name of the callback called after throwing the player.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asFunction (tString) — Name of the function, syntax: void Func().
  • abAutoRemove (bool) — If the callback should automatically be removed.

Returns:

  • void

Ghoul_SetCallback_EnterIdle

void Ghoul_SetCallback_EnterIdle(const tString &in asAgentName, const tString &in asFunction, bool abAutoRemove = false)

Adds a callback for when the ghoul enters the idle state.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asFunction (tString) — Name of the function, syntax: void Func().
  • abAutoRemove (bool) — If the callback should automatically be removed.

Returns:

  • void

Ghoul_SetCallback_Alerted

void Ghoul_SetCallback_Alerted(const tString &in asAgentName, const tString &in asFunction)

Adds a callback for when the ghoul is alerted.

Parameters

  • asAgentName (tString) — Name of the agent.
  • asFunction (tString) — Name of the function, syntax: void Func(const tString &in asEntity).

Returns:

  • void

unsorted funcs

Wip icon.png Temporary


/** * Puts a ghoul in the EatMeat state and destroys the specified meat. * * @param asAgentName, name of the agent * @param asMeatEntity, name of the meat to be destroyed **/ void Ghoul_EatMeat(const tString &in asAgentName, const tString &in asMeatEntity)

PLACEHOLDER

Return Type Function and Description
void Button_Blink(const tString &in asName)
Makes the button blink in accordance to how it is set up in the ent file

PLACEHOLDER

Billboard_SetBrightness

void Billboard_SetBrightness(const tString &in asBillboardName,
                             float afBrightness)

Sets the brightness of a billboard

Parameters

  • asBillboardName (tString) — name of billboard. Can contain wildcards.
  • afBrightness (float) — new brightness

Returns:

  • void