Difference between revisions of "HPL3/Areas/Trigger Area"

From Frictional Wiki
Jump to navigation Jump to search
(Created page with "== Overview == The Trigger area runs a callback function when an entity collides with it. == Properties == === CC_Entities === This is a list of all entities that can trigger...")
 
(Rewrote article to be more concise and added missing information)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
The Trigger area runs a callback function when an entity collides with it.
+
The Trigger area runs a callback function when an entity collides or otherwise interacts with it.
  
 
== Properties ==
 
== Properties ==
=== CC_Entities ===
+
=== Base ===
This is a list of all entities that can trigger the callback, separated by commas or spaces. <code>player</code> refers to the player character.
+
* '''BlockLineOfSight''': Blocks line of sight.
 +
* '''EventInstanceTag''': A tag used by the event system to group objects.
 +
* '''UserVar''': Arbitrary user variable. Acessable by calling the script function <code>Entity_GetVar<type>()</code>
  
=== CC_Funcs ===
+
=== Collide Callbacks ===
Includes a list of functions that will run when the area is triggered.
+
* '''CC_Entities''': A list separated by commas or spaces of all entities that can trigger the callback. ''player'' is the player character.
 +
* '''CC_Funcs''': A list of functions that will run when the area is triggered. Press copy to generate a callback function and copy to the clipboard
 +
 
 +
=== Attachment ===
 +
* '''ParentAttachEntity''': The name of an entity that this soundscape is parented to.
 +
* '''ParentAttachUseRotation''': If the rotation of the parent should affect the soundscape.
 +
* '''ParentAttachBody''': The name of the body in the parent entity to attach to.
 +
* '''ParentAttachLocked''': Locks the area to the parent and disables local movement.
 +
 
 +
=== Basic Callbacks ===
 +
* '''PlayerLookAtCallback''': A function that will run when looking at the entity. Press generate to generate a name for this text field.
 +
* '''PlayerLookAtCallbackAutoRemove''': Removes the callback after it fires once.
 +
* '''PlayerLookAtCheckCenterOfScreen''': Only counts as looked if the entity is in the center of the screen.
 +
* '''PlayerLookAtCheckRayInIntersection''': Only counts as looked at if their is a clear line of sight, i.e. not through a transparent object. ''Can return false negatives, especially if '''PlayerLookAtCheckCenterOfScreen''' is disabled.''
 +
* '''PlayerLookAtMaxDistance''': Max distance an entity can be from the area. Values lower than 0 default to max distance.
 +
* '''PlayerLookAtCallbackDelay''': Time in seconds to delay the callback
 +
* '''PlayerInteractCallback''': Callback when the player interacts with the entity, i.e. grabbing or using. Press generate to generate a name for this text field.
 +
* '''PlayerInteractCallbackAutoRemove''': Removes the callback after it fires once.
 +
 
 +
=== Interaction ===
 +
Settings used when the player interacts with the entity by clicking on it.
 +
* '''CanInteractWithoutCallback''': Allows the area to be interacted with despite having an empty callback.
 +
* '''MaxFocusDistance''': Maximum distance a player can be to interact. Values lower than 0 are set to the default.
 +
* '''CustomInteraction''': The icon shown when interaction is possible.
  
 
== Callback function syntax ==
 
== Callback function syntax ==

Revision as of 22:57, 25 January 2024

Overview

The Trigger area runs a callback function when an entity collides or otherwise interacts with it.

Properties

Base

  • BlockLineOfSight: Blocks line of sight.
  • EventInstanceTag: A tag used by the event system to group objects.
  • UserVar: Arbitrary user variable. Acessable by calling the script function Entity_GetVar<type>()

Collide Callbacks

  • CC_Entities: A list separated by commas or spaces of all entities that can trigger the callback. player is the player character.
  • CC_Funcs: A list of functions that will run when the area is triggered. Press copy to generate a callback function and copy to the clipboard

Attachment

  • ParentAttachEntity: The name of an entity that this soundscape is parented to.
  • ParentAttachUseRotation: If the rotation of the parent should affect the soundscape.
  • ParentAttachBody: The name of the body in the parent entity to attach to.
  • ParentAttachLocked: Locks the area to the parent and disables local movement.

Basic Callbacks

  • PlayerLookAtCallback: A function that will run when looking at the entity. Press generate to generate a name for this text field.
  • PlayerLookAtCallbackAutoRemove: Removes the callback after it fires once.
  • PlayerLookAtCheckCenterOfScreen: Only counts as looked if the entity is in the center of the screen.
  • PlayerLookAtCheckRayInIntersection: Only counts as looked at if their is a clear line of sight, i.e. not through a transparent object. Can return false negatives, especially if PlayerLookAtCheckCenterOfScreen is disabled.
  • PlayerLookAtMaxDistance: Max distance an entity can be from the area. Values lower than 0 default to max distance.
  • PlayerLookAtCallbackDelay: Time in seconds to delay the callback
  • PlayerInteractCallback: Callback when the player interacts with the entity, i.e. grabbing or using. Press generate to generate a name for this text field.
  • PlayerInteractCallbackAutoRemove: Removes the callback after it fires once.

Interaction

Settings used when the player interacts with the entity by clicking on it.

  • CanInteractWithoutCallback: Allows the area to be interacted with despite having an empty callback.
  • MaxFocusDistance: Maximum distance a player can be to interact. Values lower than 0 are set to the default.
  • CustomInteraction: The icon shown when interaction is possible.

Callback function syntax

This is the basic syntax for a collision callback function.

bool FunctionName(const tString &in asParent, const tString &in asChild, int alState)
{
    if(alState == 1) // 1 = entering area, -1 = leaving area
    {
        // Insert code here
    }
    return false;
}