User Tools

Site Tools


Sidebar

hpl3:community:scripting:script_functions

Engine Scripts

Basic Code

This page is here as a reference documentation available online covering the main script functions within HPL3. These top ones are included by default and are found within the hps_api.hps file located in the SOMA game directory. Further down you will find the functions referenced in the helper files.

This is a work-in-progress page. In time, it will contain much more, including all built-in functions, helper files and possibly more.

Entity

bool Entity_Exists(const tString &in asName);
bool Entity_Exists(tID aID);

Check if an entity exists in the level. Returns true if found.

asName - the name of the entity to search for.
OR
aID - the ID of the entity to search for.

bool Entity_SetActive(const tString &in asName, bool abActive);

Set whether an entity is active (visible and functioning) or not.

asName - the name of the entity (wildcards * are supported).
abActive - if active or not.

bool Entity_IsActive(const tString &in asName);

Check if an entity is active (visible and functioning) or not.

asName - the name of the entity (wildcards * are supported).

void Entity_SetInteractionDisabled(const tString &in asEntityName,  bool abX);

Sets whether an entity can be interacted with by the player or not.

asEntityName - the name of the entity (wildcards * are supported).
abX - true = interaction disabled | false = interaction enabled.

void Entity_SetMaxInteractionDistance(const tString &in asEntityName,  float afDistance);

Override the default max distance an entity can be interacted with.

asEntityName - the name of the entity (wildcards * are supported).
afDistance - the distance (in meters) the entity can be interacted with from.

bool Entity_IsInteractedWith(const tString &in asName);

Checks whether an entity is being interacted with.

asName - the name of the entity.

void Entity_Sleep(const tString &in asName);

Forces the entity to sleep. This disables Update and PostUpdate. Has no effect if entity is already sleeping.

asName - the name of the entity (wildcards * are supported).

void Entity_WakeUp(const tString &in asName);

Wakes a sleeping entity. This enabled Update and PostUpdate. Has no effect if entity is already awake.

asName - the name of the entity (wildcards * are supported).

bool Entity_IsSleeping(const tString &in asName);

Checks whether an entity is asleep.

asName - the name of the entity.

void Entity_SetAutoSleep(const tString &in asName,  bool abX);

Sets whether an entity should automatically sleep when it doesn't require updates.

asName - the name of the entity (wildcards * are supported).
abX - enabled or disabled.

bool Entity_GetAutoSleep(const tString &in asName);

Gets whether an entity automatically goes to sleep when it doesn't require updates.

asName - the name of the entity.

void Entity_SetIsOccluder(const tString &in asName,  bool abOccluder);

Set whether an entity is an occluder.

asName - the name of the entity (wildcards (*) are supported).
abOccluder - enabled or disabled.

bool Entity_IsOccluder(const tString &in asName);

Checks whether an entity is an occluder.

asName - the name of the entity.

void Entity_SetVarString(const tString&in asEntityName, const tString&in asVarName, const tString&in asX);
void Entity_SetVarBool(const tString&in asEntityName, const tString&in asVarName, bool abX);
void Entity_SetVarInt(const tString&in asEntityName, const tString&in asVarName, int alX);
void Entity_SetVarFloat(const tString&in asEntityName, const tString&in asVarName, bool afX);
void Entity_SetVarVector2f(const tString&in asEntityName, const tString&in asVarName, const cVector2f&in avX);
void Entity_SetVarVector3f(const tString&in asEntityName, const tString&in asVarName, const cVector3f&in avX);
void Entity_SetVarColor(const tString&in asEntityName, const tString&in asVarName, const cColor&in aX);

Sets a value of an entity variable.

asName - the name of the entity (wildcards * are supported).
asVarName - the name of the variable for the entity.
aX - the value of the variable.

void Entity_IncVarInt(const tString&in asEntityName,  const tString&in asVarName,  int alX);
void Entity_IncVarFloat(const tString&in asEntityName,  const tString&in asVarName,  float afX);
void Entity_IncVarVector2f(const tString&in asEntityName,  const tString&in asVarName,  const cVector2f&in avX);
void Entity_IncVarVector3f(const tString&in asEntityName,  const tString&in asVarName,  const cVector3f&in avX);

Increments a value of an entity variable.

asName - the name of the entity (wildcards * are supported).
asVarName - the name of the variable for the entity.
aX - the value to add.

tString Entity_GetVarString(const tString&in asEntityName,  const tString&in asVarName);
bool Entity_GetVarBool(const tString&in asEntityName,  const tString&in asVarName);
int Entity_GetVarInt(const tString&in asEntityName,  const tString&in asVarName);
float Entity_GetVarFloat(const tString&in asEntityName,  const tString&in asVarName);
cVector2f Entity_GetVarVector2f(const tString&in asEntityName,  const tString&in asVarName);
cVector3f Entity_GetVarVector3f(const tString&in asEntityName,  const tString&in asVarName);
cColor Entity_GetVarColor(const tString&in asEntityName,  const tString&in asVarName);

Gets the value of an entity variable.

asName - the name of the entity.
asVarName - the name of the variable for the entity.

bool Entity_AddCollideCallback(const tString &in asParentName,  const tString &in asChildName,  const tString &in asFunction);

Adds a callback between two entities (objects, areas, player etc) when they collide with each other. Collisions include when “uncolliding” as well. Wildcards * are supported in names.

asParentName - the first entity (for player collisions, this is always the player)
asChildName - the second entity to check against.
asFunction - name of the callback function for when these objects collide.

Callback syntax:
FunctionName(const tString &in asParent, const tString &in asChild, int alState)
alState - 1 = colliding, -1 = uncolliding, 0 = both.

Returns a boolean of whether the callback is repeated upon completetion. If true, callback can be called again. If false, callback is removed.
Abbreviation syntax for the callback function code snippet: clbCollide

bool Entity_RemoveCollideCallback(const tString &in asParentName,  const tString &in asChildName);

Removes a callback for entity collisions. Wildcards * supported in names.

asParentName - the first entity (for player collisions, this is always player)
asChildName - the second entity.

bool Entity_GetCollide(const tString &in asEntityA,  const tString &in asEntityB);

Check whether two entities are already colliding. Wildcards * are NOT supported.

asEntityA - the first entity.
asEntityB - the second entity.

Returns true if colliding, else false.

void Entity_SetCollideCharacter(const tString &in asEntityName,  bool abActive);

Enable/disable an entity's collision with a character for all bodies in the entity.

asEntityName - the name of the entity. Wildcards * are supported.
abActive - true = collision on, false = collision off.

void Entity_SetCollide(const tString &in asEntityName,  bool abActive);

Enable/disable an entity's collision for all bodies in the entity.

asEntityName - the name of the entity. Wildcards * are supported.
abActive - true = collision on, false = collision off.

void Entity_SetEffectsActive(const tString &in asEntityName,  bool abActive,  bool abFadeAndPlaySounds);

Enables/disables whether an entity uses effects.

asEntityName - name of the entity/prop. Wildcards * are supported.
abActive - true = activates effects, false = deactivates effects.
abFadeAndPlaySounds - if effects should fade in/out and play sounds.

void Entity_SetReflectionVisibility(const tString &in asEntityName,  bool abVisibleInReflection,  bool abVisibleInWorld);

Sets whether an entity is drawn in reflections or not, and/or in the real world or not.

asEntityName - the name of the entity. Wildcards * are supported.
abVisibleInReflection - whether the entity is drawn in reflections.
abVisibleInWorld - whether the entity is drawn in the real world.

void Entity_SetEffectBaseColor(const tString &in asEntityName, const cColor&in aColor);

Sets the base color for the entity's effects.

asEntityName - the name of the entity. Wildcards * are supported.
aColor - the color all effects will be multiplied with.

void Entity_FadeEffectBaseColor(const tString &in asEntityName, const cColor&in aColor,  float afTime);

Fades the base color for the entity's effects.

asEntityName - the name of the entity. Wildcards * are supported.
aColor - the color all effects will be faded to.
afTime - the time in seconds the fade takes to finish.

void Entity_SetColorMul(const tString &in asEntityName,  const cColor&in aColor);

Sets the color multiplier of the entity.

asEntityName - the name of the entity. Wildcards * are supported.
aColor - the color to set the multiplier to.

void Entity_AddForce(const tString &in asEntityName,  const cVector3f &in avForce,  bool abLocalSpace,  bool abOnlyMainBody);

Adds a push force to the entity.

asEntityName - the name of the entity. Wildcards * are supported.
avForce - the force to add.
abLocalSpace - true = local force is added relative to the rotation of the entity, false = global force is added in a world space
abOnlyMainBody - true = force is added only to the main body of the entity, false = force is added to all bodies of the entity.

void Entity_AddForceFromEntity(const tString &in asEntityName,  const tString &in asForceEntityName,  float afForce,  bool abOnlyMainBody);

Adds a push force to the entity away from another entity.

asEntityName - the name of the entity. Wildcards * are supported.
asForceEntityName - the name of the entity to push away from.
afForce - magnitude of the force. Negative values attract the entity to the force entity.

WORK IN PROGRESS

Helper Files

Helper files are seperate .hps files which contain many further functions and codes which are of use to the developer. The following are grouped by their helper file name. In order to use these, you need to specify with an #include <helper.hps> at the top of your code, which is done automatically when you save your map for the first time. These codes are found in SOMA/script/helpers/ , and are grouped on this page under which one you require. To search this, from most browsers, you can press Ctrl+F and start typing in a term.

A.I

The following codes require #include “helpers/helper_ai.hps”.

void Agent_FaceEntity(const tString &in asAgentName, const tString &in asLookAtTarget);

Instantly sets the yaw of the agent to make it look at the specified entity.

asAgentName - Name of the agent. Wildcard (*) supported.
asLootAtTarget - Name of entity to look at.

bool Agent_PlayerDetected(const tString &in asAgentName);

Gets if the player has been detected by an agent. Returns true if so.

asAgentName - Name of the agent. Wildcard (*) supported.

void Agent_RevealPlayerPosition(const tString &in asAgentName, bool bForceRedetect=false);

Reveals the player's current position to the agent.

asAgentName - name of the agent. Wildcard (*) supported.

void Agent_SetAutoDisableCallback(const tString &in asAgentName, const tString &in asCallbackFunc);

Sets the function that is called when the disabling made by Agent_SetAutoDisableWhenOutOfSightActive(); happens

asAgentName - name of the agent. Wildcard (*) supported.
asCallbackFunc - Function called when the disabling happens.
Callback syntax: void MyFunc(const tString&in asEntityName)

void Agent_SetAutoDisableWhenOutOfSightActive(const tString &in asAgentName, bool abActive, float afMinDistance);

When active, the agent will be a disabled (SetActive(false)) when a certain distance away from the player and no longer seen.

asAgentName - name of the agent.Wildcard (*) supported.
abActive - if the disabling is active (should be disabled = true)
afMinDistance - The minimum distance from the player for this to happen.

void Agent_SetSensesActive(const tString &in asAgentName, bool abX);

Set if the agent should have its senses (hearing/vision/etc) enabled.

asAgentName - name of the agent. Wildcard (*) supported.
abX - If the senses should be active.

void Agent_SetStaticCollider(const tString &in asAgentName, bool abX);

Set if the agent will collide with the environment (objects and stuff will still collide with it!)

asAgentName - name of the agent. Wildcard (*) supported.
abX - If the character should be static and NOT move about.

void Agent_SetViewRangeMul(const tString &in asAgentName, float afRangeMul);

Sets the view range multiplier of the specified agent

asAgentName - name of the agent. Wildcard (*) supported.
afRangeMul - the range multiplier to set.

void Agent_TeleportFeetToEntity(const tString &in asAgentName, const tString &in asTargetName);

Teleport the agent's foot position to a specific other entity.

asAgentName - name of the entity to teleport.
asTargetName - name of the entity to teleport to.

hpl3/community/scripting/script_functions.1445871307.txt.gz · Last modified: 2015/10/26 14:55 by mudbill