This shows you the differences between two versions of the page.
|
hpl2:amnesia:script_functions [2012/08/11 17:12] theforgot3n1 [Screen Effects] |
hpl2:amnesia:script_functions [2013/05/05 00:29] (current) thegreatcthulhu [Inventory] |
||
|---|---|---|---|
| Line 35: | Line 35: | ||
| 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"). | 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"). | ||
| - | |||
| - | ==== ==== | ||
| Line 55: | Line 53: | ||
| - | Generates a random int. | + | Generates a random int. Note: the maximum value is //inclusive// - the RandInt() function may return this value. |
| Line 83: | Line 81: | ||
| //alStart //- start position in the string\\ | //alStart //- start position in the string\\ | ||
| //alCount //- amount of characters | //alCount //- amount of characters | ||
| + | |||
| ==== Debugging ==== | ==== Debugging ==== | ||
| Line 191: | Line 190: | ||
| //asPSFile //- the particle system to use + extension .ps\\ | //asPSFile //- the particle system to use + extension .ps\\ | ||
| //asEntity //- the entity to create the particle system at\\ | //asEntity //- the entity to create the particle system at\\ | ||
| - | //abSavePS //- determines whether a particle system should "remember" its state | + | //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\\ |
| <code c++>void CreateParticleSystemAtEntityExt(string& asPSName, string& asPSFile, string& asEntity, bool abSavePS, | <code c++>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 afR, float afG, float afB, float afA, bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart, | ||
| Line 204: | Line 203: | ||
| //asPSFile //- the particle system to use + extension .ps\\ | //asPSFile //- the particle system to use + extension .ps\\ | ||
| //asEntity //- the entity to create the particle system at\\ | //asEntity //- the entity to create the particle system at\\ | ||
| - | //abSavePS //- determines whether a particle system should "remember" its state\\ | + | //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\\ |
| //afR //- red value\\ | //afR //- red value\\ | ||
| //afG //- green value\\ | //afG //- green value\\ | ||
| Line 242: | Line 241: | ||
| //asEntity //- the entity to create the sound at, can be "Player"\\ | //asEntity //- the entity to create the sound at, can be "Player"\\ | ||
| //afFadeTime //- time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f\\ | //afFadeTime //- time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f\\ | ||
| - | //abSaveSound //- determines whether a sound should "remember" its state. If true, the sound is never attached to the entity! Also note that saving should on be used on looping sounds! | + | //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//!\\ |
| <code c++>void FadeInSound(string& asSoundName, float afFadeTime, bool abPlayStart); | <code c++>void FadeInSound(string& asSoundName, float afFadeTime, bool abPlayStart); | ||
| </code> | </code> | ||
| Line 273: | Line 272: | ||
| //afVolume //- volume of the music\\ | //afVolume //- volume of the music\\ | ||
| //afFadeTime //- time in seconds until music reaches full volume\\ | //afFadeTime //- time in seconds until music reaches full volume\\ | ||
| - | //alPrio //- priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc | + | //alPrio //- priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc.\\ |
| + | //abResume// - if ''true'', playback will be continued from where the track stopped after the call to StopMusic(); | ||
| + | if ''false'', the track will be restarted.\\ | ||
| <code c++>void StopMusic(float afFadeTime, int alPrio); | <code c++>void StopMusic(float afFadeTime, int alPrio); | ||
| </code> | </code> | ||
| Line 350: | Line 351: | ||
| //asMusic //- the music to play (including .ogg)\\ | //asMusic //- the music to play (including .ogg)\\ | ||
| //abLoopMusic //- determines whether the music should loop\\ | //abLoopMusic //- determines whether the music should loop\\ | ||
| - | //asTextCat //- the category to be used in the .lang file (must be "Ending")\\ | + | //asTextCat //- the category to be used in the .lang file\\ |
| - | //asTextEntry //- the entry in the .lang file (must be "MainCredits")\\ | + | //asTextEntry //- the entry in the .lang file\\ |
| //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. | //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. | ||
| <code c++>void StartDemoEnd(); | <code c++>void StartDemoEnd(); | ||
| Line 1035: | Line 1036: | ||
| //asTextEntry //- the entry in the .lang file\\ | //asTextEntry //- the entry in the .lang file\\ | ||
| //afTime //- time in seconds until the message disappears. If life time is <= 0 then the life time is calculated based on string length. | //afTime //- time in seconds until the message disappears. If life time is <= 0 then the life time is calculated based on string length. | ||
| + | |||
| <code c++>void GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount); | <code c++>void GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount); | ||
| </code> | </code> | ||
| - | |||
| 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. | 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. | ||
| Line 1045: | Line 1046: | ||
| //asType //- item to give\\ | //asType //- item to give\\ | ||
| //asSubTypeName //- item name for .lang file\\ | //asSubTypeName //- item name for .lang file\\ | ||
| - | //asImageName //- For exemple: void GiveItem(string& asName, string& asType, "chemical_container_full", <font 12pt:normal/auto;;rgb(255, 0, 0);;inherit >“chemical_container_full.tga”</font> , float afAmount); The image is from <//nowiki>// <//nowiki>// <//nowiki>%%\%%// <///nowiki>// <///nowiki>// <///nowiki>// graphics<nowiki>\</nowiki>Item<nowiki>\</nowiki>chemical_container_full.tga : is the image which will appear in Inventory - [[http://img155.imageshack.us/img155/6871/20806785.jpg|img155.imageshack.us/img155/6871/20806785.jpg]] | + | //asImageName //- For exemple: void GiveItem(string& asName, string& asType, "chemical_container_full", <font 12pt:normal/auto;;rgb(255, 0, 0);;inherit >“chemical_container_full.tga”</font> , float afAmount); The image is from <//nowiki>// <//nowiki>// <//nowiki><nowiki>\</nowiki>// <///nowiki>// <///nowiki>// <///nowiki>// graphics<nowiki>\</nowiki>Item<nowiki>\</nowiki>chemical_container_full.tga : is the image which will appear in Inventory - [[http://img155.imageshack.us/img155/6871/20806785.jpg|img155.imageshack.us/img155/6871/20806785.jpg]] |
| Line 1073: | Line 1074: | ||
| //asName //- internal name\\ | //asName //- internal name\\ | ||
| //asFileName //- item to give + extension (.ent) | //asFileName //- item to give + extension (.ent) | ||
| - | <code c++>void AddCombineCallback(string& asName, string& asItemA, string& asItemB, string& asFunction, bool abAutoDestroy); | + | <code c++>void AddCombineCallback(string& asName, string& asItemA, string& asItemB, string& asFunction, bool abAutoRemove); |
| </code> | </code> | ||
| Line 1081: | Line 1082: | ||
| - | //asName //- internal name\\ | + | //asName //- internal name for the callback\\ |
| //asItemA //- internal name of first item\\ | //asItemA //- internal name of first item\\ | ||
| //asItemB //- internal name of second item\\ | //asItemB //- internal name of second item\\ | ||
| //asFunction //- the function to call\\ | //asFunction //- the function to call\\ | ||
| - | //abAutoDestroy //- determines whether both items should be destroyed when combined | + | //abAutoRemove //- determines whether the callback should be removed when the items are combined\\ |
| <code c++>void RemoveCombineCallback(string& asName); | <code c++>void RemoveCombineCallback(string& asName); | ||
| </code> | </code> | ||
| - | Removes a combine callback. | + | Removes a combine callback.\\ |
| + | //asName// - the internal name of the callback to be removed (as specified in AddCombineCallback)\\ | ||
| <code c++>void AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy); | <code c++>void AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy); | ||
| Line 1111: | Line 1113: | ||
| Removes an item callback. | Removes an item callback. | ||
| - | |||
| ==== Entities ==== | ==== Entities ==== | ||
| Line 1363: | Line 1364: | ||
| - | Pushes objects. Note that rather high values are needed when applying forces. | + | 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). | ||
| - | //asName //- the object to push\\ | + | |
| - | //afX //- direction along the X-axis\\ | + | //asName //- the object to push; for bodies, use this format: "//entityName//_//bodyName//"\\ |
| - | //afY //- direction along the Y-axis\\ | + | //afX //- magnitude along the X-axis\\ |
| - | //afZ //- direction along the Z-axis\\ | + | //afY //- magnitude along the Y-axis\\ |
| + | //afZ //- magnitude along the Z-axis\\ | ||
| //asCoordSystem //- determines which coordinate system is used, usually "world" | //asCoordSystem //- determines which coordinate system is used, usually "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 === | === Connections === | ||
| Line 1420: | Line 1427: | ||
| //abLit //- Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit\\ | //abLit //- Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit\\ | ||
| //abEffects //- If you want to have the lamp fade in/out when it gets (un)lit | //abEffects //- If you want to have the lamp fade in/out when it gets (un)lit | ||
| - | |||
| - | |||
| === Doors === | === Doors === | ||
| Line 1489: | Line 1494: | ||
| //asName //- internal name\\ | //asName //- internal name\\ | ||
| - | //afState //- state of the object, 0 = closed, 1 = open, values inbetween are valid too! | + | //afState //- state of the object, 0 = closed, 1 = open, values inbetween (and above, for example, the bridge_metal_vert) are valid too! |
| <code c>void SetMoveObjectStateExt(string& asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed); | <code c>void SetMoveObjectStateExt(string& asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed); | ||
| </code> | </code> | ||