Difference between revisions of "HPL2/Engine Scripts"

From Frictional Wiki
Jump to navigation Jump to search
(→‎Insanity: Turns out it has the wrong return type defined in InitScriptFunctions, so it's only really broken at script level)
m (→‎Enemies: Apparently these AMFP functions are actually defined like this)
Line 2,020: Line 2,020:
  
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
void ChangeManPigPose(string &in asName, string &in asPoseType);
+
void ChangeManPigPose(string&in asName, string &in asPoseType);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 2,031: Line 2,031:
  
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
void SetTeslaPigFadeDisabled(string &in asName, bool abX);
+
void SetTeslaPigFadeDisabled(string&in asName, bool abX);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 2,042: Line 2,042:
  
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
void SetTeslaPigSoundDisabled(string &in asName, bool abX);
+
void SetTeslaPigSoundDisabled(string&in asName, bool abX);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 2,053: Line 2,053:
  
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
void SetTeslaPigEasyEscapeDisabled(string &in asName, bool abX);
+
void SetTeslaPigEasyEscapeDisabled(string&in asName, bool abX);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 2,064: Line 2,064:
  
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
void ForceTeslaPigSighting(string &in asName);
+
void ForceTeslaPigSighting(string&in asName);
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 05:38, 4 November 2024

This page documents all scripts available in Amnesia: The Dark Descent.

Note icon.png Note: Some of the functions require the Amnesia 1.3 or 1.5 update. Steam and other online store copies should be automatically updated. Other copies can get 1.3 here.

Directives

First off, #include "file.hps" can be used to programmatically merge together multiple separate files to make organizing scripts easier.


Alert icon.png Requires version 1.5

Engine scripts

Main

The following functions are the main hps functions that the HPL2 engine looks to run on certain events - similar to the C++ int main() function.

void OnStart();

The function that runs when the map is loaded for the first time.

void OnEnter();

The function that runs whenever the player enters a map.

void OnLeave();

The function that runs when the player leaves a map.

void OnGameStart();

This function is found in the global.hps file and the inventory.hps file, and is run when the game is first started by the player (ie via "Start New Game").

void OnUpdate(float afStep);

Alert icon.png Requires version 1.5

This function is executed for every game update or "tick". Can be used for rapid-firing updates instead of looping timers. Keep in mind that this can affect game performance if not used with care.

  1. afStep- Time elapsed in seconds since the last frame. Multiply speeds, distances etc. by this argument to avoid framerate dependence issues (for example: if you move something in this function with constant speed, it will move faster on computers which run the game with high FPS and slower on computers with low FPS).

General

float RandFloat(float afMin, float afMax);

Generates a random float.

  1. afMin - minimum value
  2. afMax - maximum value
int RandInt(int alMin, int alMax);

Generates a random int. Note: the maximum value is inclusive - the RandInt() function may return this value.

  1. alMin - minimum value
  2. alMax - maximum value
bool StringContains(string &in asString, string &in asSubString);

Checks whether a string contains the specified string.
Example: searching for "hello" in "hello world" would return true.

  1. asString - the string to check
  2. asSubString - the string to search for
string& StringSub(string &in asString, int alStart, int alCount);

Returns the substring in a string.
Example: in the string "frictional games rocks", using 4 as alStart and 6 as alCount would return "tional".

  1. asString - the string
  2. alStart - start position in the string
  3. alCount - amount of characters
int StringToInt(string &in asString);

Alert icon.png Requires version 1.3

If possible, returns an integer converted from a string, else returns 0.

  1. asString - String to convert.
float StringToFloat(string &in asString);

Alert icon.png Requires version 1.3

If possible, returns a float converted from a string, else returns 0.

  1. asString - String to convert.
bool StringToBool(string &in asString);

Alert icon.png Requires version 1.3

If possible, returns a boolean converted from a string, else returns false.

  1. asString - String to convert.

Mathematical Operations

float MathSin(float afX);

Alert icon.png Requires version 1.3

Returns the sine of the specified value.

  1. afX - Value to operate.
float MathCos(float afX);

Alert icon.png Requires version 1.3

Returns the cosine of the specified value.

  1. afX - Value to operate.
float MathTan(float afX);

Alert icon.png Requires version 1.3

Returns the tangent of the specified value.

  1. afX - Value to operate.
float MathAsin(float afX);

Alert icon.png Requires version 1.3

Returns the arc sine of the specified value.

  1. afX - Value to operate.
float MathAcos(float afX);

Alert icon.png Requires version 1.3

Returns the arc cosine of the specified value.

  1. afX - Value to operate.
float MathAtan(float afX);

Alert icon.png Requires version 1.3

Returns the arc tangent of the specified value.

  1. afX - Value to operate.
float MathAtan2(float afX, float afY);

Alert icon.png Requires version 1.3

Calculates and returns the arc tangent of the specified values.

  1. afX - First value to operate.
  2. afY - Second value to operate.
float MathSqrt(float afX);

Alert icon.png Requires version 1.3

Returns the square root of the specified value.

  1. afX - Value to operate.
float MathPow(float afBase, float afExp);

Alert icon.png Requires version 1.3

Returns the value of afBase raised to the power of afExp.

  1. afBase - The base value.
  2. afExp - Value to calculate the base with.
float MathMin(float afA, float afB);

Alert icon.png Requires version 1.3

Returns the lowest value.

  1. afA - First value.
  2. afB - Second value.
float MathMax(float afA, float afB);

Alert icon.png Requires version 1.3

Returns the highest value.

  1. afA - First value.
  2. afB - Second value.
float MathClamp(float afX, float afMin, float afMax);

Alert icon.png Requires version 1.3

Returns afX clamped between afMin and afMax. If afX < afMin, returns afMin, and if afX > afMax, returns afMax.

  1. afX - The value to clamp.
  2. afMin - The minimum value to clamp afX with.
  3. afMax - The maximum value to clamp afX with.
float MathAbs(float afX);

Alert icon.png Requires version 1.3

Returns the absolute value.

  1. afX - Value to operate.

Debugging

void Print(string &in asString);

Prints a string to the log file (hpl.log).

void AddDebugMessage(string &in asString, bool abCheckForDuplicates);

Prints a line of text to the debug console at the bottom left of the screen. Debug mode must be enabled for the console messages to be visible.

  1. asString - the string to print
  2. abCheckForDuplicates - if true, the string won't be printed more than once on screen until it disappears
void ProgLog(string &in asLevel, string &in asMessage);

Prints an entry to the ProgLog (progression log).
ProgLog is a file created in Documents/Amnesia/main (or an FC folder if one is being used). It logs certain events, such us opening the menu or picking up the lantern, as well as the player's state (Health, Sanity, Oil, Tinderboxes, Coins), for the purpose of documenting a tester's playstyle.

This function allows to log custom messages.The messages in the ProgLog file are sorted by time elapsed since a map was loaded.

ProgLog has to be enabled for a player profile in user_settings.cfg before it starts working.

  1. asLevel - can be "Low", "Medium" or "High". It's a tag which appears in each log entry, for event prioritising.
  2. asMessage - The custom message to be printed to the log.
bool ScriptDebugOn();

Checks whether the debug mode is enabled.
See "Setting up Development Environment" to setup debug mode on your own computer.

Variables

Alert icon.png Warning: Regular variables (int, float, etc.) are not saved by the game. Using them in important parts of yor script will break it upon loading a game save. In HPL, those variables should only be used for disposable counters, like spawning objects in a "for" loop. For variables which need to be saved, use the wrappers as described below.

Local

Local variables can be used throughout the same script file.

void SetLocalVarInt(string &in asName, int alVal);
void AddLocalVarInt(string &in asName, int alVal);
int GetLocalVarInt(string &in asName);
void SetLocalVarFloat(string &in asName, float afVal);
void AddLocalVarFloat(string &in asName, float afVal);
float GetLocalVarFloat(string &in asName);
void SetLocalVarString(string &in asName, const string &in asVal);
void AddLocalVarString(string &in asName, string &in asVal);
string& GetLocalVarString(string &in asName);

Global

Global variables can be used throughout several maps and can be accessed by several script files.

void SetGlobalVarInt(string &in asName, int alVal);
void AddGlobalVarInt(string &in asName, int alVal);
int GetGlobalVarInt(string &in asName);
void SetGlobalVarFloat(string &in asName, float afVal);
void AddGlobalVarFloat(string &in asName, float afVal);
float GetGlobalVarFloat(string &in asName);
void SetGlobalVarString(string &in asName, const string &in asVal);
void AddGlobalVarString(string &in asName, string &in asVal);
string& GetGlobalVarString(string &in asName);

Particle Systems

void PreloadParticleSystem(string &in asPSFile);

Preloads a particle system.

  1. asPSFile - The particle system file to load. Extension: .ps
void CreateParticleSystemAtEntity(string &in asPSName, string &in asPSFile, string &in asEntity, bool abSavePS);

Creates a particle system on an entity.

  1. asPSName - internal name
  2. asPSFile - the particle system to use + extension .ps
  3. asEntity - the entity to create the particle system at
  4. abSavePS - determines whether a particle system should "remember" its shown/hidden state, so that this state can be restored when the player revisits the level
void CreateParticleSystemAtEntityExt(string &in asPSName, string &in asPSFile, string &in asEntity, bool abSavePS,
float afR, float afG, float afB, float afA, bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart,
float afFadeMaxStart, float afFadeMaxEnd);

Creates a particle system on an entity, extended method with more options.

  1. asPSName - internal name
  2. asPSFile - the particle system to use + extension .ps
  3. asEntity - the entity to create the particle system at
  4. abSavePS - determines whether a particle system should "remember" its shown/hidden state, so that this state can be restored when the player revisits the level
  5. afR - red value
  6. afG - green value
  7. afB - blue value
  8. afA - alpha value
  9. abFadeAtDistance - determines whether a particle system fades from a certain distance on
  10. afFadeMinEnd - minimum distance at which the particle system stops fading
  11. afFadeMinStart - minimum distance at which the particle system starts fading
  12. afFadeMaxStart - maximum distance at which the particle system starts fading
  13. afFadeMaxEnd - maximum distance at which the particle system stops fading
void DestroyParticleSystem(string &in asName);

Destroys a particle system.

  1. asName - The internal name of the particle system

Sounds & Music

void PreloadSound(string &in asSoundFile);

Preloads a sound.

  1. asSoundFile - The sound file to load (extension .snt optional)
void PlayGuiSound(string &in asSoundFile, float afVolume);

Plays a sound, not using 3D.

  1. asSoundFile - the sound to play (extension .snt/.ogg optional)
  2. afVolume - the volume of the sound
void PlaySoundAtEntity(string &in asSoundName, string &in asSoundFile, string &in asEntity, float afFadeTime, bool abSaveSound);

Creates a sound at an entity.

  1. asSoundName - internal name
  2. asSoundFile - the sound to use (extension .snt optional)
  3. asEntity - the entity to create the sound at. Using "Player" is effectively the same as PlayGuiSound, yet this function allows a looping sound to be saved
  4. afFadeTime - time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f
  5. abSaveSound - if true, a looping sound will "remember" its playback state (currently playing/stopped), and that state will be restored the next time the level is entered. If true, the sound is never attached to the entity! Note that saving should only be used on looping sounds!
void FadeInSound(string &in asSoundName, float afFadeTime, bool abPlayStart);

Fades in a sound.

  1. asSoundName - internal name
  2. afFadeTime - time in seconds
  3. abPlayStart - Play the sound defined in the <Start> section of the .snt before playing the main sound
void StopSound(string &in asSoundName, float afFadeTime);

Fades out a sound.

  1. asSoundName - internal name
  2. afFadeTime - time in seconds, use 0 to immediately stop the sound
void PlayMusic(string &in asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

Plays music.

  1. asMusicFile - the music file to play (extension .ogg optional)
  2. abLoop - determines whether a music track should loop
  3. afVolume - volume of the music
  4. afFadeTime - time in seconds until music reaches full volume
  5. alPrio - priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc.
  6. abResume - if true, playback will be continued from where the track stopped after the call to StopMusic(). If false, the track will be restarted.
void StopMusic(float afFadeTime, int alPrio);

Stops music.

  1. afFadeTime - time in seconds until music stops
  2. alPrio - the priority of the music that should stop
void FadeGlobalSoundVolume(float afDestVolume, float afTime);

Influences the global sound volume, that means everything you can hear from the world. This does not affect music of GUI sounds.

  1. afDestVolume - desired volume
  2. afTime - time in seconds until volume reaches desired volume
void FadeGlobalSoundSpeed(float afDestSpeed, float afTime);

Influences the global sound speed.

  1. afDestSpeed - desired speed
  2. afTime - time in seconds until volume reaches desired speed

Lights

void SetLightVisible(string &in asLightName, bool abVisible);

Enables/disables lights.

  1. asLightName - internal name
  2. abVisible - determines the state of the light
void FadeLightTo(string &in asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);

Changes the properties of a light.

  1. asLightName - internal name
  2. afR - red value
  3. afG - green value
  4. afB - blue value
  5. afA - alpha value
  6. afRadius - radius of the light. -1 means keeping the radius
  7. afTime - time in seconds until change is done
void SetLightFlickerActive(string &in asLightName, bool abActive);

Activates flickering on a light.

  1. asLightName - The internal light name
  2. abActive - true = active, false = inactive

Game scripts

General

void StartCredits(string &in asMusic, bool abLoopMusic, string &in asTextCat, string &in asTextEntry, int alEndNum);

Starts the end credits screen.

  1. asMusic - the music to play (including .ogg)
  2. abLoopMusic - determines whether the music should loop
  3. asTextCat - the category to be used in the .lang file, usually "Ending"
  4. asTextEntry - the entry in the .lang file
  5. alEndNum - Amnesia has 3 different endings and displays a code at the bottom. Determines which code is displayed. 0-2 will display codes, any other integer will not.
void StartDemoEnd();

Shows the demo end screen. The background and UI elements are defined in demo.cfg, with the text using the entries in the "Demo" category of the .lang file.

void AutoSave();

Creates an auto save file.

void CheckPoint (string &in asName, string &in asStartPos, string &in asCallback, string &in asDeathHintCat, string &in asDeathHintEntry);

Sets a checkpoint at which the player will respawn in case he dies.
Callback syntax: void MyFunc(string &in asName, int alCount)
Count is 0 on the first checkpoint load!

  1. asName - the internal name
  2. asStartPos - the name of the StartPos in the editor
  3. asCallback - the function to call when the player dies/respawns
  4. asDeathHintCat - the category of the death hint message to be used in the .lang file, usually "Hints"
  5. asDeathHintEntry - the entry in the .lang file
void ChangeMap(string &in asMapName, string &in asStartPos, string &in asStartSound, string &in asEndSound);

Loads another map after a 1.5 second fade out.

  1. asMapName - the file to load
  2. asStartPos - the name of the StartPos in the next map
  3. asStartSound - the sound that is played when the change starts
  4. asEndSound - the sound that is played when the new map is loaded
void ClearSavedMaps();

Clears the "history" of the save, useful to do when you know the player will not be able to go back anymore. Makes the next save much smaller in size.

void CreateDataCache();
void DestroyDataCache();

This caches all current textures and models and they are not released until destroy is called. If there is already cached data it is destroyed. Create caches to enable faster loading when going back to a map. Destroy the cache if you know the player won't go back to that map.

void SetMapDisplayNameEntry(string &in asNameEntry);

Sets the map name shown in save file names. If none is set NULL is assumed.

  1. asNameEntry - the entry to display, category must be "Levels"!
void SetSkyBoxActive(bool abActive);

Enables/Disables the skybox.

  1. abActive - true = active, false = inactive
void SetSkyBoxTexture(string &in asTexture);

Sets the texture of the skybox.

  1. asTexture - The texture file to set. Extension: .dds
void SetSkyBoxColor(float afR, float afG, float afB, float afA);

Sets the solid color of the skybox rather than a texture.

  1. afR - red value
  2. afG - green value
  3. afB - blue value
  4. afA - alpha value
void SetFogActive(bool abActive);

Enables/Disables the global fog.

  1. abActive - true = active, false = inactive
void SetFogColor(float afR, float afG, float afB, float afA);

Sets the color to use for the global fog.

  1. afR - red value
  2. afG - green value
  3. afB - blue value
  4. afA - alpha value
void SetFogProperties(float afStart, float afEnd, float afFalloffExp, bool abCulling);

Sets the properties for the global fog.

  1. afStart - how many meters from the camera should the fog begin
  2. afEnd - how many meters from the camera should the fog reach full thickness
  3. afFalloffExp - the amount by which the thinkness increases
  4. abCulling - whether occlusion culling is active for the fog; this prevents objects behind the fog from being loaded
void SetupLoadScreen(string &in asTextCat, string &in asTextEntry, int alRandomNum, string &in asImageFile);

Determines which loading screen will be shown when changing maps.

  1. asTextCat - the category of the loading text in the .lang file to be shown on the loading screen, usually "LoadingText"
  2. asTextEntry - the entry in the .lang file
  3. alRandomNum - if greater 1, then it will randomize between 1 and alRandom for each LoadScreen giving entry the suffix XX (eg 01). If < =1 then no suffix is added
  4. asImageFile - the image to be shown (optional)
void UnlockAchievement(string &in asName);

Unlocks the specified achievement. Only able to be used for the ending achievements.

  1. asName - The name of the achievement. Only the following strings are valid:
  • Benefactor
  • Survivor
  • Sacrifice
  • Quitter
  • Egotist
  • Altruist
  • Vacillator

Game Timer

void AddTimer(string &in asName, float afTime, string &in asFunction);

Creates a timer which calls a function when it expires.
Callback syntax: void MyFunc(string &in asTimer)

  1. asName - the name of the timer
  2. afTime - time in seconds
  3. asFunction - the function to call
void RemoveTimer(string &in asName);

Removes a timer, no matter how much time is left.

  1. asName - the internal name of the timer.
float GetTimerTimeLeft(string &in asName);

Returns the time left on a timer.

  1. asName - the internal name of the timer.

Screen Effects

void FadeOut(float afTime);

Fades the screen to black.

  1. afTime - time in seconds until the screen is completly black
void FadeIn(float afTime);

Fades the screen back to normal.

  1. afTime - time in seconds until the screen back to normal
void FadeImageTrailTo(float afAmount, float afSpeed);

Applies the image trail effect to the screen.

  1. afAmount - intensity (default: 0)
  2. afSpeed - time in seconds until full effect
void FadeSepiaColorTo(float afAmount, float afSpeed);

Makes the screen go dark red.

  1. afAmount - intensity (default: 0)
  2. afSpeed - time in seconds until full effect
void FadeRadialBlurTo(float afSize, float afSpeed);

Applies radial blur effects to the screen.

  1. afSize - intensity (default: 0)
  2. afSpeed - time in seconds until full effect
void SetRadialBlurStartDist(float afStartDist);

Determines at which distance the radial blur effects appear.

  1. afStartDist - the distance at which the effect starts
void StartEffectFlash(float afFadeIn, float afWhite, float afFadeOut);

Fades the screen to white.

  1. afFadeIn - time in seconds until screen is white
  2. afWhite - determines to which percentage the screen fades to white (1.0 = completly white)
  3. afFadeOut - time in seconds until screen is back to normal again
void StartEffectEmotionFlash(string &in asTextCat, string &in asTextEntry, string &in asSound);

Fades the screen to white and shows a text message.

  1. asTextCat - the category in the .lang file
  2. asTextEntry - the text entry in the .lang file
  3. asSound - the sound to play while fading
void AddEffectVoice(string &in asVoiceFile, string &in asEffectFile, string &in asTextCat, string &in asTextEntry,
bool abUsePosition, string &in asPosEntity, float afMinDistance, float afMaxDistance);

This adds a voice and an effect to be played. It is okay to call this many times in order to play many voices in a row. The EffectVoiceOverCallback is not called until ALL voices have finished.

  1. asVoiceFile - the voice to play
  2. asEffectFile - the effect to play
  3. asTextCat - the category in the .lang file, usually "Voice"
  4. asTextEntry - the text entry in the .lang file
  5. abUsePosition - plays using 3D from the entity, or without 3D
  6. asPosEntity - the entity at which the effect appears
  7. afMinDistance - minimum distance to see the effect
  8. afMaxDistance - maximum distance to see the effect
void StopAllEffectVoices(float afFadeOutTime);

Stops all voices and calls the EffectVoiceOverCallback.

bool GetEffectVoiceActive();

Checks whether EffectVoices are still active.

void SetEffectVoiceOverCallback(string &in asFunc);

Sets the function to be called when the EffectVoices are finished.
Callback syntax: void MyFunc()

bool GetFlashbackIsActive();

Checks whether a flashback is still in effect.

void StartPlayerSpawnPS(string &in asSPSFile);
void StopPlayerSpawnPS();

Continuously spawn regular particle systems (.ps) around the player. Particles created by this script carry over from map to map.

  1. asSPSFile - the .sps file to use. Example .sps files are located in the /misc folder in the main game directory.
    Custom .sps files can be created by hand in a text editor (see existing ones and mimic how those are written).
    Since StopPlayerSpawnPS() doesn't seem to work, to stop an SPS you must create an .sps file with an empty particle field field and override the old SPS by calling StartPlayerSpawnPS again.
void StartScreenShake(float afAmount, float afTime, float afFadeInTime, float afFadeOutTime);

Shakes the screen.

  1. afAmount - intensity of the shake
  2. afTime - duration of the shake
  3. afFadeInTime - time in seconds until full intensity is reached
  4. afFadeOutTime - time until screen is back to normal
void SetInDarknessEffectsActive(bool abX);

Alert icon.png Requires version 1.3

Enables/disables the sanity drain and night vision effects while in the darkness.

bool abX - Enable/disable effects.

void ShowScreenImage(string &in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);

Alert icon.png Requires version 1.5

Displays an image file directly onto the screen. See ShowScreenImage() in the tutorials section for more information.

  1. asImageName - The image file to render (.jpg, .png, .tga, .dds)
  2. afX - The X position of the image
  3. afY - The Y position of the image
  4. afScale - The size of the image in pixels (not scale), or original image size if negative
  5. abUseRelativeCoordinates - Whether X and Y are relative to the screen resoltion, or pixel co-ordinates if not
  6. afDuration - The duration that the image is displayed for
  7. afFadeIn - The time, in seconds, to fade in the image
  8. afFadeOut - The time, in seconds, to fade out the image

Insanity

void SetInsanitySetEnabled(string &in asSet, bool abX);

Determines which InsanitySets are enabled.

  1. asSet - the set
  2. abX - enabled or not
void StartInsanityEvent(string &in asEventName);

Alert icon.png Requires version 1.3

Starts a specified insanity event.

  1. asEventName - Insanity event to play.
void StartRandomInsanityEvent();

Starts a random insanity event from the available sets.

void StopCurrentInsanityEvent();

Alert icon.png Requires version 1.3

Stops the currently playing insanity event.

void InsanityEventIsActive();

Checks whether an insanity event is currently in effect.
Not useful at all due to having a return type of void when it should be bool.

Player

Note that the player's maximum health and sanity is 100.

void SetPlayerActive(bool abActive);

Enabled/Disable player controlled movement.

void ChangePlayerStateToNormal();

Resets the player's state, forcing them to stop interacting with objects. It also clears the inventory item to be used (as if it was double-clicked on in the inventory again) and dismounts the player from ladders.

void SetPlayerCrouching(bool abCrouch);

Forces the player to crouch.

void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);

Pushes the player into a certain direction. Note that you need values above ~2000 to see any effects.

  1. afX - amount along the X-axis
  2. afY - amount along the Y-axis
  3. afZ - amount along the Z-axis
  4. abUseLocalCoords - If true, axes are based on where the player is facing, not the world.
void ShowPlayerCrossHairIcons(bool abX);

Enables/Disables the icons when a player has something in focus.

void SetPlayerSanity(float afSanity);
void AddPlayerSanity(float afSanity);
float GetPlayerSanity();

Modifies/returns the sanity of the player.

void SetPlayerHealth(float afHealth);
void AddPlayerHealth(float afHealth);
float GetPlayerHealth();

Modifies/returns the health of the player.

void SetPlayerLampOil(float afOil);
void AddPlayerLampOil(float afOil);
float GetPlayerLampOil();

Modifies/returns the lamp oil of the player.

float GetPlayerSpeed();
float GetPlayerYSpeed();

Returns the current speed of the player.

void SetSanityDrainDisabled(bool abX);

Enables/Disables sanity drain from darkness.

void GiveSanityBoost();

Boosts the player's sanity by a large amount depending on the current sanity.

Sanity New Sanity
0-24 100
25-49 90
50-74 80
75-100 +5
void GiveSanityBoostSmall();

Boosts the player's sanity by a small amount depending on the current sanity.

Sanity Sanity Bonus
0-24 +20
25-49 +15
50-75 +10
75-100 +5
void GiveSanityDamage(float afAmount, bool abUseEffect);

Reduces the sanity of the player.

  1. afAmount - amount of sanity damage done
  2. abUseEffect - determines whether an effect is played when the sanity damage is dealt
void GivePlayerDamage(float afAmount, string &in asType, bool abSpinHead, bool abLethal);

Reduces the health of the player.

  1. afAmount - amount of damage done to health
  2. asType - plays a certain effect on the screen when the damage is dealt (BloodSplat, Claws, or Slash)
  3. abSpinHead - changes the camera view when damage is dealt
  4. abLethal - set to true if player can die from given damage. If false and the damage would have left the player with less than 10 health, health is set to 10.
void FadePlayerFOVMulTo(float afX, float afSpeed);

Changes the field of view of the player. A shorter FOV will create a zoom effect.

  1. afX - multiplier of default FOV (1 is default)
  2. afSpeed - the speed of change between FOVs
void FadePlayerAspectMulTo(float afX, float afSpeed);

Changes the aspect ratio of the player. Basically stretches or narrows the screen horizontally.

  1. afX - multiplier of default aspect (default is 1)
  2. afSpeed - the speed of change between FOVs
void FadePlayerRollTo(float afX, float afSpeedMul, float afMaxSpeed);

Rotates the position of the camera on the player's body.

  1. afX - angle of rotation of head, positive being counter-clockwise
  2. afSpeedMul - speed (possibly acceleration) multiplier of the rotation (default 1, which is really slow)
  3. afMaxSpeed - maximum speed of rotation
void MovePlayerForward(float afAmount);

Alert icon.png Requires version 1.2

Moves the player forward. It needs to be called in a timer that updates 60 times / second.

void MovePlayerHeadPos(float afX, float afY, float afZ, float afSpeed, float afSlowDownDist);

Changes the position of the camera on the player's body.

  1. afX - amount along the X-axis
  2. afY - amount along the Y-axis
  3. afZ - amount along the Z-axis
  4. afSpeed - speed at which the change happens
  5. afSlowDownDist - distance at which to start slowing down (prevents the head from abruptly stopping)
void StartPlayerLookAt(string &in asEntityName, float afSpeedMul, float afMaxSpeed, string &in asAtTargetCallback);
void StopPlayerLookAt();

Forces the player to look at a certain entity until StopPlayerLookAt is used.

  1. asEntityName - the entity to look at
  2. afSpeedMul - how fast should the player look at the entity
  3. afMaxSpeed - maximum speed allowed
  4. asAtTargetCallback - function to call when player looks at target
void SetPlayerMoveSpeedMul(float afMul);
void SetPlayerRunSpeedMul(float afMul);
void SetPlayerLookSpeedMul(float afMul);

Changes the player's move/run/look speed. Default is 1.

void SetPlayerJumpForceMul(float afMul);

Alert icon.png Requires version 1.3

Changes the player's jump multiplier. Higher values = higher jumps. Default is 1.

void SetPlayerJumpDisabled(bool abX);
void SetPlayerCrouchDisabled(bool abX);

Enables/Disables the player's ability to jump/crouch.

void TeleportPlayer(string &in asStartPosName);

Instantly teleports the player to the target StartPos.

void SetLanternActive(bool abX, bool abUseEffects);

Makes the player use his lantern.

bool GetLanternActive();

Checks whether the player currently uses his lantern.

void SetLanternDisabled(bool abX);

Enables/Disables the player's ability to use his lantern.

void SetLanternLitCallback(string &in asCallback);

Sets the function to call when the player uses his lantern.
Callback syntax: MyFunc(bool abLit)

void SetMessage(string &in asTextCategory, string &in asTextEntry, float afTime);

Displays a message on the screen.

  1. asTextCategory - the category in the .lang file
  2. asTextEntry - the entry in the .lang file
  3. afTime - determines how long the message is displayed. If time is < =0 then the life time is calculated based on string length.
void SetDeathHint(string &in asTextCategory, string &in asTextEntry);

Sets the message that appears when the player dies.

  1. asTextCategory - the category in the .lang file
  2. asTextEntry - the entry in the .lang file, usually "Hints"
void DisableDeathStartSound();

Disables the death sound when the player dies. This must be called directly before player is killed! The variable as soon as player dies too.

void SetPlayerPermaDeathSound(string &in asSound);

Alert icon.png Requires version 1.2

Sets the sound played after the player dies when permadeath is active. Permadeath is only active when the game is launched with the ptest command line parameter. Only used for the post-death Suitor lines in Justine.

  1. asSound - The sound to be played after death. Expects a voice-type sound.
void SetPlayerFallDamageDisabled(bool abX);

Alert icon.png Requires version 1.3

Enables/disables the player's ability to take fall damage.

void SetPlayerPos(float afX, float afY, float afZ);

Alert icon.png Requires version 1.3

Sets the player's position within the level.

  1. afX - X co-ordinate position.
  2. afY - Y co-ordinate position.
  3. afZ - Z co-ordinate position.
float GetPlayerPosX();
float GetPlayerPosY();
float GetPlayerPosZ();

Alert icon.png Requires version 1.3

Returns the player's position within the level on the specified axis.

Journal

void AddNote(string &in asNameAndTextEntry, string &in asImage);

Adds a note to the player's journal.

  1. asNameAndTextEntry - entries in the .lang file. Must end with _Name and _Text and be in category "Journal"!
  2. asImage - the background image to be used
void AddDiary(string &in asNameAndTextEntry, string &in asImage);

Adds a diary to the player's journal.

  1. asNameAndTextEntry - entries in the .lang file. Must end with _NameX and _TextY whereas X and Y are numbers of the parts (_Name1: first diary, _Text1: first page) and be in category "Journal"!
  2. asImage - the background image to be used
void ReturnOpenJournal(bool abOpenJournal);

Only called in the pickup diary callback! If true the journal displays the entry else not.

Quests

void AddQuest(string &in asName, string &in asNameAndTextEntry);

Adds a quest to the player's journal under mementos. Completed quests cannot be readded.

  1. asName - the internal name to be used
  2. asNameAndTextEntry - entry in the .lang file. Must start with "Quest_<texthere>_Text”, and be in category “Journal”!
void CompleteQuest(string &in asName, string &in asNameAndTextEntry);

Completes a quest. If the quest has not been added, it's marked as complete anyway, preventing it from being added.

  1. asName - the internal name of the quest
  2. asNameAndTextEntry - entry in the .lang file. Must start with " Quest_<texthere>_Text ”, and be in category “Journal”!
bool QuestIsCompleted(string &in asName);
bool QuestIsAdded(string &in asName);

Checks whether a quest is completed/added.

  1. asName - the internal name of the quest
void SetNumberOfQuestsInMap(int alNumberOfQuests);

Sets the number of quests in the map. Obsolete; formerly used to calculate a completion percentage when looking at a level door.

  1. alNumberOfQuests - Amount of quests
void GiveHint(string &in asName, string &in asMessageCat, string &in asMessageEntry, float afTimeShown);

Displays a hint on the player's screen.

  1. asName - the internal name
  2. asMessageCat - the category in the .lang file, usually "Hints"
  3. asMessageEntry - the entry in the .lang file
  4. afTimeShown - time in seconds until the message disappears. If time is <= 0 then the life time is calculated based on string length.
void BlockHint(string &in asName);
void UnBlockHint(string &in asName);

Blocking a hint prevents it from being shown. Blocked hints are included in savefiles, so they should persist between levels. Unblocking a hint allows it to be shown.

  1. asName - the internal name. Basic game hints use the same name as their respective lang entries, with the exception of "numbered" hints. For example, EntityGrab blocks the EntityGrab01 and EntityGrab02 entries.
void RemoveHint(string &in asName);

Removes the hint from the list of already shown hints, allowing it to appear again.

  1. asName - the internal name. Basic game hints use the same name as their respective lang entries, with the exception of "numbered" hints. For example, EntityGrab reenables the EntityGrab01 and EntityGrab02 entries.

Inventory

void ExitInventory();

Exits the inventory by force.

void SetInventoryDisabled(bool abX);

Disables the player's ability to open his inventory.

void SetInventoryMessage(string &in asTextCategory, string &in asTextEntry, float afTime);

Adds a message on the inventory screen. Used for feedback messages when failing to combine items.

  1. asTextCategory - the category in the .lang file, usually "Inventory"
  2. asTextEntry - the entry in the .lang file
  3. afTime - time in seconds until the message disappears. If life time is <= 0 then the life time is calculated based on string length.
void GiveItem(string &in asName, string &in asType, string &in asSubTypeName, string &in asImageName, float afAmount);

Adds an item to the inventory of the player. Note that the item does not have to exist as entity in the world to be able to do this.

  1. asName - internal name
  2. asType - item type to give, Available types are:
  • Puzzle
  • Lantern
  • Health
  • Sanity
  • LampOil
  • Tinderbox
  1. asSubTypeName - item name for .lang file
  2. asImageName - the image which will appear in inventory. For example: void GiveItem("chemical_container_full_1", "Puzzle", "chemical_container_full", "chemical_container_full.tga", 1); will use the image from graphics/item/chemical_container_full.tga
  3. afAmount - amount the item gives, - For example: Oil potions will fill the oil meter by this amount, Health potions will heal by this amount, etc.
void RemoveItem(string &in asName);

Removes an item from the player's inventory.

  1. asName - internal name
bool HasItem(string &in asName);

Checks whether the player has an item in his inventory.

  1. asName - internal name
void GiveItemFromFile(string &in asName, string &in asFileName);

Adds a single item to the player's inventory. This is meant to be used for debug mostly as it creates the actual item and then destroys it.

  1. asName - internal name
  2. asFileName - item to give + extension (.ent)
void AddCombineCallback(string &in asName, string &in asItemA, string &in asItemB, string &in asFunction, bool abAutoRemove);

Allows the player to combine items in his inventory.
Callback syntax: void MyFunc(string &in asItemA, string &in asItemB)

  1. asName - internal name for the callback
  2. asItemA - internal name of first item
  3. asItemB - internal name of second item
  4. asFunction - the function to call
  5. abAutoRemove - determines whether the callback should be removed when the items are combined
void RemoveCombineCallback(string &in asName);

Removes a combine callback.

  1. asName - the internal name of the callback to be removed (as specified in AddCombineCallback)
void AddUseItemCallback(string &in asName, string &in asItem, string &in asEntity, string &in asFunction, bool abAutoDestroy);

Allows the player to use items on the world.
Callback syntax: void MyFunc(string &in asItem, string &in asEntity)

  1. asName - internal name of the callback
  2. asItem - internal name of the item
  3. asEntity - entity to be able to use the item on
  4. asFunction - function to call
  5. abAutoDestroy - determines whether the callback should be removed when the item is used
void RemoveUseItemCallback(string &in asName);

Removes an item callback.

  1. asName - internal name of the callback

Entities

General

void SetEntityActive(string &in asName, bool abActive);

Activates/deactivates an entity.

void SetEntityVisible(string &in asName, bool abVisible);

Alert icon.png Requires version 1.3

Activates/deactivates an entity's visual mesh. The collision body remains.

  1. asName - Name of the entity.
  2. abActive - Activate/deactivate mesh.
bool GetEntityExists(string &in asName);

Checks whether an entity exists.

void SetEntityCustomFocusCrossHair(string &in asName, string& asCrossHair);

Changes the crosshair that is used when focusing an entity.

  1. asName - internal name
  2. asCrossHair - desired crosshair, can be: Default (uses default), Grab, Push, Ignite, Pick, LevelDoor, Ladder
void CreateEntityAtArea(string &in asEntityName, string &in asEntityFile, string &in asAreaName, bool abFullGameSave);

Creates an entity at an area. When creating an enemy though, it cannot chase properly along PathNodes (using for example ShowEnemyPlayerPosition).

  1. asEntityName - internal name
  2. asEntityFile - entity to be used extension .ent
  3. asAreaName - the area to create the entity at
  4. abFullGameSave - determines whether an entity "remembers" its state
void ReplaceEntity(string &in asName, string &in asBodyName, string &in asNewEntityName, string &in asNewEntityFile, bool abFullGameSave);

Alert icon.png Requires version 1.3

Removes an entity and places a new one in its place.

  1. asName - Name of the entity to replace.
  2. asBodyName - Name of the body of the entity to place the new entity at. If empty the first body is used (might be buggy, recommended to name a body anyway).
  3. asNewEntityName - Name of the new entity.
  4. asNewEntityFile - Name of the new entity file. Extension .ent.
  5. abFullGameSave - Whether ALL properties of this entity should be saved throughout levels.
void PlaceEntityAtEntity(string &in asName, string &in asTargetEntity, string &in asTargetBodyName, bool abUseRotation);

Alert icon.png Requires version 1.3

Places an entity at the position of another entity. Does not work for enemies, use TeleportEnemyToEntity instead.

  1. asName - Name of the entity to place.
  2. asTargetEntity - Name of the other entity to place the first entity at.
  3. asTargetBodyName - Name of the body of the entity to place the first entity at. If empty the first body is used (might be buggy, recommended to name a body anyway).
  4. abUseRotation - Whether the entity should be rotated like the target entity.
void SetEntityPos(string &in asName, float afX, float afY, float afZ);

Alert icon.png Requires version 1.3

Moves an entity to a position in the level.

  1. asName - Name of the entity to move.
  2. afX - X co-ordinate position.
  3. afY - Y co-ordinate position.
  4. afZ - Z co-ordinate position.
float GetEntityPosX(string &in asName);
float GetEntityPosY(string &in asName);
float GetEntityPosZ(string &in asName);

Alert icon.png Requires version 1.3

Returns an entity's position in the level on the specified axis.

  1. asName - Name of the entity.
void SetEntityPlayerLookAtCallback(string &in asName, string &in asCallback, bool abRemoveWhenLookedAt);

Calls a function when the player looks at a certain entity.
Callback syntax: void MyFunc(string &in asEntity, int alState)
alState: 1 = looking, -1 = not looking

  1. asName - internal name
  2. asCallback - function to call
  3. abRemoveWhenLookedAt - determines whether the callback should be removed when the player looked at the entity
void SetEntityPlayerInteractCallback(string &in asName, string &in asCallback, bool abRemoveOnInteraction);

Calls a function when the player interacts with a certain entity.
Callback syntax: void MyFunc(string &in asEntity)

  1. asName - internal name
  2. asCallback - function to call
  3. abRemoveOnInteraction - determines whether the callback should be removed when the player interacts with the entity
void SetEntityCallbackFunc(string &in asName, string &in asCallback);

Calls a function when certain events occur with an entity.
Callback syntax: void MyFunc(string &in asEntity, string &in asType)

asType values depend on entity type:

Entity Type asType Value
Object Break
Lamp OnIgnite
Item OnPickup
Enemy OnDeath
Enemy_Grunt
Enemy_Manpig
OnAutoDisabled
void SetEntityConnectionStateChangeCallback(string &in asName, string &in asCallback);

A callback called when ever the connection state changes (button being switched on, lever switched, etc).
Callback syntax: void Func(string &in asEntity, int alState)
alState: -1 = off, 0 = between, 1 = on

void SetEntityInteractionDisabled(string &in asName, bool abDisabled);

Disallows interaction with an entity.

void BreakJoint (string &in asName);

Breaks a joint. Do not use this on joints in SwingDoors, Levers, Wheels, etc. where the joint is part of an interaction. That will make the game crash.

void AddEntityCollideCallback(string &in asParentName, string &in asChildName, string &in asFunction, bool abDeleteOnCollide, int alStates);

Calls a function when two entities collide.
Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)
alState: 1 = enter, -1 = leave

  1. asParentName - internal name of main object
  2. asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)
  3. asFunction - function to call
  4. abDeleteOnCollide - determines whether the callback after it was called
  5. alStates - 1 = only enter, -1 = only leave, 0 = both
void RemoveEntityCollideCallback(string &in asParentName, string &in asChildName);

Removes an EntityCollideCallback. Asterix (*) not supported in asChildName.

bool GetEntitiesCollide(string &in asEntityA, string &in asEntityB);

Checks whether two entities collide. This function does NOT support asterix (*) or "Player"!

void SetBodyMass(string &in asName, float afMass);

Alert icon.png Requires version 1.3

Sets the mass of an entity's body.

  1. asName - Name of the body of an entity. The body name of an entity is EntityName_BodyName.
  2. afMass - The mass to set.
float GetBodyMass(string &in asName);

Alert icon.png Requires version 1.3

Gets the mass of an entity's body.

  1. asName - Name of the body of an entity. The body name of an entity is EntityName_BodyName.
  2. afMass - The mass to get.

Props

void SetPropEffectActive(string &in asName, bool abActive, bool abFadeAndPlaySounds);

Can be used on coal to give it the black color it should have.

void SetPropActiveAndFade(string &in asName, bool abActive, float afFadeTime);

Activates/deactivates a prop.

  1. asName - internal name
  2. abActive - nothing to add
  3. afFadeTime - time in seconds until prop fully fades
void SetPropStaticPhysics(string &in asName, bool abX);

Activates/deactivates the physics of a prop, setting the mass to 0. Setting as true will make entities static in midair.

bool GetPropIsInteractedWith(string &in asName);

Checks whether a prop is interacted with.

void RotatePropToSpeed(string &in asName, float afAcc, float afGoalSpeed, float afAxisX, float afAxisY, float afAxisZ, bool abResetSpeed, string &in asOffsetArea);

Rotates the prop up to a set speed.

  1. asName - internal name
  2. afAcc - acceleration
  3. afGoalSpeed - desired speed
  4. afAxisX - rotation around X axis
  5. afAxisY - rotation around Y axis
  6. afAxisZ - rotation around Z axis
  7. abResetSpeed - determines whether the speed is resetted after goal speed is reached
  8. asOffsetArea - the area to rotate around, if empty, then the center of the body is used Note: The entity you want to rotate MUST be a "StaticObject" entity!
void StopPropMovement(string &in asName);

Stops all movement of a prop.

void AddAttachedPropToProp(string &in asPropName, string &in asAttachName, string &in asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);

Attaches a prop to another prop.

  1. asPropName- the prop to attach another prop at
  2. asAttachName - internal name of the prop that gets attached
  3. asAttachFile - the prop that gets attached extension .ent
  4. afPosX - X position of the attach from the prop
  5. afPosY - Y position of the attach from the prop
  6. afPosZ - Z position of the attach from the prop
  7. afRotX - rotation around X axis of the attach
  8. afRotY - rotation around Y axis of the attach
  9. afRotZ - rotation around ZX axis of the attach Note: for the purposes of AddEntityCollideCallback, attached props will not call the callback function if they collide with a "static_object" or a "StaticProp" entity type!



void AttachPropToProp(string &in asPropName, string &in asAttachName, string &in asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);

Alert icon.png Requires version 1.3

Attaches a prop to another prop. Fixed version of AddAttachedPropToProp.

  1. asPropName - the prop to attach another prop at
  2. asAttachName - internal name of the prop that gets attached
  3. asAttachFile - the prop that gets attached extension .ent
  4. afPosX - X position of the attach from the prop
  5. afPosY - Y position of the attach from the prop
  6. afPosZ - Z position of the attach from the prop
  7. afRotX - rotation around X axis of the attach
  8. afRotY - rotation around Y axis of the attach
  9. afRotZ - rotation around ZX axis of the attach Note: for the purposes of AddEntityCollideCallback, attached props will not call the callback function if they collide with a "static_object" or a "StaticProp" entity type!
void RemoveAttachedPropFromProp(string &in asPropName, string &in asAttachName);

Detaches a prop from a prop.

void SetPropHealth(string &in asName, float afHealth);
void AddPropHealth(string &in asName, float afHealth);
float GetPropHealth(string &in asName);

Modifies/returns the health of a prop.

void ResetProp(string &in asName);

Resets a prop's state to the original one when the map was loaded.

void PlayPropAnimation(string &in asProp, string &in asAnimation, float afFadeTime, bool abLoop, string &in asCallback);

Makes the prop play an animation and calls a function.
Callback syntax: void MyFunc(string &in asProp)

  1. asProp - internal name of the prop
  2. asAnimation - animation to play
  3. afFadeTime - Fade time between current and new animations
  4. abLoop - determines whether the animation loops
  5. asCallback - function to call
void AddPropForce(string &in asName, float afX, float afY, float afZ, string &in asCoordSystem);
void AddPropImpulse(string &in asName, float afX, float afY, float afZ, string &in asCoordSystem);
void AddBodyForce(string &in asName, float afX, float afY, float afZ, string &in asCoordSystem);
void AddBodyImpulse(string &in asName, float afX, float afY, float afZ, string &in asCoordSystem);

These functions push objects. Note that rather high values are needed when applying forces (on the order of ~100 (weak) to ~10000 (strong)), but not impulses (values less than 10 can be appropriate). Forces are external influences, and will have different effect depending on the mass of the object they are being applied to; impulses disregard mass, and can cause objects to break, as if hit. A "Body" is a physics-related helper object, to which a force or an impulse can be applied. Entities can consist of several bodies, interconnected in various ways (you can create/examine bodies in the model editor).

  1. asName - the object to push; for bodies, use this format: "entityName_bodyName"
  2. afX - magnitude along the X-axis
  3. afY - magnitude along the Y-axis
  4. afZ - magnitude along the Z-axis
  5. asCoordSystem - determines which coordinate system is used, "local" or "world"

All of these functions are additive - when called consecutively, for each call, the vectors defined by (afX, afY, afZ) will be added together, and a resultant force/impulse will be calculated before any physics simulation is applied to the target object.

Connections

void InteractConnectPropWithRope(string &in asName, string &in asPropName, string &in asRopeName, bool abInteractOnly, float afSpeedMul, float afToMinSpeed, float afToMaxSpeed, bool abInvert, int alStatesUsed);

Connects a prop with the movement of a rope (ie. turn wheel to move rope).

  1. asName - connection name
  2. asPropName - name of prop
  3. asRopeName - name of rope
  4. abInteractOnly - If the connection is only affected by interacting with the prop directly
  5. afSpeedMul - speed multiplier of how quickly the rope moves
  6. afToMinSpeed - the slowest the rope will move when moving the prop
  7. afToMaxSpeed - the fastest the rope will move when moving the prop
  8. abInvert - whether to invert the direction the rope moves
  9. alStatesUsed - which states of the prop can interact with the rope?
void InteractConnectPropWithMoveObject(string &in asName, string &in asPropName, string &in asMoveObjectName, bool abInteractOnly, bool abInvert, int alStatesUsed);

This one should only be used if there must be an exact correspondence to prop "amount" and the moveobject open amount. It is best used for Wheel-door connections!

void ConnectEntities(string &in asName, string &in asMainEntity, string &in asConnectEntity, bool abInvertStateSent, int alStatesUsed, string &in asCallbackFunc);

Callback syntax: void MyFunc(string &in asConnectionName, string &in asMainEntity, string &in asConnectEntity, int alState)
State is what is sent to connection entity and will be inverted if abInvertStateSent = true!

Lamps

void SetLampLit(string &in asName, bool abLit, bool abEffects);

Turns a lamp on or off.

  1. asName - Name of the lamp
  2. abLit - Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit
  3. abEffects - If you want to have the lamp fade in/out when it gets lit/unlit

Doors

void SetSwingDoorLocked(string &in asName, bool abLocked, bool abEffects);

Locks a SwingDoor.

  1. asName - Name of the door
  2. abLocked - Locked/unlocked
  3. abEffects - If sounds are played when the door is locked/unlocked
void SetSwingDoorClosed(string &in asName, bool abClosed, bool abEffects);

Closes a SwingDoor.

  1. asName - Name of the door
  2. abClosed - Closed/open
  3. abEffects - If sounds are played when the door is closed/opened
bool GetSwingDoorLocked(string &in asName);
bool GetSwingDoorClosed(string &in asName);

Checks whether a swing door is locked/closed.

void SetSwingDoorDisableAutoClose(string &in asName, bool abDisableAutoClose);

Deactivates the "auto-close" when a door is nearly closed.

int GetSwingDoorState(string &in asName);

Returns an integer depending on how far the door is opened.
-1 = angle is close to 0°, 1 = angle is 70% or higher of max, 0 = inbetween -1 and 1.

void SetLevelDoorLocked(string &in asName, bool abLocked);

Locks a level door. Note that level doors are NOT swing doors.

void SetLevelDoorLockedSound(string &in asName, string &in asSound);

Determines which sound is played when interacting with a locked level door.

void SetLevelDoorLockedText(string &in asName, string &in asTextCat, string &in asTextEntry);

Displays a message when interacting with a locked level door.

  1. asName - internal name
  2. asTextCat - the category in the .lang file, usually "Levels"
  3. asTextEntry - the entry in the .lang file
void SetMoveObjectState(string &in asName, float afState);

Moves an object to a certain state.

  1. asName - internal name
  2. afState - state of the object, 0 = closed, 1 = open, values inbetween (and above, for example, the bridge_metal_vert) are valid too!
void SetMoveObjectStateExt(string &in asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed);

Moves an object to a certain state, extended method.

  1. asName - internal name
  2. afState - state of the object, 0 = closed, 1 = open, values inbetween are valid too!
  3. afAcc - acceleration
  4. afMaxSpeed - maximum speed
  5. afSlowdownDist - Distance to the target state before deceleration occurs.
  6. abResetSpeed - Set to true if the prop's speed should be reset before performing the movement, else the prop will accelerate from its current speed to afMaxSpeed.

Levers, wheels and buttons

void SetPropObjectStuckState(string &in asName, int alState);
void SetWheelStuckState(string &in asName, int alState, bool abEffects);
void SetLeverStuckState(string &in asName, int alState, bool abEffects);

Makes a prop\wheel\lever stuck in a certain state.

  1. asName - internal name
  2. alState - 0 = not stuck, 1 = at max, -1 = at min
  3. abEffects - use effects
void SetWheelAngle(string &in asName, float afAngle, bool abAutoMove);

Moves a wheel to a certain angle.

  1. asName - internal name
  2. afAngle - angle
  3. abAutoMove - determines whether the wheel should move on its own
void SetWheelInteractionDisablesStuck(string &in asName, bool abX);
void SetLeverInteractionDisablesStuck(string &in asName, bool abX);

Allows the player to make a wheel/lever unstuck when interacted with.

int GetLeverState(string &in asName);

Returns the state of the lever.
0 = not stuck, 1 = at max, -1 = at min

void SetMultiSliderStuckState(string &in asName, int alStuckState, bool abEffects);

Makes a MultiSlider stuck in a certain state.

void SetMultiSliderCallback(string &in asName, string &in asCallback);

Calls a function when state changes.
Callback syntax: void MyFunc(string &in asEntity, int alState)

void SetButtonSwitchedOn(string &in asName, bool abSwitchedOn, bool abEffects);

Sticky areas

void SetAllowStickyAreaAttachment(bool abX);

Allows entities to stick to a StickyArea.

void AttachPropToStickyArea(string &in asAreaName, string &in asProp);
void AttachBodyToStickyArea(string &in asAreaName, string &in asBody);

Attaches a prop/body to a StickyArea.

void DetachFromStickyArea(string &in asAreaName);

Detaches everything from a StickyArea.

NPCs

void SetNPCAwake(string &in asName, bool abAwake, bool abEffects);

Activates the NPC

void SetNPCFollowPlayer(string &in asName, bool abX);

Sets a NPC's head to follow the player's movements.

Enemies

void SetEnemyDisabled(string &in asName, bool abDisabled);

Disables an enemy.

void SetEnemyIsHallucination(string &in asName, bool abX);

Makes an enemy a hallucination. Hallucinations fade to smoke when they get near the player.

void FadeEnemyToSmoke(string &in asName, bool abPlaySound);

Instantly fades an enemy to smoke.

void ShowEnemyPlayerPosition(string &in asName);

Makes the enemy run to the player, no matter where he is.

void AlertEnemyOfPlayerPresence(string &in asName);

Alert icon.png Requires version 1.3

Gives the specified enemy the player's current position and makes it search the area.

void SetEnemyDisableTriggers(string &in asName, bool abX);

Enables or disables enemy triggers. If disabled, enemy will not react to player or attack.

void AddEnemyPatrolNode(string &in asName, string &in asNodeName, float afWaitTime, string &in asAnimation);

Adds a patrol node to the enemy's path.

  1. asName - internal name of the enemy
  2. asNodeName - path node
  3. afWaitTime - time in seconds that the enemy waits at the path node before continuing
  4. asAnimation - the animation the enemy uses when reaching the path node
void ClearEnemyPatrolNodes(string &in asEnemyName);

Clears the current path of patrol nodes of the enemy.

void SetEnemySanityDecreaseActive(string &in asName, bool abX);

Alert icon.png Requires version 1.3

Enables/disables whether an enemy activates the player's sanity drain when stared at.

  1. asName - Internal name of the enemy
  2. abX - Enabled/disabled
void TeleportEnemyToNode(string &in asEnemyName, string &in asNodeName, bool abChangeY);

Alert icon.png Requires version 1.3

Teleports an enemy to a specific PathNode.

  1. asEnemyName - Internal name of the enemy
  2. asNodeName - Internal name of the node to teleport to
  3. abChangeY - Whether the Y position of the node will be used when teleporting the enemy
void TeleportEnemyToEntity(string &in asEnemyName, string &in asTargetEntity, string &in asTargetBody, bool abChangeY);

Alert icon.png Requires version 1.3

Teleports an enemy to a specific entity.

  1. asEnemyName - Internal name of the enemy
  2. asTargetEntity - Internal name of the entity to teleport to
  3. asTargetBody- Internal name of the entity's body name to teleport to. If empty, the first body will be used (might be unstable, recommended to input a body anyway)
  4. abChangeY - Whether the Y position of the node will be used when teleporting the enemy
void ChangeManPigPose(string&in asName, string &in asPoseType);

Alert icon.png Requires version 1.3

Changes the pose a specified ManPig.

  1. asName - Internal name of the enemy
  2. asPoseType- Name of the ManPig pose to use. Can be "Biped" or "Quadruped"
void SetTeslaPigFadeDisabled(string&in asName, bool abX);

Alert icon.png Requires version 1.3

Enables/disables whether a specified TeslaPig should fade the player's view in and out.

  1. asName - Internal name of the enemy
  2. abX- Enabled/disabled
void SetTeslaPigSoundDisabled(string&in asName, bool abX);

Alert icon.png Requires version 1.3

Enables/disables whether a specified TeslaPig should play the proximity sounds.

  1. asName - Internal name of the enemy
  2. abX- Enabled/disabled
void SetTeslaPigEasyEscapeDisabled(string&in asName, bool abX);

Alert icon.png Requires version 1.3

Enables/disables whether a specified TeslaPig should be easier to escape from when hunted.

  1. asName - Internal name of the enemy
  2. abX- Enabled/disabled
void ForceTeslaPigSighting(string&in asName);

Alert icon.png Requires version 1.3

Forces a TeslaPig to be visible for a short time.

  1. asName - Internal name of the enemy
string& GetEnemyStateName(string &in asName);

Alert icon.png Requires version 1.3

Returns the name of the state a specified enemy is current in.

  1. asName - Internal name of the enemy

Possible states for all enemies:

  • Idle
  • Wait
  • Patrol
  • Investigate
  • Alert
  • Search
  • Hurt
  • Hunt
  • HuntPause
  • HuntWander
  • AttackMeleeShort
  • AttackMeleeLong
  • BreakDoor
  • Dead

Waterlurker-only states:

  • GoHome
  • Eat

ManPig-only states:

  • Flee
  • Stalk
  • Track

Unused states:

  • AttackRange