User Tools

Site Tools



This is an old revision of the document!

Script Functions

FIXME Add better information for all functions and variables as in old wiki.

// Debug
void  Print(string& asString);
void  AddDebugMessage(string& asString, bool abCheckForDuplicates);
* Type can be "Low", "Medium" or "High"
void  ProgLog(string& asLevel, string& asMessage);
bool  ScriptDebugOn();
// General
float  RandFloat(float afMin, float afMax);
int  RandInt(int alMin, int alMax);
bool  StringContains(string& asString, string& asSubString);
string&  StringSub(string& asString, int alStart, int alCount);
//Function syntax: Func(string &in asTimer)
void  AddTimer(string& asName, float afTime, string& asFunction);
void  RemoveTimer(string& asName);
float  GetTimerTimeLeft(string& asName);
void  SetLocalVarInt(string& asName, int alVal);
void  SetLocalVarFloat(string& asName, float afVal);
void  SetLocalVarString(string& asName, const string& asVal);
void  AddLocalVarInt(string& asName, int alVal);
void  AddLocalVarFloat(string& asName, float afVal);
void  AddLocalVarString(string& asName, string& asVal);
int  GetLocalVarInt(string& asName);
float  GetLocalVarFloat(string& asName);
string&  GetLocalVarString(string& asName);
void  SetGlobalVarInt(string& asName, int alVal);
void  SetGlobalVarFloat(string& asName, float afVal);
void  SetGlobalVarString(string& asName, const string& asVal);
void  AddGlobalVarInt(string& asName, int alVal);
void  AddGlobalVarFloat(string& asName, float afVal);
void  AddGlobalVarString(string& asName, string& asVal);
int  GetGlobalVarInt(string& asName);
float  GetGlobalVarFloat(string& asName);
string&  GetGlobalVarString(string& asName);
// Game
void  StartCredits(string& asMusic, bool abLoopMusic, string& asTextCat, string& asTextEntry, int alEndNum);
void  StartDemoEnd();
// Saving
void  AutoSave();
* Callback syntax: MyFunc(string &in asName, int alCount), Count is 0 on first checkpoint load!
void  CheckPoint(string& asName,string& asStartPos ,string& asCallback, string &asDeathHintCat, string &asDeathHintEntry);
// Map
void  ChangeMap(string& asMapName, string& asStartPos, string& asStartSound, string& asEndSound);
void  ClearSavedMaps();
* 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.
void  CreateDataCache();
void  DestroyDataCache();
* Looked up in lang as ("Levels", asNameEntry)
void  SetMapDisplayNameEntry(string& asNameEntry);
void  SetSkyBoxActive(bool abActive);
void  SetSkyBoxTexture(string& asTexture);
void  SetSkyBoxColor(float afR, float afG, float afB, float afA);
void  SetFogActive(bool abActive);
void  SetFogColor(float afR, float afG, float afB, float afA);
void  SetFogProperties(float afStart, float afEnd, float afFalloffExp, bool abCulling);
* If alRandomNum > 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
void  SetupLoadScreen(string &asTextCat, string &asTextEntry, int alRandomNum, string &asImageFile);
// Effect
void  FadeIn(float afTime);
void  FadeOut(float afTime);
void  FadeImageTrailTo(float afAmount, float afSpeed);
void  FadeSepiaColorTo(float afAmount, float afSpeed);
void  FadeRadialBlurTo(float afSize, float afSpeed);
void  SetRadialBlurStartDist(float afStartDist);
void  StartEffectFlash(float afFadeIn, float afWhite, float afFadeOut);
void  StartEffectEmotionFlash(string &asTextCat, string &asTextEntry, string &asSound);
//This adds a voice + 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.
void  AddEffectVoice(    string& asVoiceFile, string& asEffectFile,
                                    string& asTextCat, string& asTextEntry, bool abUsePostion, 
                                    string& asPosEnitity, float afMinDistance, float afMaxDistance);
void  StopAllEffectVoices(float afFadeOutTime);
bool  GetEffectVoiceActive();
* Syntax: void Func();
void  SetEffectVoiceOverCallback(string& asFunc);
bool  GetFlashbackIsActive();
void  StartPlayerSpawnPS(string& asSPSFile);
void  StopPlayerSpawnPS();
void  PlayGuiSound(string& asSoundFile, float afVolume);
void  StartScreenShake(float afAmount, float afTime, float afFadeInTime,float afFadeOutTime);
// Insanity
void  SetInsanitySetEnabled(string& asSet, bool abX);
void  StartRandomInsanityEvent();
bool  InsanityEventIsActive();
// Player
void  SetPlayerActive(bool abActive);
void  ChangePlayerStateToNormal();
void  SetPlayerCrouching(bool abCrouch);
void  AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);
void  ShowPlayerCrossHairIcons(bool abX);
void  SetPlayerSanity(float afSanity);
void  AddPlayerSanity(float afSanity);
float  GetPlayerSanity();
void  SetPlayerHealth(float afHealth);
void  AddPlayerHealth(float afHealth);
float  GetPlayerHealth();
void  SetPlayerLampOil(float afOil);
void  AddPlayerLampOil(float afOil);
float  GetPlayerLampOil();
float  GetPlayerSpeed();
float  GetPlayerYSpeed();
void  SetSanityDrainDisabled(bool abX);
void  GiveSanityBoost();
void  GiveSanityBoostSmall();
void  GiveSanityDamage(float afAmount, bool abUseEffect);
* Type can be: BloodSplat, Claws or Slash.
void  GivePlayerDamage(float afAmount, string& asType, bool abSpinHead, bool abLethal);
void  FadePlayerFOVMulTo(float afX, float afSpeed);
void  FadePlayerAspectMulTo(float afX, float afSpeed);
void  FadePlayerRollTo(float afX, float afSpeedMul, float afMaxSpeed);
void  MovePlayerHeadPos(float afX, float afY, float afZ, float afSpeed, float afSlowDownDist);
void  StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string &asAtTargetCallback);
void  StopPlayerLookAt();
void  SetPlayerMoveSpeedMul(float afMul);
void  SetPlayerRunSpeedMul(float afMul);
void  SetPlayerLookSpeedMul(float afMul);
void  SetPlayerJumpDisabled(bool abX);
void  SetPlayerCrouchDisabled(bool abX);
void  TeleportPlayer(string &asStartPosName);
void  SetLanternActive(bool abX, bool abUseEffects);
bool  GetLanternActive();
void  SetLanternDisabled(bool abX);
* Syntax: MyFun(bool abLit)
void  SetLanternLitCallback(string &asCallback);
* if time is <=0 then the life time is calculated based on string length.
void  SetMessage(string &asTextCategory, string &asTextEntry, float afTime);
void  SetDeathHint(string &asTextCategory, string &asTextEntry);
* This must be called directly before player is killed! The variable as soon as player dies too.
void  DisableDeathStartSound();
// Journal
void  AddNote(string& asNameAndTextEntry, string& asImage);
void  AddDiary(string& asNameAndTextEntry, string& asImage);
* Only called in the pickup diary callback! If true the journal displays the entry else not.
void  ReturnOpenJournal(bool abOpenJournal);
// Quest
void  AddQuest(string& asName, string& asNameAndTextEntry);
void  CompleteQuest(string& asName, string& asNameAndTextEntry);
bool  QuestIsCompleted(string& asName);
bool  QuestIsAdded(string& asName);
void  SetNumberOfQuestsInMap(int alNumberOfQuests);
// Hint
* if time is <=0 then the life time is calculated based on string length.
void  GiveHint(string& asName, string& asMessageCat, string& asMessageEntry, float afTimeShown);
void  RemoveHint(string& asName);
void  BlockHint(string& asName);
void  UnBlockHint(string& asName);
// Inventory
void  ExitInventory();
void  SetInventoryDisabled(bool abX);
* if life time is <=0 then the life time is calculated based on string length.
void  SetInventoryMessage(string &asTextCategory, string &asTextEntry, float afTime);
void  GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount);
void  RemoveItem(string& asName);
bool  HasItem(string& asName);
//This is meant to be used for debug mostly as it creates the actual item and then destroys i.
void  GiveItemFromFile(string& asName, string& asFileName);
* Callback syntax: MyFunc(string &in asItemA, string &in asItemB)
void  AddCombineCallback(string& asName, string& asItemA, string& asItemB, string& asFunction, bool abAutoDestroy);
void  RemoveCombineCallback(string& asName);
* Callback syntax: MyFunc(string &in asItem, string &in asEntity)
void  AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy);
void  RemoveUseItemCallback(string& asName);
// Engine data
void  PreloadParticleSystem(string& asPSFile);
void  PreloadSound(string& asSoundFile);
void  CreateParticleSystemAtEntity(string& asPSName, string& asPSFile, string& asEntity, bool abSavePS);
void  CreateParticleSystemAtEntityExt(    string& asPSName, string& asPSFile, string& asEntity, bool abSavePS, float afR, float afG, float afB, float afA,
                                                    bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart, float afFadeMaxStart, float afFadeMaxEnd);
void  DestroyParticleSystem(string& asName);
//asEntity can be "Player". If abSaveSound = true the sound is never attached to the entity! Also note that saving should on be used on looping sounds!
void  PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
void  FadeInSound(string& asSoundName, float afFadeTime, bool abPlayStart);
void  StopSound(string& asSoundName, float afFadeTime);
void  PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
void  StopMusic(float afFadeTime, int alPrio);
void  FadeGlobalSoundVolume(float afDestVolume, float afTime);
void  FadeGlobalSoundSpeed(float afDestSpeed, float afTime);
void  SetLightVisible(string& asLightName, bool abVisible);
* -1 for color or radius means keeping the value.
void  FadeLightTo(string& asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);
void  SetLightFlickerActive(string& asLightName, bool abActive);
// Entity properties
void  SetEntityActive(string& asName, bool abActive);
bool  GetEntityExists(string& asName);
* CrossHair can be: Default (uses default), Grab, Push, Ignite, Pick, LevelDoor, Ladder
void  SetEntityCustomFocusCrossHair(string& asName, string &asCrossHair);
void  CreateEntityAtArea(string& asEntityName, string& asEntityFile, string& asAreaName, bool abFullGameSave);
* Callback syntax: MyFunc(string &in entity, int alState) state: 1=looking, -1=not looking
void  SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);
* Callback syntax: MyFunc(string &in entity)
void  SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
* Callback syntax: MyFunc(string &in entity, string &in type). Type depends on entity type and includes: "OnPickup", "Break", "OnIgnite", etc
void  SetEntityCallbackFunc(string& asName, string& asCallback);
* A callback called when ever the connection state changes (button being switched on). Syntax: void Func(string &in EntityName, int alState). alState: -1=off, 0=between 1=on
void  SetEntityConnectionStateChangeCallback(string& asName, string& asCallback);
void  SetEntityInteractionDisabled(string& asName, bool abDisabled);
* This function does NOT support asterix!
bool  GetEntitiesCollide(string& asEntityA, string& asEntityB);
void  SetPropEffectActive(string& asName, bool abActive, bool abFadeAndPlaySounds);
void  SetPropActiveAndFade(string& asName, bool abActive, float afFadeTime);
void  SetPropPhysics(string& asName, bool abX);
bool  GetPropIsInteractedWith(string& asName);
* Rotates the prop up to a set speed. If OffsetArea = "", then center of body is used.
void  RotatePropToSpeed(string& asName, float afAcc, float afGoalSpeed, float afAxisX, float afAxisY, float afAxisZ, bool abResetSpeed, string& asOffsetArea);    
void  StopPropMovement(string& asName);    
void  AddAttachedPropToProp(string& asPropName, string& asAttachName, string& asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);
void  RemoveAttachedPropFromProp(string& asPropName, string& asAttachName);
void  SetLampLit(string& asName, bool abLit, bool abEffects);
void  SetSwingDoorLocked(string& asName, bool abLocked, bool abEffects);
void  SetSwingDoorClosed(string& asName, bool abClosed, bool abEffects);
void  SetSwingDoorDisableAutoClose(string& asName, bool abDisableAutoClose);
bool  GetSwingDoorLocked(string &asName);
bool  GetSwingDoorClosed(string &asName);
* -1 = angle is close to 0, 1=angle is 70% or higher of max, 0=inbetween -1 and 1.
int  GetSwingDoorState(string &asName);
void  SetLevelDoorLocked(string& asName, bool abLocked);
void  SetLevelDoorLockedSound(string& asName, string& asSound);
void  SetLevelDoorLockedText(string& asName, string& asTextCat, string& asTextEntry);
* State: 0=not stuck 1 = at max -1= at min
void  SetPropObjectStuckState(string& asName, int alState);
void  SetWheelAngle(string& asName, float afAngle, bool abAutoMove);
void  SetWheelStuckState(string& asName, int alState, bool abEffects);
void  SetLeverStuckState(string& asName, int alState, bool abEffects);
void  SetWheelInteractionDisablesStuck(string& asName, bool abX);
void  SetLeverInteractionDisablesStuck(string& asName, bool abX);
int  GetLeverState(string& asName);
void  SetMultiSliderStuckState(string& asName, int alStuckState, bool abEffects);
* Called when state changes Syntax: MyFunc(string &in asEntity, int alState)
void  SetMultiSliderCallback(string& asName, string& asCallback);
void  SetButtonSwitchedOn(string& asName, bool abSwitchedOn, bool abEffects);
void  SetAllowStickyAreaAttachment(bool abX);
void  AttachPropToStickyArea(string& asAreaName, string& asProp);
void  AttachBodyToStickyArea(string& asAreaName, string& asBody);
void  DetachFromStickyArea(string& asAreaName);
void  SetNPCAwake(string& asName, bool abAwake, bool abEffects);
void  SetNPCFollowPlayer(string& asName, bool abX);
void  SetEnemyDisabled(string& asName, bool abDisabled);
void  SetEnemyIsHallucination(string& asName, bool abX);
void  FadeEnemyToSmoke(string& asName, bool abPlaySound);
void  ShowEnemyPlayerPosition(string& asName);
void  SetEnemyDisableTriggers(string& asName, bool abX);
void  AddEnemyPatrolNode(string& asName, string& asNodeName, float afWaitTime, string& asAnimation);
void  ClearEnemyPatrolNodes(string& asEnemyName);
void  SetPropHealth(string& asName, float afHealth);
void  AddPropHealth(string& asName, float afHealth);
float  GetPropHealth(string& asName);
void  ResetProp(string& asName);
* Callback syntax: MyFunc(string &in asProp)
void  PlayPropAnimation(string& asProp, string& asAnimation, float afFadeTime, bool abLoop, string &asCallback);
* State is 0 -1 where 0 is close and 1 is open. Any intermediate value is also valid!
void  SetMoveObjectState(string& asName, float afState);
void  SetMoveObjectStateExt(string& asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed);
void  AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void  AddPropImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void  AddBodyForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
void  AddBodyImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
* 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  BreakJoint(string& asName);
// Parent can have asterix in name but mot child! Entity callbacks alStates = 1=only enter, -1=only leave 0=both. Syntax: void Func(string &in asParent, string &in asChild, int alState). alState: 1=enter, -1=leave.
void  AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);
// Parent can have asterix in name but mot child!
void  RemoveEntityCollideCallback(string& asParentName, string& asChildName);
// Entity connections
void  InteractConnectPropWithRope(    string& asName, string& asPropName, string& asRopeName, bool abInteractOnly,
                                                float afSpeedMul, float afToMinSpeed, float afToMaxSpeed,
                                                bool abInvert, int alStatesUsed);
* This one should only be used if there must be an exact correspondance to prope "amount" and the moveobject open amount. It is best used for Wheel-door connections!
void  InteractConnectPropWithMoveObject(string& asName, string& asPropName, string& asMoveObjectName, bool abInteractOnly,
                                                    bool abInvert, int alStatesUsed);
* Callback Syntax: 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!
void  ConnectEntities(string& asName, string& asMainEntity, string& asConnectEntity, bool abInvertStateSent, int alStatesUsed, string& asCallbackFunc);    
hpl2/amnesia/script_functions.1288859259.txt.gz · Last modified: 2010/11/04 08:27 by jens