From 6db520bfc525165f18747b5fb50903bf0f548d50 Mon Sep 17 00:00:00 2001 From: Mateusz Uczciwek Date: Sat, 28 Oct 2023 23:47:44 +0200 Subject: [PATCH] [LeGo] Fixes, missing functions and social cards --- .../extenders/lego/applications/anim8.md | 514 +++++++-------- .../lego/applications/bloodsplats.md | 96 +-- .../extenders/lego/applications/buffs.md | 10 +- .../lego/applications/console_commands.pl.md | 2 +- .../extenders/lego/applications/cursor.md | 6 +- .../lego/applications/dialoggestures.md | 4 + .../extenders/lego/applications/focusnames.md | 2 +- .../extenders/lego/applications/gamestate.md | 4 + .../lego/applications/gamestate.pl.md | 3 +- .../extenders/lego/applications/names.md | 2 +- .../extenders/lego/applications/render.md | 2 +- .../extenders/lego/applications/saves.md | 4 +- .../extenders/lego/applications/trialoge.md | 48 +- .../lego/applications/trialoge.pl.md | 47 +- .../extenders/lego/tools/ai_function.md | 137 ++-- .../extenders/lego/tools/ai_function.pl.md | 5 +- .../extenders/lego/tools/binary_machines.md | 4 + .../lego/tools/binary_machines.pl.md | 4 + .../extenders/lego/tools/event_handler.md | 4 + .../extenders/lego/tools/frame_functions.md | 590 ++++++++++-------- .../extenders/lego/tools/hashtables.md | 60 ++ .../scripts/extenders/lego/tools/hook_dae.md | 16 + .../extenders/lego/tools/hook_engine.md | 28 + .../scripts/extenders/lego/tools/interface.md | 16 +- .../extenders/lego/tools/item_helper.md | 4 +- .../extenders/lego/tools/item_helper.pl.md | 4 +- .../scripts/extenders/lego/tools/list.md | 20 +- .../scripts/extenders/lego/tools/locals.md | 2 +- .../scripts/extenders/lego/tools/misc.md | 299 ++++----- .../scripts/extenders/lego/tools/misc.pl.md | 13 +- .../scripts/extenders/lego/tools/permmem.md | 8 +- .../scripts/extenders/lego/tools/queue.md | 4 +- .../extenders/lego/tools/string_builder.md | 18 +- .../scripts/extenders/lego/tools/talents.md | 10 +- .../extenders/lego/tools/talents.pl.md | 2 +- 35 files changed, 1169 insertions(+), 823 deletions(-) diff --git a/docs/zengin/scripts/extenders/lego/applications/anim8.md b/docs/zengin/scripts/extenders/lego/applications/anim8.md index 14a2f22552..79b4a97e9f 100644 --- a/docs/zengin/scripts/extenders/lego/applications/anim8.md +++ b/docs/zengin/scripts/extenders/lego/applications/anim8.md @@ -1,255 +1,259 @@ -# Anim8 -This package allows int or float values to be "animated" over a period of time. It is possible to string several commands together and to set the type of movement. The new version of PrintS from [Interface](../tools/interface.md) uses Anim8. - -## Dependencies - -- Floats - -## Initialization -Initialize with `LeGo_Anim8` flag. -```dae -LeGo_Init(LeGo_Anim8); -``` -## Implementation -[:material-github: Anim8.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/Anim8.d) - -## Functions - -### `Anim8_New` -Creates a new Anim8 object that can be filled with commands. -```dae -func int Anim8_New(var int initialValue, var int IsFloat) -``` -**Parameters** - -- `#!dae var int initialValue` - The initial value to start animating from. Can be an integer, or an Ikarus float. -- `var int IsFloat` - If the `initialValue` is an Ikarus float, this parameter must be set to `TRUE`. If it is an integer, it must be set to `FALSE`. - -**Return value** - -The function returns handle of the Anim8 object. - -### `Anim8_NewExt` -Creates a new Anim8 object with advanced options. Extends the `Anim8_New` function. -```dae -func int Anim8_NewExt(var int value, var func handler, var int data, var int IsFloat) -``` -**Parameters** - -- `#!dae var int value` - The initial value to start animating from. Can be an integer, or an Ikarus float. -- `#!dae var func handler` - This function is called whenever the object is updated. - The signature of the functions depends on the `data` value: - `data != 0`: `#!dae func void handler(var int data, var int value)`, - `data == 0`: `#!dae func void handler(var int value)`. -- `#!dae var int data` - Optional parameter to send an additional value to the `handler` function. If `data == 0`, it is ignored. -- `#!dae var int IsFloat` - If the `initialValue` is an Ikarus float, this parameter must be set to `TRUE`. If it is an integer, it must be set to `FALSE`. - -**Return value** - -The function returns handle of the Anim8 object. - -### `Anim8_Delete` -Deletes an Anim8 object created with `Anim8_New`. -```dae -func void Anim8_Delete(var int handle) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` - -### `Anim8_Get` -Get current value of the object. -```dae -func int Anim8_Get(var int handle) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` - -**Return value** - -The function returns value of the object. - -### `Anim8_Set` -Sets the value of the object. -```dae -func void Anim8_Set(var int handle, var int value) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` -- `#!dae var int value` - New value of the object - -### `Anim8_Empty` -Indicates whether the object is empty, i.e. has no more commands to process. -```dae -func int Anim8_Empty(var int handle) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` - -**Return value** - -The function returns `TRUE` if object is empty (has no more commands), `FALSE` is returned otherwise. - -### `Anim8_RemoveIfEmpty` -If desired, Anim8 can automatically delete an object after it is empty. -```dae -func void Anim8_RemoveIfEmpty(var int handle, var int on) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` -- `#!dae var int on` - `TRUE`: enable, `FALSE`: disable - -### `Anim8_RemoveDataIfEmpty` -With `Anim8_NewExt` handler and data can be set. If this function is called with `TRUE`, `data` is taken as a handle and `#!dae delete(data)` is called if the object is empty. Works only if `Anim8_RemoveIfEmpty` is also activated. -```dae -func void Anim8_RemoveDataIfEmpty(var int handle, var int on) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` -- `#!dae var int on` - `TRUE`: enable, `FALSE`: disable - -### `Anim8` -Packet core. Gives the object a new command to process. -```dae -func void Anim8(var int handle, var int target, var int span, var int interpol) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` -- `#!dae var int target` - Target value of this command. When the object's value has reached this value, the command is considered completed and deleted. -- `#!dae var int span` - Action duration in milliseconds -- `#!dae var int interpol` - What form of movement is used (See [constants](../various/userconstants.md#anim8) for this) - -### `Anim8q` -As already mentioned above, Anim8 can also process several commands one after the other. While Anim8 completely resets the object and deletes all commands, Anim8q just appends a new command to the list. This will be processed as soon as the previous one is completed. -```dae -func void Anim8q(var int handle, var int target, var int span, var int interpol) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` -- `#!dae var int target` - Target value of this command. When the object's value has reached this value, the command is considered completed and another one in the queue will start. -- `#!dae var int span` - Action duration in milliseconds -- `#!dae var int interpol` - What form of movement is used (See [constants](../various/userconstants.md#anim8) for this) - -### `Anim8_CallOnRemove` -Registers a function to be called when the object is deleted (e.g. by `Anim8_RemoveIfEmpty`) -```dae -func void Anim8_CallOnRemove(var int handle, var func dfnc) -``` -**Parameters** - -- `#!dae var int handle` - Handle returned from `Anim8_New` -- `#!dae var func dfnc` - This function is called when the object is deleted - -## Examples - -### Count up to a number -Count from 0 to 10 in 10 seconds. We use the `Print_Ext` function from [Interface](../tools/interface.md) to display the text. -```dae -func void Example1() -{ - // First we create a handle to a text: - var int MyText; MyText = Print_Ext(20, 20, "0", Font_Screen, COL_White, -1); - - // After that we create a new, extended Anim8 object. - // It gets a handler and the handle to the text as data: - var int MyAnim8; MyAnim8 = Anim8_NewExt(0, MyLoop1, MyText, FALSE); - // Start value 1, MyLoop1 as handler, MyText as data and no float - - // Now the command to count to 10: - Anim8(MyAnim8, 10, 10000, A8_Constant); // With MyAnim8 to 10 within 10000ms with constant motion. - - // So that the text and the Anim8 object are deleted after the process. - // Now we have to do two more things: - Anim8_RemoveIfEmpty(MyAnim8, TRUE); - Anim8_RemoveDataIfEmpty(MyAnim8, TRUE); -}; - -func void MyLoop1(var int MyText, var int Number) -{ - var zCViewText t; t = _^(myText); - - // Now the text is set to the value of the Anim8 object: - t.text = IntToString(Number); - - // As I said, everything is deleted fully automatically -}; -``` -A similar example can be found in the [Interface examples](../tools/interface.md#examples). - -### Moving zCVob in loop -Now we make a vob constantly move back and forth, but without a mover. [FrameFunctions](../tools/frame_functions.md) are used for the loop: -```dae hl_lines="32" -var zCVob MyVob; -var int MyVobAni; - -func void Example2() -{ - // We use Ikarus to get a pointer to a known VOB: - MyVob = MEM_PtrToInst(MEM_SearchVobByName("MYVOB")); - // There must be a vob with the appropriate name in the world for this. - - // Since the positions of a vob are floats, this time Anim8 must also use floats: - MyVobAni = Anim8_New(MyVob.trafoObjToWorld[3], TRUE); - // The X position of the vob serves as the starting value. - // We will also move it along this axis. - - // Now start a loop that "nudges" the vob over and over again: - FF_Apply(MyVobLoop); -}; - -func void MyVobLoop() -{ - // We get the pointer to the VOB again - MyVob = MEM_PtrToInst(MEM_SearchVobByName("MYVOB")); - - // Whenever there are no more commands, we add new ones: - if(Anim8_Empty(MyVobAni)) - { - // First move by three meters: - Anim8(MyVobAni, addf(MyVob.trafoObjToWorld[3], mkf(300)), 1000, A8_SlowEnd); - // Then wait half a second: - Anim8q(MyVobAni, 0, 500, A8_Wait); - // And then back again: - Anim8q(MyVobAni, MyVob.trafoObjToWorld[3], 1000, A8_SlowEnd); - // And wait another half a second: - Anim8q(MyVobAni, 0, 500, A8_Wait); - // Note the 'q' in the follow-up commands. - // While Anim8 completely resets the command list, i.e. starts again, Anim8q appends the command to the queue. - // So you can tinker with a command sequence. - }; - // Of course, we must set the "animated" value to the VOB itself - MyVob.trafoObjToWorld[3] = Anim8_Get(MyVobAni); -}; -``` +--- +title: Anim8 +description: LeGo package for "animating" float values over a period of time +--- +# Anim8 +This package allows int or float values to be "animated" over a period of time. It is possible to string several commands together and to set the type of movement. The new version of PrintS from [Interface](../tools/interface.md) uses Anim8. + +## Dependencies + +- [Floats](../../ikarus/floats.md) + +## Initialization +Initialize with `LeGo_Anim8` flag. +```dae +LeGo_Init(LeGo_Anim8); +``` +## Implementation +[:material-github: Anim8.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/Anim8.d) + +## Functions + +### `Anim8_New` +Creates a new Anim8 object that can be filled with commands. +```dae +func int Anim8_New(var int initialValue, var int IsFloat) +``` +**Parameters** + +- `#!dae var int initialValue` + The initial value to start animating from. Can be an integer, or an Ikarus float. +- `var int IsFloat` + If the `initialValue` is an Ikarus float, this parameter must be set to `TRUE`. If it is an integer, it must be set to `FALSE`. + +**Return value** + +The function returns handle of the Anim8 object. + +### `Anim8_NewExt` +Creates a new Anim8 object with advanced options. Extends the [`Anim8_New`](#anim8_new) function. +```dae +func int Anim8_NewExt(var int value, var func handler, var int data, var int IsFloat) +``` +**Parameters** + +- `#!dae var int value` + The initial value to start animating from. Can be an integer, or an Ikarus float. +- `#!dae var func handler` + This function is called whenever the object is updated. + The signature of the functions depends on the `data` value: + `data != 0`: `#!dae func void handler(var int data, var int value)`, + `data == 0`: `#!dae func void handler(var int value)`. +- `#!dae var int data` + Optional parameter to send an additional value to the `handler` function. If `data == 0`, it is ignored. +- `#!dae var int IsFloat` + If the `initialValue` is an Ikarus float, this parameter must be set to `TRUE`. If it is an integer, it must be set to `FALSE`. + +**Return value** + +The function returns handle of the Anim8 object. + +### `Anim8_Delete` +Deletes an Anim8 object created with [`Anim8_New`](#anim8_new). +```dae +func void Anim8_Delete(var int handle) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) + +### `Anim8_Get` +Get current value of the object. +```dae +func int Anim8_Get(var int handle) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) + +**Return value** + +The function returns value of the object. + +### `Anim8_Set` +Sets the value of the object. +```dae +func void Anim8_Set(var int handle, var int value) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) +- `#!dae var int value` + New value of the object + +### `Anim8_Empty` +Indicates whether the object is empty, i.e. has no more commands to process. +```dae +func int Anim8_Empty(var int handle) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) + +**Return value** + +The function returns `TRUE` if object is empty (has no more commands), `FALSE` is returned otherwise. + +### `Anim8_RemoveIfEmpty` +If desired, Anim8 can automatically delete an object after it is empty. +```dae +func void Anim8_RemoveIfEmpty(var int handle, var int on) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) +- `#!dae var int on` + `TRUE`: enable, `FALSE`: disable + +### `Anim8_RemoveDataIfEmpty` +With [`Anim8_NewExt`](#anim8_newext) handler and data can be set. If this function is called with `TRUE`, `data` is taken as a handle and `#!dae delete(data)` is called if the object is empty. Works only if [`Anim8_RemoveIfEmpty`](#anim8_removeifempty) is also activated. +```dae +func void Anim8_RemoveDataIfEmpty(var int handle, var int on) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) +- `#!dae var int on` + `TRUE`: enable, `FALSE`: disable + +### `Anim8` +Packet core. Gives the object a new command to process. +```dae +func void Anim8(var int handle, var int target, var int span, var int interpol) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) +- `#!dae var int target` + Target value of this command. When the object's value has reached this value, the command is considered completed and deleted. +- `#!dae var int span` + Action duration in milliseconds +- `#!dae var int interpol` + What form of movement is used (See [constants](../various/userconstants.md#anim8) for this) + +### `Anim8q` +As already mentioned above, Anim8 can also process several commands one after the other. While Anim8 completely resets the object and deletes all commands, Anim8q just appends a new command to the list. This will be processed as soon as the previous one is completed. +```dae +func void Anim8q(var int handle, var int target, var int span, var int interpol) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) +- `#!dae var int target` + Target value of this command. When the object's value has reached this value, the command is considered completed and another one in the queue will start. +- `#!dae var int span` + Action duration in milliseconds +- `#!dae var int interpol` + What form of movement is used (See [constants](../various/userconstants.md#anim8) for this) + +### `Anim8_CallOnRemove` +Registers a function to be called when the object is deleted (e.g. by [`Anim8_RemoveIfEmpty`](#anim8_removeifempty)) +```dae +func void Anim8_CallOnRemove(var int handle, var func dfnc) +``` +**Parameters** + +- `#!dae var int handle` + Handle returned from [`Anim8_New`](#anim8_new) +- `#!dae var func dfnc` + This function is called when the object is deleted + +## Examples + +### Count up to a number +Count from 0 to 10 in 10 seconds. We use the `Print_Ext` function from [Interface](../tools/interface.md) to display the text. +```dae +func void Example1() +{ + // First we create a handle to a text: + var int MyText; MyText = Print_Ext(20, 20, "0", Font_Screen, COL_White, -1); + + // After that we create a new, extended Anim8 object. + // It gets a handler and the handle to the text as data: + var int MyAnim8; MyAnim8 = Anim8_NewExt(0, MyLoop1, MyText, FALSE); + // Start value 1, MyLoop1 as handler, MyText as data and no float + + // Now the command to count to 10: + Anim8(MyAnim8, 10, 10000, A8_Constant); // With MyAnim8 to 10 within 10000ms with constant motion. + + // So that the text and the Anim8 object are deleted after the process. + // Now we have to do two more things: + Anim8_RemoveIfEmpty(MyAnim8, TRUE); + Anim8_RemoveDataIfEmpty(MyAnim8, TRUE); +}; + +func void MyLoop1(var int MyText, var int Number) +{ + var zCViewText t; t = _^(myText); + + // Now the text is set to the value of the Anim8 object: + t.text = IntToString(Number); + + // As I said, everything is deleted fully automatically +}; +``` +A similar example can be found in the [Interface examples](../tools/interface.md#examples). + +### Moving zCVob in loop +Now we make a vob constantly move back and forth, but without a mover. [FrameFunctions](../tools/frame_functions.md) are used for the loop: +```dae hl_lines="32" +var zCVob MyVob; +var int MyVobAni; + +func void Example2() +{ + // We use Ikarus to get a pointer to a known VOB: + MyVob = MEM_PtrToInst(MEM_SearchVobByName("MYVOB")); + // There must be a vob with the appropriate name in the world for this. + + // Since the positions of a vob are floats, this time Anim8 must also use floats: + MyVobAni = Anim8_New(MyVob.trafoObjToWorld[3], TRUE); + // The X position of the vob serves as the starting value. + // We will also move it along this axis. + + // Now start a loop that "nudges" the vob over and over again: + FF_Apply(MyVobLoop); +}; + +func void MyVobLoop() +{ + // We get the pointer to the VOB again + MyVob = MEM_PtrToInst(MEM_SearchVobByName("MYVOB")); + + // Whenever there are no more commands, we add new ones: + if(Anim8_Empty(MyVobAni)) + { + // First move by three meters: + Anim8(MyVobAni, addf(MyVob.trafoObjToWorld[3], mkf(300)), 1000, A8_SlowEnd); + // Then wait half a second: + Anim8q(MyVobAni, 0, 500, A8_Wait); + // And then back again: + Anim8q(MyVobAni, MyVob.trafoObjToWorld[3], 1000, A8_SlowEnd); + // And wait another half a second: + Anim8q(MyVobAni, 0, 500, A8_Wait); + // Note the 'q' in the follow-up commands. + // While Anim8 completely resets the command list, i.e. starts again, Anim8q appends the command to the queue. + // So you can tinker with a command sequence. + }; + // Of course, we must set the "animated" value to the VOB itself + MyVob.trafoObjToWorld[3] = Anim8_Get(MyVobAni); +}; +``` diff --git a/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md b/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md index 014b701e51..dd6d795818 100644 --- a/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md +++ b/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md @@ -1,38 +1,58 @@ -# Bloodsplats -If this package is activated, red blood splatters will appear on the screen when the hero takes damage. For this, the damage perception for the hero is redirected to `_B_HeroDamage()`. To use the Bloodsplats, the enclosed textures must be available. Also, the VFX "HERO_HURT" (also included) should be entered in the `VfxInst.d` to create an even better hit effect. All textures used here are from [CGTextures.com](http://CGTextures.com). If you use Bloodsplats in your modification, this site must be noted in the credits. - -!!! Tip - See [user constants](../various/userconstants.md#bloodsplats) to edit behavior of this packet. - -## Dependencies - -- Floats -- View -- [Random](../tools/random.md) -- [Anim8](anim8.md) - -## Initialization -Initialize with `LeGo_Bloodsplats` flag. -```dae -LeGo_Init(LeGo_Bloodsplats); -``` -## Implementation -[:material-github: Bloodsplats.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/Bloodsplats.d) - -## Functions - -### `Bloodsplat` -Puts a blood splatter on the screen. -```dae -func void Bloodsplat(var int damage) -``` -**Parameters** - -- `#!dae var int damage` - The damage (affects the size of the splatter) - -### `Bloodsplats_Rage` -Pretty pointless feature that smears the entire screen. -```dae -func void Bloodsplats_Rage() -``` +--- +title: Bloodsplats +description: LeGo package for displaying bloodsplats on a screen when player is hit +--- +# Bloodsplats +If this package is activated, red blood splatters will appear on the screen when the hero takes damage. For this, the damage perception for the hero is redirected to `_B_HeroDamage()`. To use the Bloodsplats, the enclosed textures must be available. Also, the VFX "HERO_HURT" (also included) should be entered in the `VfxInst.d` to create an even better hit effect. All textures used here are from [CGTextures.com](http://CGTextures.com). If you use Bloodsplats in your modification, this site must be noted in the credits. + +!!! Tip + See [user constants](../various/userconstants.md#bloodsplats) to edit behavior of this packet. + +## Dependencies + +- [Floats](../../ikarus/floats.md) +- View +- [Random](../tools/random.md) +- [Anim8](anim8.md) + +## Initialization +Initialize with `LeGo_Bloodsplats` flag. +```dae +LeGo_Init(LeGo_Bloodsplats); +``` +## Implementation +[:material-github: Bloodsplats.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/Bloodsplats.d) + +## Functions + +### `Bloodsplat` +Puts a blood splatter on the screen. +```dae +func void Bloodsplat(var int damage) +``` +**Parameters** + +- `#!dae var int damage` + The damage (affects the size of the splatter) + +### `Bloodsplats_Rage` +Pretty pointless feature that smears the entire screen. +```dae +func void Bloodsplats_Rage() +``` + +### `Npc_GetPercFunc` +`oCNpc::GetPerceptionFunc` engine function wraper +```dae +func int Npc_GetPercFunc(var C_Npc npc, var int type) +``` +**Parameters** + +- `#!dae var C_NPC npc` + NPC whose percepcion is checked +- `#!dae var int type` + Checked perception type (form [`Constant.d`](https://github.com/VaanaCZ/gothic-2-addon-scripts/blob/Unified-EN/_work/Data/Scripts/Content/_intern/Constants.d#L213-L258)) + +**Return value** + +The function returns the state of NPCs selected perception. \ No newline at end of file diff --git a/docs/zengin/scripts/extenders/lego/applications/buffs.md b/docs/zengin/scripts/extenders/lego/applications/buffs.md index 70acef0c05..48f3bbb8d2 100644 --- a/docs/zengin/scripts/extenders/lego/applications/buffs.md +++ b/docs/zengin/scripts/extenders/lego/applications/buffs.md @@ -39,7 +39,7 @@ func int Buff_Apply(var C_NPC npc, var int buff) The function returns the handle of the buff, which was just generated. ### `Buff_ApplyUnique` -`Buff_Apply`, but nothing happens if a status effect of that kind is already on the NPC. +[`Buff_Apply`](#buff_apply), but nothing happens if a status effect of that kind is already on the NPC. ```dae func int Buff_ApplyUnique(var C_NPC npc, var int buff) ``` @@ -56,7 +56,7 @@ func int Buff_ApplyUnique(var C_NPC npc, var int buff) The function returns the handle of the buff, which was just generated or `0` if the buff is already applied on the NPC. ### `Buff_ApplyOrRefresh` -`Buff_Apply`, but if a status effect of this type is already affecting the NPC, the duration will be reset. +[`Buff_Apply`](#buff_apply), but if a status effect of this type is already affecting the NPC, the duration will be reset. ```dae func int Buff_ApplyOrRefresh(var C_NPC n, var int buff) ``` @@ -84,8 +84,6 @@ func void Buff_Refresh(var int buffHandle) ### `Buff_Remove` Removes the buff from the all NPCs. - -[//]: # (TODO Needs to be checked) ```dae func void Buff_Remove(var int buffHandle) ``` @@ -96,8 +94,6 @@ func void Buff_Remove(var int buffHandle) ### `Buff_RemoveAll` Removes the buffs form the NPC. - -[//]: # (TODO Needs to be checked) ```dae func void Buff_RemoveAll(var C_NPC npc, var int buffInstance) ``` @@ -179,7 +175,7 @@ class lCBuff ## Examples -## Delayed poison +### Delayed poison ```dae instance deadly_poison(lCBuff) { diff --git a/docs/zengin/scripts/extenders/lego/applications/console_commands.pl.md b/docs/zengin/scripts/extenders/lego/applications/console_commands.pl.md index 56db711d51..f16c9d240f 100644 --- a/docs/zengin/scripts/extenders/lego/applications/console_commands.pl.md +++ b/docs/zengin/scripts/extenders/lego/applications/console_commands.pl.md @@ -1,5 +1,5 @@ --- -title: Polecenia konsoli +title: Console Commands --- # Console Commands - polecenia konsoli Ten Pakiet pozwala na tworzenie nowych poleceń konsoli dostępnej po naciśnięciu klawisza F2 w trybie marvin. diff --git a/docs/zengin/scripts/extenders/lego/applications/cursor.md b/docs/zengin/scripts/extenders/lego/applications/cursor.md index 4be94167d0..9b1546dde4 100644 --- a/docs/zengin/scripts/extenders/lego/applications/cursor.md +++ b/docs/zengin/scripts/extenders/lego/applications/cursor.md @@ -7,9 +7,9 @@ This package implements Gothic in-game mouse cursor support. To visually display ## Dependencies -- Floats +- [Floats](../../ikarus/floats.md) - [FrameFunctions](../tools/frame_functions.md) -- View +- [View](../tools/view.md) ## Initialization Initialize with `LeGo_Cursor` flag. @@ -115,7 +115,7 @@ func void Button_Click() }; ``` -This also can be done by the Buttons package instead of View. +This also can be done by the Buttons package instead of [View](../tools/view.md). ### Event handler Since LeGo 2.2 there is also an event handler (`#!dae var int Cursor_Event`) in the cursor package. This example briefly explains how it works: diff --git a/docs/zengin/scripts/extenders/lego/applications/dialoggestures.md b/docs/zengin/scripts/extenders/lego/applications/dialoggestures.md index 7ea06ea9f4..402e2f8699 100644 --- a/docs/zengin/scripts/extenders/lego/applications/dialoggestures.md +++ b/docs/zengin/scripts/extenders/lego/applications/dialoggestures.md @@ -1,3 +1,7 @@ +--- +title: Dialoggestures +description: LeGo package for modifying the NPCs' gestures during dialogue +--- # Dialoggestures This package can modify the NPCs' gestures during dialogue to better bring out emotions. diff --git a/docs/zengin/scripts/extenders/lego/applications/focusnames.md b/docs/zengin/scripts/extenders/lego/applications/focusnames.md index 8dde149938..59bc86c0a1 100644 --- a/docs/zengin/scripts/extenders/lego/applications/focusnames.md +++ b/docs/zengin/scripts/extenders/lego/applications/focusnames.md @@ -16,7 +16,7 @@ LeGo_Init(LeGo_Focusnames); [:material-github: Focusnames.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/Focusnames.d) ## Usage -If you want to change colors for any behavior edit the following functions directly in `Focusnames.d` file. +If you want to change colors for any behavior edit the following functions directly in [`Focusnames.d`](https://github.com/Lehona/LeGo/blob/dev/Focusnames.d) file. ### `Focusnames_Color_Friendly` ```dae diff --git a/docs/zengin/scripts/extenders/lego/applications/gamestate.md b/docs/zengin/scripts/extenders/lego/applications/gamestate.md index 9b7fc50053..00fe81bad6 100644 --- a/docs/zengin/scripts/extenders/lego/applications/gamestate.md +++ b/docs/zengin/scripts/extenders/lego/applications/gamestate.md @@ -1,3 +1,7 @@ +--- +title: Gamestate +description: LeGo package for calling functions during different game states +--- # Gamestate Gamestate package allows to check for different game states (game start, game load or level change). diff --git a/docs/zengin/scripts/extenders/lego/applications/gamestate.pl.md b/docs/zengin/scripts/extenders/lego/applications/gamestate.pl.md index e8c99e7377..806931e79c 100644 --- a/docs/zengin/scripts/extenders/lego/applications/gamestate.pl.md +++ b/docs/zengin/scripts/extenders/lego/applications/gamestate.pl.md @@ -1,5 +1,6 @@ --- -title: Stan gry +title: Gamestate +description: Pakiet LeGo do wywoływania funkcji podczas różnych stanów gry --- # Gamestate - stan gry Pakiet Gamestate pozwala sprawdzić stan gry (rozpoczęcie gry, ładowanie gry lub zmiana poziomu). diff --git a/docs/zengin/scripts/extenders/lego/applications/names.md b/docs/zengin/scripts/extenders/lego/applications/names.md index 750919ed46..107abbb5d0 100644 --- a/docs/zengin/scripts/extenders/lego/applications/names.md +++ b/docs/zengin/scripts/extenders/lego/applications/names.md @@ -2,7 +2,7 @@ Allows the user to change NPC name e.g. after he shows up. ## Dependencies -N/A +- [Talents](../tools/talents.md) ## Initialization N/A diff --git a/docs/zengin/scripts/extenders/lego/applications/render.md b/docs/zengin/scripts/extenders/lego/applications/render.md index 728930519a..b2b78447d5 100644 --- a/docs/zengin/scripts/extenders/lego/applications/render.md +++ b/docs/zengin/scripts/extenders/lego/applications/render.md @@ -2,7 +2,7 @@ With this package items can be rendered on the screen. Since items are rendered independently of the normal views, textures that are 'below' the items must also be managed by this package, this behaviour is managed by the priority system. The view with the highest priority is always rendered first, so it is at the bottom. In theory, any .3DS model can be rendered if you just create a suitable item script. ## Dependencies -- List +- [List](../tools/list.md) - View - [PermMem](../tools/permmem.md) diff --git a/docs/zengin/scripts/extenders/lego/applications/saves.md b/docs/zengin/scripts/extenders/lego/applications/saves.md index 26f220aa45..a2c0cc6ff7 100644 --- a/docs/zengin/scripts/extenders/lego/applications/saves.md +++ b/docs/zengin/scripts/extenders/lego/applications/saves.md @@ -17,13 +17,13 @@ LeGo_Init(LeGo_Saves); ## Functions ### `BW_Savegame` -Custom function. It creates a stream to its own memory file, this can be filled with the `BW_*` functions from the [BinaryMachines](../tools/binary_machines.md). +Custom function. It creates a stream to its own memory file, this can be filled with the `BW_*` functions from the [BinaryMachines](../tools/binary_machines.md#binarywriter). ```dae func void BW_Savegame() ``` ### `BR_Savegame` -Custom function. It opens a stream to a previously saved memory file, which can be read from the [BinaryMachines](../tools/binary_machines.md) using the `BR_*` functions. +Custom function. It opens a stream to a previously saved memory file, which can be read from the [BinaryMachines](../tools/binary_machines.md#binaryreader) using the `BR_*` functions. ```dae func void BR_Savegame() ``` diff --git a/docs/zengin/scripts/extenders/lego/applications/trialoge.md b/docs/zengin/scripts/extenders/lego/applications/trialoge.md index c6372ce80c..27bbb993cf 100644 --- a/docs/zengin/scripts/extenders/lego/applications/trialoge.md +++ b/docs/zengin/scripts/extenders/lego/applications/trialoge.md @@ -1,3 +1,7 @@ +--- +title: Trialoge +description: LeGo package implementing trialogues to gothic +--- # Trialoge This package allows you to create conversations with any number of NPCs and control the camera during the dialog. @@ -16,7 +20,7 @@ LeGo_Init(LeGo_Trialoge); ## Functions ### `EquipWeapon` -Sektenspinner's function. (Taken from the forum.) +Sektenspinner's function. Makes NPC equip a weapon. ```dae func void EquipWeapon(var C_NPC slf, var int ItemInstance) ``` @@ -25,7 +29,16 @@ func void EquipWeapon(var C_NPC slf, var int ItemInstance) - `#!dae var C_NPC slf` NPC to have a weapon equipped - `#!dae var int ItemInstance` - Weapon instance to be equipped + Weapon instance ID to be equipped + +**Configuration** + +`#!dae const int EquipWeapon_TogglesEquip = 1` + +Above constant configures the behaviour of the function when trying to equip an already equipped weapon: + +- `0` - `EquipWeapon` will do nothing +- `1` - `EquipWeapon` will unequip this weapon ### `Npc_GetArmor` Returns NPC's equipped armor. @@ -53,7 +66,36 @@ func int Npc_GetMeleeWeapon(var C_NPC slf) **Return value** -The function returns instance of melee weapon equipped by the NPC. +The function returns instance ID of melee weapon equipped by the NPC. + +### `Npc_GetRangedWeapon` +Returns NPC's equipped ranged weapon. +```dae +func int Npc_GetRangedWeapon(var c_npc slf) +``` +**Parameters** + +- `#!dae var C_NPC slf` + NPC to get the weapon from + +**Return value** + +The function returns instance ID of ranged weapon equipped by the NPC. + +### `Npc_TradeItem` +Swaps NPCs equipped weapon. +```dae +func void Npc_TradeItem(var c_npc slf, var int itm0, var int itm1) +``` +**Parameters** + +- `#!dae var C_NPC slf` + NPC to perform operation on +- `#!dae var int itm0` + instance ID of item to remove +- `#!dae var int itm1` + instance ID of item to create and equip + ### `DiaCAM_Update` Sektenspinner's function that updates the dialogue camera. (Used internally.) diff --git a/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md b/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md index d93b1ff5a3..06a9f8852f 100644 --- a/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md +++ b/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md @@ -1,3 +1,7 @@ +--- +title: Trialoge +description: Pakiet LeGo implementujący trialogi w gothicu +--- # Trialogi Ten pakiet pozwala na tworzenie rozmów z dowolną liczbą NPC i sterowanie kamerą podczas dialogu. @@ -16,7 +20,7 @@ LeGo_Init(LeGo_Trialoge); ## Funkcje ### `EquipWeapon` -Funkcja Sektenspinnera. (wzięta z forum) +Funkcja Sektenspinnera. Sprawia, że NPC wyposaża broń. ```dae func void EquipWeapon(var C_NPC slf, var int ItemInstance) ``` @@ -27,6 +31,15 @@ func void EquipWeapon(var C_NPC slf, var int ItemInstance) - `#!dae var int ItemInstance` Instancja broni do wyposażenia +**Konfigurcja** + +`#!dae const int EquipWeapon_TogglesEquip = 1` + +Powyższa stała ustala zachowanie funkcji podczas próby założenia już założonej bronii: + +- `0` - `EquipWeapon` nic nie zrobi +- `1` - `EquipWeapon` zdejmie tą broń + ### `Npc_GetArmor` Pobiera pancerz wyposażony przez NPC. ```dae @@ -39,7 +52,7 @@ func int Npc_GetArmor(var C_NPC slf) **Zwracana wartość** -Funkcja zwraca instancje pancerza założonego przez NPC. +Funkcja zwraca ID instancji pancerza założonego przez NPC. ### `Npc_GetMeleeWeapon` Pobiera wyposażoną przez NPC broń białą. @@ -53,7 +66,35 @@ func int Npc_GetMeleeWeapon(var C_NPC slf) **Zwracana wartość** -Funkcja zwraca instancje broni białej wyposażonej przez NPC. +Funkcja zwraca ID instancji broni białej wyposażonej przez NPC. + +### `Npc_GetRangedWeapon` +Pobiera wyposażoną przez NPC broń dystansową. +```dae +func int Npc_GetRangedWeapon(var C_NPC slf) +``` +**Parametry** + +- `#!dae var C_NPC slf` + NPC którego broń jest pobierana + +**Zwracana wartość** + +Funkcja zwraca ID instancji broni dystansowej wyposażonej przez NPC. + +### `Npc_TradeItem` +Podmienia broń założoną przez NPC. +```dae +func void Npc_TradeItem(var c_npc slf, var int itm0, var int itm1) +``` +**Parameters** + +- `#!dae var C_NPC slf` + NPC na którym wykonywana jest operacja +- `#!dae var int itm0` + ID instancji przedmiotu do usunięcia +- `#!dae var int itm1` + ID instancji przedmiotu do stworzenia i założenia ### `DiaCAM_Update` Funkcja Sektenspinnera. Aktualizuje kamerę dialogową. (Używana wewnętrznie) diff --git a/docs/zengin/scripts/extenders/lego/tools/ai_function.md b/docs/zengin/scripts/extenders/lego/tools/ai_function.md index f0554acd8b..653d4a0252 100644 --- a/docs/zengin/scripts/extenders/lego/tools/ai_function.md +++ b/docs/zengin/scripts/extenders/lego/tools/ai_function.md @@ -1,69 +1,70 @@ ---- -title: AI_Function ---- -# AI_Function -This package allows time-delayed functions to be called by enqueuing the functions in the AI queue of the NPC in question. This can be very useful in writing cutscenes on engine or implementing new routines. - -## Dependencies - -- [HookEngine](hook_engine.md) - -## Initialization -Initialize with `LeGo_AI_Function` flag. -```dae -LeGo_Init(LeGo_AI_Function); -``` -## Implementation -[:material-github: AI_Function.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/AI_Function.d) - -## Functions -The script function `function` is called with a delay: it joins the AI queue of `slf`. -```dae -func void AI_Function(var C_NPC slf, var func function) -``` -**Parameters** - -- `#!dae var C_NPC slf` - NPC in whose AI queue the function is queued -- `#!dae var func function` - Name of function to be queued - -Additionally, there are some overloads of `AI_Function`, which allow to call functions with parameters. -```dae -func void AI_Function_I (var C_NPC slf, var func function, var int param) {}; // Int -func void AI_Function_N (var C_NPC slf, var func function, var int param) {}; // Instance (e.g. NPC) -func void AI_Function_S (var C_NPC slf, var func function, var string param) {}; // String -func void AI_Function_II (var C_NPC slf, var func function, var int param1, var int param2) {}; // Int, Int -func void AI_Function_NN (var C_NPC slf, var func function, var int param1, var int param2) {}; // Instance, Instance -func void AI_Function_SS (var C_NPC slf, var func function, var string param1, var string param2) {}; // String, String -func void AI_Function_IS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Int, String -func void AI_Function_SI (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Int -func void AI_Function_NS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Instance, String -func void AI_Function_SN (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Istance -func void AI_Function_IN (var C_NPC slf, var func function, var int param1, var int param2) {}; // Int, Instance -func void AI_Function_NI (var C_NPC slf, var func function, var int param1, var int param2) {}; // Instance, Int -``` -Functions with more than two parameters cannot be called, but parameters can be passed indirectly via global variables. - -In the called function, `slf` can be accessed as follows: -```dae -var oCNpc slf; slf = _^(ECX); -``` -!!! Info - From LeGo 2.7.2 the global instance `self` is provided correctly and can be used directly. - -## Examples - -### Enqueueing a simple function -Before a function is called, any Npc should first complete its AI queue. - -Here the hero is supposed to run to a waypoint, and only when he has arrived is to start a tracking shot. -```dae -func void Example1() { - Npc_ClearAIQueue(hero); - AI_GotoWP(hero, "MYWAYPOINT"); - - AI_Function_S(hero, Wld_SendTrigger, "CAMERASTART"); -}; -``` +--- +title: AI_Function +description: LeGo package for enqueuing functions to NPC's AI queue +--- +# AI_Function +This package allows time-delayed functions to be called by enqueuing the functions in the AI queue of the NPC in question. This can be very useful in writing cutscenes on engine or implementing new routines. + +## Dependencies + +- [HookEngine](hook_engine.md) + +## Initialization +Initialize with `LeGo_AI_Function` flag. +```dae +LeGo_Init(LeGo_AI_Function); +``` +## Implementation +[:material-github: AI_Function.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/AI_Function.d) + +## Functions +The script function `function` is called with a delay: it joins the AI queue of `slf`. +```dae +func void AI_Function(var C_NPC slf, var func function) +``` +**Parameters** + +- `#!dae var C_NPC slf` + NPC in whose AI queue the function is queued +- `#!dae var func function` + Name of function to be queued + +Additionally, there are some overloads of `AI_Function`, which allow to call functions with parameters. +```dae +func void AI_Function_I (var C_NPC slf, var func function, var int param) {}; // Int +func void AI_Function_N (var C_NPC slf, var func function, var int param) {}; // Instance (e.g. NPC) +func void AI_Function_S (var C_NPC slf, var func function, var string param) {}; // String +func void AI_Function_II (var C_NPC slf, var func function, var int param1, var int param2) {}; // Int, Int +func void AI_Function_NN (var C_NPC slf, var func function, var int param1, var int param2) {}; // Instance, Instance +func void AI_Function_SS (var C_NPC slf, var func function, var string param1, var string param2) {}; // String, String +func void AI_Function_IS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Int, String +func void AI_Function_SI (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Int +func void AI_Function_NS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Instance, String +func void AI_Function_SN (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Istance +func void AI_Function_IN (var C_NPC slf, var func function, var int param1, var int param2) {}; // Int, Instance +func void AI_Function_NI (var C_NPC slf, var func function, var int param1, var int param2) {}; // Instance, Int +``` +Functions with more than two parameters cannot be called, but parameters can be passed indirectly via global variables. + +In the called function, `self` can be accessed as follows: +```dae +var oCNpc slf; slf = _^(ECX); +``` +!!! Info + From LeGo 2.7.2 the global instance `self` is provided correctly and can be used directly. + +## Examples + +### Enqueueing a simple function +Before a function is called, any Npc should first complete its AI queue. + +Here the hero is supposed to run to a waypoint, and only when he has arrived is to start a tracking shot. +```dae +func void Example1() { + Npc_ClearAIQueue(hero); + AI_GotoWP(hero, "MYWAYPOINT"); + + AI_Function_S(hero, Wld_SendTrigger, "CAMERASTART"); +}; +``` As soon as the hero has reached the waypoint, `Wld_SendTrigger("CAMERASTART");` is called. \ No newline at end of file diff --git a/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md b/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md index 54bbfbd88b..a82a2c85bf 100644 --- a/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md +++ b/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md @@ -1,5 +1,6 @@ --- -title: Funkcje AI +title: AI_Function +description: Pakiet LeGo do kolejkowania funkcji w kolejce AI dowolnego NPC --- # AI_Function - Funkcje AI Ten pakiet umożliwia wywoływanie funkcji opóźnionych w czasie poprzez kolejkowanie ich w kolejce AI danego NPC. Może to być bardzo przydatne przy pisaniu przerywników filmowych na silniku lub implementacji nowych rutyn. @@ -45,7 +46,7 @@ func void AI_Function_NI (var C_NPC slf, var func function, var int param1, v ``` Nie można wywoływać funkcji z więcej niż dwoma parametrami, ale parametry można przekazywać pośrednio przez zmienne globalne. -W wywołanej funkcji dostęp do `slf` można uzyskać w następujący sposób: +W wywołanej funkcji dostęp do `self` można uzyskać w następujący sposób: ```dae var oCNpc slf; slf = _^(ECX); ``` diff --git a/docs/zengin/scripts/extenders/lego/tools/binary_machines.md b/docs/zengin/scripts/extenders/lego/tools/binary_machines.md index c3d18d421a..1c874509ac 100644 --- a/docs/zengin/scripts/extenders/lego/tools/binary_machines.md +++ b/docs/zengin/scripts/extenders/lego/tools/binary_machines.md @@ -1,3 +1,7 @@ +--- +title: BinaryMachines +description: LeGo package for creating, writing and reading your own files +--- # BinaryMachines This package allows you to create and write your own files anywhere in the file system. diff --git a/docs/zengin/scripts/extenders/lego/tools/binary_machines.pl.md b/docs/zengin/scripts/extenders/lego/tools/binary_machines.pl.md index c8d9529b53..5f0c91ad7a 100644 --- a/docs/zengin/scripts/extenders/lego/tools/binary_machines.pl.md +++ b/docs/zengin/scripts/extenders/lego/tools/binary_machines.pl.md @@ -1,3 +1,7 @@ +--- +title: BinaryMachines +description: Pakiet LeGo do tworzenia, zapisywania i odczytywania własnych plików +--- # BinaryMachines Ten pakiet pozwala tworzyć i zapisywać własne pliki w dowolnym miejscu w systemie plików. diff --git a/docs/zengin/scripts/extenders/lego/tools/event_handler.md b/docs/zengin/scripts/extenders/lego/tools/event_handler.md index 35ee4221be..ac6c7c6d9a 100644 --- a/docs/zengin/scripts/extenders/lego/tools/event_handler.md +++ b/docs/zengin/scripts/extenders/lego/tools/event_handler.md @@ -1,3 +1,7 @@ +--- +title: EventHandler +description: LeGo package for creating new script events and triggering them +--- # EventHandler This package allows to create new events and trigger them at desired times. The [Gamestate](../applications/gamestate.md) package already uses it. diff --git a/docs/zengin/scripts/extenders/lego/tools/frame_functions.md b/docs/zengin/scripts/extenders/lego/tools/frame_functions.md index 4b5648b8b0..0a82c061d3 100644 --- a/docs/zengin/scripts/extenders/lego/tools/frame_functions.md +++ b/docs/zengin/scripts/extenders/lego/tools/frame_functions.md @@ -1,260 +1,330 @@ -# FrameFunctions -The FrameFunctions package allows to call any number of functions called on every frame, or every specified time delay. - -## Dependencies - -- Floats -- [PermMem](permmem.md) -- [HookEngine](../tools/hook_engine.md) -- [Timer](timer.md) - -## Initialization -Initialize with `LeGo_FrameFunctions` flag. -```dae -LeGo_Init(LeGo_FrameFunctions); -``` -## Implementation -[:material-github: FrameFunctions.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/FrameFunctions.d) - -## Functions - -### `FF_Apply` -Adds the Daedalus function `function` to the frame functions list. `function` is called each frame. -```dae -func void FF_Apply(var func function) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. - -### `FF_ApplyGT` -Adds the Daedalus function `function` to the frame function list. `function` is called every frame except when the game is paused. -```dae -func void FF_ApplyGT(var func function) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. - -### `FF_ApplyExt` -Adds the Daedalus function `function` to the frame function list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. -```dae -func void FF_ApplyExt(var func function, var int delay, var int cycles) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. -- `#!dae var int delay` - Delay between calls in milliseconds. (0 = every frame) -- `#!dae var int cycles` - How many times should the function be called. (-1 = endless) - -### `FF_ApplyExtGT` -Adds the Daedalus function `function` to the frame function list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. Gets called only when the game is not paused. -```dae -func void FF_ApplyExtGT(var func function, var int delay, var int cycles) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. -- `#!dae var int delay` - Delay between calls in milliseconds. (0 = every frame) -- `#!dae var int cycles` - How many times should the function be called. (-1 = endless) - -### `FF_ApplyExtData` -Adds the Daedalus function `function` to the frame function list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. The integer parameter `data` is passed to the function `function`. -```dae -func void FF_ApplyExtData(var func function, var int delay, var int cycles, var int data) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. -- `#!dae var int delay` - Delay between calls in milliseconds. (0 = every frame) -- `#!dae var int cycles` - How many times should the function be called. (-1 = endless) -- `#!dae var int data` - Value passed to the function as a parameter. - -### `FF_ApplyExtDataGT` -Adds the Daedalus function `function` to the frame function list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. The integer parameter `data` is passed to the function `function`. Gets called only when the game is not paused. -```dae -func void FF_ApplyExtData(var func function, var int delay, var int cycles, var int data) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. -- `#!dae var int delay` - Delay between calls in milliseconds. (0 = every frame) -- `#!dae var int cycles` - How many times should the function be called. (-1 = endless) -- `#!dae var int data` - Value passed to the function as a parameter. - -### `FF_ApplyOnce` -Alias to [FF_Apply](#ff_apply), which only adds the function once, even after multiple calls. -```dae -func void FF_ApplyOnce(var func function) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. - -### `FF_ApplyOnceGT` -Alias to [FF_ApplyGT](#ff_applygt), which only adds the function once, even after multiple calls. Loop doesn't run if the game is paused. -```dae -func voidoften FF_ApplyOnceGT(var func function) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. - -### `FF_ApplyOnceExt` -Alias to [FF-ApplyExt](#ff_applyext), which adds the function only once after repeated calls. -```dae -func void FF_ApplyOnceExt(var func function, var int delay, var int cycles) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. -- `#!dae var int delay` - Delay between calls in milliseconds. (0 = every frame) -- `#!dae var int cycles` - How many times should the function be called. (-1 = endless) - -### `FF_ApplyOnceExtGT` -Alias to [FF_ApplyExtGT](#ff_applyextgt), which adds the function only once after repeated calls. Loop doesn't run if the game is paused. -```dae -func void FF_ApplyOnceExtGT(var func function, var int delay, var int cycles) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. -- `#!dae var int delay` - Delay between calls in milliseconds. (0 = every frame) -- `#!dae var int cycles` - How many times should the function be called. (-1 = endless) - -### `FF_Active` -Checks whether the function `function` is active. -```dae -func int FF_Active(var func function) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. - -**Return value** -The function returns `TRUE` if the function is active, `FALSE` if it is not. - -### `FF_Remove` -Removes specified Daedalus function from the list. -```dae -func void FF_Remove(var func function) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. - -### `FF_RemoveData` -Removes specified Daedalus function with the specified value from the list (see [`FF_ApplyExtData`](#ff_applyextdata) ). -```dae -func void FF_RemoveData(var func function, var int data) -``` -**Parameters** - -- `#!dae var func function` - Name of the function. -- `#!dae var int data` - Value previously passed to the function as a parameter. - -## Examples - -### A function called every frame -In this example function `MyFunc` will be executed on every frame. -```dae -func void Example1() -{ - FF_Apply(MyFunc); -}; - -func void MyFunc() {}; -``` -After the `Example1` function is executed the function `MyFunc` is called on every frame. - -The easiest and best way to run a function from the beginning is to call [`FF-Apply`](#ff_apply) directly in the `Init_Global` (under `LeGo_Init`), there is a small problem: If the game is loaded, `Init_Global` is called a second time, the function is added to the list again and is therefore always called twice. - -To avoid this effect, you should check whether the function is already active: -```dae -func void Example1() -{ - if(!FF_Active(MyFunc)) - { - FF_Apply(MyFunc); - }; -}; -``` - -However, since LeGo version 2.2 there is an even more pleasant method to do this: -```dae -func void Example1() -{ - FF_ApplyOnce(MyFunc); -}; -``` -[`FF_ApplyOnce`](#ff_applyonce) function already implements the check for function activity. - -### Calling delayed function -Create a function, that is called once after 3 seconds. -```dae -func void Example2() -{ - FF_ApplyExt(MyFunc2, 3000, 1); // 3000 ms = 3 s, this function is called only once -}; - -func void MyFunc2() {}; -``` - -There is also a `Once` variant of this function, that prevents adding it twice into the frame function list. -```dae -func void Example2() -{ - FF_ApplyOnceExt(MyFunc2, 3000, 1); -}; -``` -!!! Note - `#!dae FF_ApplyExt(MyFunc, 0, -1)` is the same as `#!dae FF_Apply(MyFunc)`. - -### FrameFunction with Timer -Since LeGo 2.2, FrameFunctions package uses the Timer package, so it is possible to pause FrameFunctions at will: -```dae -func void Example3() -{ - FF_ApplyOnceExt(MyFunc3, 4000, 2); -}; - -func void MyFunc3() -{ - Timer_SetPaused(!Timer_GetPaused()); -}; -``` -This would pause the timer after 4 seconds and let it continue after 8 seconds. - -!!! Warning - Because the timer doesn't run, the frame function execution is stopped as well. **This script won't work**. If the timer is to be paused, it must be paused outside FrameFunctions. - -!!! Note - This is translation of article originally written by Gottfried and Lehona and hosted on LeGo's official documentation [website](https://lego.worldofplayers.de/?Beispiele_FrameFunctions). +--- +title: FrameFunctions +description: LeGo package for calling script functions on every frame, or every time delay +--- +# FrameFunctions +The FrameFunctions package allows to call any number of functions called on every frame, or every specified time delay. + +## Dependencies + +- [Floats](../../ikarus/floats.md) +- [PermMem](permmem.md) +- [HookEngine](../tools/hook_engine.md) +- [Timer](timer.md) + +## Initialization +Initialize with `LeGo_FrameFunctions` flag. +```dae +LeGo_Init(LeGo_FrameFunctions); +``` +## Implementation +[:material-github: FrameFunctions.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/FrameFunctions.d) + +## Functions + +### `FF_Apply` +Adds the Daedalus function `function` to the running FrameFunctions list. `function` is called each frame. +```dae +func void FF_Apply(var func function) +``` +**Parameters** + +- `#!dae var func function` + Name of the function + +### `FF_ApplyGT` +Adds the Daedalus function `function` to the running FrameFunctions list. `function` is called every frame except when the game is paused. +```dae +func void FF_ApplyGT(var func function) +``` +**Parameters** + +- `#!dae var func function` + Name of the function + +### `FF_ApplyData` +Adds the Daedalus function `function` to the running FrameFunctions list. The integer parameter `data` is passed to the function `function`. +```dae +func void FF_ApplyData(var func function, var int data) +``` +**Parameters** + +- `#!dae var func function` + Name of the function. +- `#!dae var int data` + Value passed to the function as a parameter + + +### `FF_ApplyExt` +Adds the Daedalus function `function` to the running FrameFunctions list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. +```dae +func void FF_ApplyExt(var func function, var int delay, var int cycles) +``` +**Parameters** + +- `#!dae var func function` + Name of the function +- `#!dae var int delay` + Delay between calls in milliseconds (0 = every frame) +- `#!dae var int cycles` + How many times should the function be called (-1 = endless) + +### `FF_ApplyExtGT` +Adds the Daedalus function `function` to the running FrameFunctions list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. Gets called only when the game is not paused. +```dae +func void FF_ApplyExtGT(var func function, var int delay, var int cycles) +``` +**Parameters** + +- `#!dae var func function` + Name of the function +- `#!dae var int delay` + Delay between calls in milliseconds (0 = every frame) +- `#!dae var int cycles` + How many times should the function be called (-1 = endless) + +### `FF_ApplyExtData` +Adds the Daedalus function `function` to the running FrameFunctions list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. The integer parameter `data` is passed to the function `function`. +```dae +func void FF_ApplyExtData(var func function, var int delay, var int cycles, var int data) +``` +**Parameters** + +- `#!dae var func function` + Name of the function. +- `#!dae var int delay` + Delay between calls in milliseconds (0 = every frame) +- `#!dae var int cycles` + How many times should the function be called (-1 = endless) +- `#!dae var int data` + Value passed to the function as a parameter + +### `FF_ApplyExtDataGT` +Adds the Daedalus function `function` to the running FrameFunctions list. The function `function` is called every `delay` milliseconds, and it runs only `cycles` number of times. The integer parameter `data` is passed to the function `function`. Gets called only when the game is not paused. +```dae +func void FF_ApplyExtData(var func function, var int delay, var int cycles, var int data) +``` +**Parameters** + +- `#!dae var func function` + Name of the function. +- `#!dae var int delay` + Delay between calls in milliseconds (0 = every frame) +- `#!dae var int cycles` + How many times should the function be called (-1 = endless) +- `#!dae var int data` + Value passed to the function as a parameter + +### `FF_ApplyOnce` +Alias to [FF_Apply](#ff_apply), which only adds the function once, even after multiple calls. +```dae +func void FF_ApplyOnce(var func function) +``` +**Parameters** + +- `#!dae var func function` + Name of the function + +### `FF_ApplyOnceGT` +Alias to [FF_ApplyGT](#ff_applygt), which only adds the function once, even after multiple calls. Loop doesn't run if the game is paused. +```dae +func voidoften FF_ApplyOnceGT(var func function) +``` +**Parameters** + +- `#!dae var func function` + Name of the function. + +### `FF_ApplyOnceData` +Alias to [FF_ApplyData](#ff_applydata), which only adds the function with the specified parameter once, even after multiple calls. +```dae +func void FF_ApplyOnceData(var func function, var int data) +``` +**Parameters** + +- `#!dae var func function` + Name of the function. +- `#!dae var int data` + Value passed to the function as a parameter + +### `FF_ApplyOnceExt` +Alias to [FF_ApplyExt](#ff_applyext), which adds the function only once, after repeated calls. +```dae +func void FF_ApplyOnceExt(var func function, var int delay, var int cycles) +``` +**Parameters** + +- `#!dae var func function` + Name of the function +- `#!dae var int delay` + Delay between calls in milliseconds (0 = every frame) +- `#!dae var int cycles` + How many times should the function be called (-1 = endless) + +### `FF_ApplyOnceExtGT` +Alias to [FF_ApplyExtGT](#ff_applyextgt), which adds the function only once after repeated calls. Loop doesn't run if the game is paused. +```dae +func void FF_ApplyOnceExtGT(var func function, var int delay, var int cycles) +``` +**Parameters** + +- `#!dae var func function` + Name of the function +- `#!dae var int delay` + Delay between calls in milliseconds (0 = every frame) +- `#!dae var int cycles` + How many times should the function be called (-1 = endless) + +### `FF_ApplyOnceExtData` +Alias to [FF_ApplyExtData](#ff_applyextdata), which adds the function with the specified parameter only once, after repeated calls. +```dae +func void FF_ApplyOnceExtData(var func function, var int delay, var int cycles, var int data) +``` +**Parameters** + +- `#!dae var func function` + Name of the function +- `#!dae var int delay` + Delay between calls in milliseconds (0 = every frame) +- `#!dae var int cycles` + How many times should the function be called (-1 = endless) +- `#!dae var int data` + Value passed to the function as a parameter + +### `FF_Active` +Checks whether the `function` is active. +```dae +func int FF_Active(var func function) +``` +**Parameters** + +- `#!dae var func function` + Name of the function + +**Return value** +The function returns `TRUE` if the function is active, `FALSE` if it is not. + +### `FF_ActiveData` +Checks whether the `function` with the specified `data` is active. +```dae +func int FF_ActiveData(var func function, var int data) +``` +**Parameters** + +- `#!dae var func function` + Name of the function +- `#!dae var int data` + Value previously passed to the function + +**Return value** +The function returns `TRUE` if the function is active, `FALSE` if it is not. + +### `FF_Remove` +Stops a specific FrameFunction. +```dae +func void FF_Remove(var func function) +``` +**Parameters** + +- `#!dae var func function` + Name of the stopped function + +### `FF_RemoveAll` +Stops all intsnces of a specific FrameFunction. +```dae +func void FF_RemoveAll(var func function) +``` +**Parameters** + +- `#!dae var func function` + Name of the stopped function + +### `FF_RemoveData` +Stops a specific FrameFunction, with the specified value (see [`FF_ApplyExtData`](#ff_applyextdata) ). +```dae +func void FF_RemoveData(var func function, var int data) +``` +**Parameters** + +- `#!dae var func function` + Name of the stopped function +- `#!dae var int data` + Value previously passed to the function as a parameter + +## Examples + +### A function called every frame +In this example function `MyFunc` will be executed on every frame. +```dae +func void Example1() +{ + FF_Apply(MyFunc); +}; + +func void MyFunc() {}; +``` +After the `Example1` function is executed the function `MyFunc` is called on every frame. + +The easiest and best way to run a function from the beginning is to call [`FF-Apply`](#ff_apply) directly in the `Init_Global` (under `LeGo_Init`), there is a small problem: If the game is loaded, `Init_Global` is called a second time, the function is added to the list again and is therefore always called twice. + +To avoid this effect, you should check whether the function is already active: +```dae +func void Example1() +{ + if(!FF_Active(MyFunc)) + { + FF_Apply(MyFunc); + }; +}; +``` + +However, since LeGo version 2.2 there is an even more pleasant method to do this: +```dae +func void Example1() +{ + FF_ApplyOnce(MyFunc); +}; +``` +[`FF_ApplyOnce`](#ff_applyonce) function already implements the check for function activity. + +### Calling delayed function +Create a function, that is called once after 3 seconds. +```dae +func void Example2() +{ + FF_ApplyExt(MyFunc2, 3000, 1); // 3000 ms = 3 s, this function is called only once +}; + +func void MyFunc2() {}; +``` + +There is also a `Once` variant of this function, that prevents adding it twice into the frame function list. +```dae +func void Example2() +{ + FF_ApplyOnceExt(MyFunc2, 3000, 1); +}; +``` +!!! Note + `#!dae FF_ApplyExt(MyFunc, 0, -1)` is the same as `#!dae FF_Apply(MyFunc)`. + +### FrameFunction with Timer +Since LeGo 2.2, FrameFunctions package uses the Timer package, so it is possible to pause FrameFunctions at will: +```dae +func void Example3() +{ + FF_ApplyOnceExt(MyFunc3, 4000, 2); +}; + +func void MyFunc3() +{ + Timer_SetPaused(!Timer_GetPaused()); +}; +``` +This would pause the timer after 4 seconds and let it continue after 8 seconds. + +!!! Warning + Because the timer doesn't run, the frame function execution is stopped as well. **This script won't work**. If the timer is to be paused, it must be paused outside FrameFunctions. + +!!! Note + This is translation of article originally written by Gottfried and Lehona and hosted on LeGo's official documentation [website](https://lego.worldofplayers.de/?Beispiele_FrameFunctions). diff --git a/docs/zengin/scripts/extenders/lego/tools/hashtables.md b/docs/zengin/scripts/extenders/lego/tools/hashtables.md index 2a79cae442..cb1df38c68 100644 --- a/docs/zengin/scripts/extenders/lego/tools/hashtables.md +++ b/docs/zengin/scripts/extenders/lego/tools/hashtables.md @@ -1,3 +1,7 @@ +--- +title: Hashtables +description: LeGo package implementing Hashtable data structure to gothic scripts +--- # Hashtables Hashtables package is an implementation of hashtables in Gothic. Currently (version 2.8.0) only integers are supported as keys. The Hashtables grow automatically. @@ -173,3 +177,59 @@ func void HT_Destroy(var int handle) - `#!dae var int handle` The handle of the hashtable to be deleted + +## Examples + +### Simple operations +```dae +func void PrintKeyValuePair(var int key, var int val) +{ + Print(ConcatStrings(ConcatStrings("Key: ", IntToString(key)), ConcatStrings(", Value: ", IntToString(val)))); +}; + +func void exapmle() +{ + // Create a new hashtable + var int hashtableHandle; hashtableHandle = HT_Create(); + + // Insert values into the hashtable + HT_Insert(hashtableHandle, 42, 1); + HT_Insert(hashtableHandle, 23, 2); + HT_Insert(hashtableHandle, 56, 3); + + // Get a value from the hashtable + var int value; value = HT_Get(hashtableHandle, 2); + Print(ConcatStrings("Value associated with key 2: ", IntToString(value))); + + // Check if a key exists in the hashtable + if (HT_Has(hashtableHandle, 3)) + { + Print("Key 3 exists in the hashtable."); + } + else + { + Print("Key 3 does not exist in the hashtable."); + }; + + // Remove a key from the hashtable + HT_Remove(hashtableHandle, 1); + + // Change the value associated with a key + HT_Change(hashtableHandle, 99, 3); + + // Insert a value or change it if the key exists + HT_InsertOrChange(hashtableHandle, 123, 4); + + // Get the number of entries in the hashtable + var int numEntries; numEntries = HT_GetNumber(hashtableHandle); + Print(ConcatStrings("Number of entries in the hashtable: ", IntToString(numEntries))); + + + // Iterate through the hashtable and print key-value pairs + // Function from top of the example is used here + HT_ForEach(hashtableHandle, PrintKeyValuePair); + + // Destroy the hashtable + HT_Destroy(hashtableHandle); +}; +``` \ No newline at end of file diff --git a/docs/zengin/scripts/extenders/lego/tools/hook_dae.md b/docs/zengin/scripts/extenders/lego/tools/hook_dae.md index ca82323718..9d77838bb4 100644 --- a/docs/zengin/scripts/extenders/lego/tools/hook_dae.md +++ b/docs/zengin/scripts/extenders/lego/tools/hook_dae.md @@ -1,3 +1,7 @@ +--- +title: HookDaedalus +description: LeGo package for hooking daedalus script functions +--- # HookDaedalus This package allows hooking daedalus functions. The principle is similar [HookEngine](hook_engine.md). We have a function (hooked function) into which we would like to hook another function (hook function). @@ -22,6 +26,18 @@ func void HookDaedalusFunc(var func hooked, var func hook) ``` **Parameters** +- `#!dae var func hooked` + Hooked function +- `#!dae var func hook` + Hook function + +### `HookDaedalusFuncF` +Alias to the `HookDaedalusFunc` function. +```dae +func void HookDaedalusFuncF(var func hooked, var func hook) +``` +**Parameters** + - `#!dae var func hooked` Hooked function - `#!dae var func hook` diff --git a/docs/zengin/scripts/extenders/lego/tools/hook_engine.md b/docs/zengin/scripts/extenders/lego/tools/hook_engine.md index e773082597..8b102eb550 100644 --- a/docs/zengin/scripts/extenders/lego/tools/hook_engine.md +++ b/docs/zengin/scripts/extenders/lego/tools/hook_engine.md @@ -22,6 +22,20 @@ func void HookEngine(var int address, var int oldInstr, var string function) ``` **Parameters** +- `#!dae var int address` + Address of an engine function to which the function should be attached. +- `#!dae var int oldInstr` + The length in bytes of the instruction to be found at `address`, at least 5 bytes. Can be seen in IDA. +- `#!dae var string function` + Name of Daedalus function to be called. + +### `HookEngineS` +Alias to the `HookEngine` function. +```dae +func void HookEngineS(var int address, var int oldInstr, var string function) +``` +**Parameters** + - `#!dae var int address` Address of an engine function to which the function should be attached. - `#!dae var int oldInstr` @@ -226,3 +240,17 @@ Simple function to replace `return TRUE` in hook. ```dae func void Hook_ReturnTrue() ``` + +## Registers +In addition the HookEngine package implement x86 32-bit registers that can be used to access hooked function parameters. + +```dae +var int EAX; +var int ECX; +var int EDX; +var int EBX; +var int ESP; +var int EBP; +var int ESI; +var int EDI; +``` \ No newline at end of file diff --git a/docs/zengin/scripts/extenders/lego/tools/interface.md b/docs/zengin/scripts/extenders/lego/tools/interface.md index 192243f4bb..eda160bd2c 100644 --- a/docs/zengin/scripts/extenders/lego/tools/interface.md +++ b/docs/zengin/scripts/extenders/lego/tools/interface.md @@ -1,3 +1,7 @@ +--- +title: Interface +description: LeGo package for working with the 2D interface +--- # Interface This package offers a lot of useful functions to work with the 2D interface. @@ -153,7 +157,7 @@ func void Print_DeleteText(var int hndl) **Parameters** - `#!dae var int hndl` - Handle to `zCViewText` (form `Print_CreateText` or `Print_Ext`) + Handle to `zCViewText` (form [`Print_CreateText`](#print_createtext) or [`Print_Ext`](#print_ext)) ### `Print_SetAlpha` Changes the alpha value of a given `zCViewText`. @@ -217,7 +221,7 @@ func int Print_ToVirtual(var int pxl, var int dim) - `#!dae var int pxl` Pixel position to convert - `#!dae var int dim` - PS_X or PS_Y (see `Print_Screen`) + PS_X or PS_Y (see [`Print_Screen`](#print_screen)) **Return value** @@ -233,7 +237,7 @@ func int Print_ToVirtualF(var int pxl, var int dim) - `#!dae var int pxl` Pixel position to convert - `#!dae var int dim` - PS_X or PS_Y (see `Print_Screen`) + PS_X or PS_Y (see [`Print_Screen`](#print_screen)) **Return value** @@ -249,7 +253,7 @@ func int Print_ToPixel(var int vrt, var int dim) - `#!dae var int vrt` Virtual position to convert - `#!dae var int dim` - PS_X or PS_Y (see `Print_Screen`) + PS_X or PS_Y (see [`Print_Screen`](#print_screen)) **Return value** @@ -265,7 +269,7 @@ func int Print_ToPixelF(var int vrt, var int dim) - `#!dae var int vrt` Virtual position to convert - `#!dae var int dim` - PS_X or PS_Y (see `Print_Screen`) + PS_X or PS_Y (see [`Print_Screen`](#print_screen)) **Return value** @@ -281,7 +285,7 @@ func int Print_ToRatio(var int size, var int dim) - `#!dae var int size` Size to convert - `#!dae var int dim` - PS_X or PS_Y (see `Print_Screen`) + PS_X or PS_Y (see [`Print_Screen`](#print_screen)) **Return value** diff --git a/docs/zengin/scripts/extenders/lego/tools/item_helper.md b/docs/zengin/scripts/extenders/lego/tools/item_helper.md index e6c2482de7..eee957bd1d 100644 --- a/docs/zengin/scripts/extenders/lego/tools/item_helper.md +++ b/docs/zengin/scripts/extenders/lego/tools/item_helper.md @@ -16,9 +16,9 @@ N/A ## Functions -### `ITM_GetPtr` +### `Itm_GetPtr` ```dae -func int ITM_GetPtr(var int instance) +func int Itm_GetPtr(var int instance) ``` **Parameters** diff --git a/docs/zengin/scripts/extenders/lego/tools/item_helper.pl.md b/docs/zengin/scripts/extenders/lego/tools/item_helper.pl.md index f025953a4c..6e574d364c 100644 --- a/docs/zengin/scripts/extenders/lego/tools/item_helper.pl.md +++ b/docs/zengin/scripts/extenders/lego/tools/item_helper.pl.md @@ -19,9 +19,9 @@ Nie dotyczy. ## Funkcje -### `ITM_GetPtr` +### `Itm_GetPtr` ```dae -func int ITM_GetPtr(var int instance) +func int Itm_GetPtr(var int instance) ``` **Parametry** diff --git a/docs/zengin/scripts/extenders/lego/tools/list.md b/docs/zengin/scripts/extenders/lego/tools/list.md index 9f46e904b3..3809718d6b 100644 --- a/docs/zengin/scripts/extenders/lego/tools/list.md +++ b/docs/zengin/scripts/extenders/lego/tools/list.md @@ -12,7 +12,7 @@ N/A ## Functions !!! Note - All functions come with an additional "S" at the end for objects of type `zCListSort`. (Example: List_Node S .) Unlike most LeGo packages, pointers are used here, not handles! + All functions, expect `List_Compare` come with an additional "S" at the end for objects of type `zCListSort`. (Example: `List_NodeS` .) Unlike most LeGo packages, pointers are used here, not handles! ### `List_Create` Creates a list with an initial value. @@ -294,9 +294,25 @@ func void List_InsertSorted(var int list, var int data, var func compare) - `#!dae var func compare` A comparison function used to determine the sort order. +### `List_Compare` +```dae +func int List_Compare(var int data1, var int data2, var func compare) +``` +**Parameters:** + +- `#!dae var int data1` + The first integer value. +- `#!dae var int data2` + The second integer value. +- `#!dae var func compare` + One of comparsion functions. +**Return value** + +The function returns the return value of specified comparsion funtion. + ## Comparison Functions -The following comparison functions can be used as the `compare` parameter in the `List_InsertSorted` function: +The following comparison functions can be used as the `compare` parameter in the `List_InsertSorted` and `List_Compare` function: #### `List_CmpAscending` Compares two integer values in ascending order. diff --git a/docs/zengin/scripts/extenders/lego/tools/locals.md b/docs/zengin/scripts/extenders/lego/tools/locals.md index 7831ab4b1a..a3123f7727 100644 --- a/docs/zengin/scripts/extenders/lego/tools/locals.md +++ b/docs/zengin/scripts/extenders/lego/tools/locals.md @@ -27,7 +27,7 @@ It is hard to explain how to use it, but very easy to understand once you've see func int Final() ``` -??? abstract "Examples" +??? abstract "Example" With `final()` it is very easy to emulate Java's `final` clause, i.e. a block of code can be specified, which is executed after this function is exited, regardless of when or where the function is exited. ```dae func void testFinal() diff --git a/docs/zengin/scripts/extenders/lego/tools/misc.md b/docs/zengin/scripts/extenders/lego/tools/misc.md index ae0db1e2f2..c3818eafc4 100644 --- a/docs/zengin/scripts/extenders/lego/tools/misc.md +++ b/docs/zengin/scripts/extenders/lego/tools/misc.md @@ -1,143 +1,156 @@ -# Misc - -The Misc package introduces various helper functions that did not fit into any other package. - -## Dependencies -N/A - -## Initialization -N/A - -## Implementation -[:material-github: Misc.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/Misc.d) - -## Functions - -### `atan2f` -Calculates the arcus tangent of an angle between the origin and (x, y) point. -```dae -func float atan2f(var int x, var int y) -``` -**Parameters** - -- `#!dae var int x` - X-coordinate -- `#!dae var int y` - Y-coordinate - -**Return value** - -The function returns arcus tangent in radians as Ikarus `float`. - -### `sin` -Calculates the sine of an angle given in radians. -```dae -func float sin(var float angle) -``` -**Parameters** - -- `#!dae var float angle` - The angle in radians as a Ikarus `float` - -**Return value** - -The function returns sine of the angle. - -### `cos` -Calculates the cosine of an angle given in radians. -```dae -func float cos(var float angle) -``` -**Parameters** - -- `#!dae var float angle` - The angle in radians as a Ikarus `float` - -**Return value** - -The function returns cosine of the angle. - - -### `tan` -Calculates the tangent of an angle given in radians. -```dae -func float tan(var float angle) -``` -**Parameters** - -- `#!dae var float angle` - The angle in radians as a Ikarus `float` - -**Return value** - -The function returns tangent of the angle. - -### `asin` -Calculates the arcus sine -```dae -func float asin(var float sine) -``` -**Parameters** - -- `#!dae var float sine` - The sine of an angle as a Ikarus `float` - -**Return value** - -The function returns arcus sine of the angle. - -### `acos` -Calculates the arcus cosine -```dae -func float acos(var float cosine) -``` -**Parameters** - -- `#!dae var float cosine` - The cosine of an angle as a Ikarus `float` - -**Return value** - -The function returns arcus cosine of the angle. - - -### `distance2D` -Calculates the distance between two points on a two-dimensional plane. -```dae -func int distance2D(var int x1, var int x2, var int y1, var int y2) -``` -**Parameters** - -- `#!dae var int x1` - X-coordinate of the first point -- `#!dae var int x2` - X-coordinate of the second point -- `#!dae var int y1` - Y-coordinate of the first point -- `#!dae var int y2` - Y-coordinate of the second point - -**Return value** - -The function returns the distance between the two points. - -### `distance2Df` -Calculates the distance between two points on a two-dimensional plane but parameters and return values are Ikarus `floats`. -```dae -func float distance2Df(var float x1, var float x2, var float y1, var float y2) -``` -**Parameters** - -- `#!dae var float x1` - X-coordinate of the first point -- `#!dae var float x2` - X-coordinate of the second point -- `#!dae var float y1` - Y-coordinate of the first point -- `#!dae var float y2` - Y-coordinate of the second point - -**Return value** - -The function returns the distance between the two points as Ikarus `float`. - +--- +title: Misc +description: LeGo package implementing various helper functions +--- +# Misc +The Misc package introduces various helper functions that did not fit into any other package. + +## Dependencies + +- [Floats](../../ikarus/floats.md) + +## Initialization +N/A + +## Implementation +[:material-github: Misc.d on GitHub](https://github.com/Lehona/LeGo/blob/dev/Misc.d) + +## Constants +Misc package implements the `phi` constant +```dae +const int phi = 1070141312; // PI/2 +``` +whitch is actualy `pi` divided by 2 saved as an ikarus float. + +Decimal: `1.5707...` + +## Functions + +### `atan2f` +Calculates the arcus tangent of an angle between the origin and (x, y) point. +```dae +func float atan2f(var int x, var int y) +``` +**Parameters** + +- `#!dae var int x` + X-coordinate +- `#!dae var int y` + Y-coordinate + +**Return value** + +The function returns arcus tangent in radians as Ikarus `float`. + +### `sin` +Calculates the sine of an angle given in radians. +```dae +func float sin(var float angle) +``` +**Parameters** + +- `#!dae var float angle` + The angle in radians as a Ikarus `float` + +**Return value** + +The function returns sine of the angle. + +### `cos` +Calculates the cosine of an angle given in radians. +```dae +func float cos(var float angle) +``` +**Parameters** + +- `#!dae var float angle` + The angle in radians as a Ikarus `float` + +**Return value** + +The function returns cosine of the angle. + + +### `tan` +Calculates the tangent of an angle given in radians. +```dae +func float tan(var float angle) +``` +**Parameters** + +- `#!dae var float angle` + The angle in radians as a Ikarus `float` + +**Return value** + +The function returns tangent of the angle. + +### `asin` +Calculates the arcus sine +```dae +func float asin(var float sine) +``` +**Parameters** + +- `#!dae var float sine` + The sine of an angle as a Ikarus `float` + +**Return value** + +The function returns arcus sine of the angle. + +### `acos` +Calculates the arcus cosine +```dae +func float acos(var float cosine) +``` +**Parameters** + +- `#!dae var float cosine` + The cosine of an angle as a Ikarus `float` + +**Return value** + +The function returns arcus cosine of the angle. + + +### `distance2D` +Calculates the distance between two points on a two-dimensional plane. +```dae +func int distance2D(var int x1, var int x2, var int y1, var int y2) +``` +**Parameters** + +- `#!dae var int x1` + X-coordinate of the first point +- `#!dae var int x2` + X-coordinate of the second point +- `#!dae var int y1` + Y-coordinate of the first point +- `#!dae var int y2` + Y-coordinate of the second point + +**Return value** + +The function returns the distance between the two points. + +### `distance2Df` +Calculates the distance between two points on a two-dimensional plane but parameters and return values are Ikarus `floats`. +```dae +func float distance2Df(var float x1, var float x2, var float y1, var float y2) +``` +**Parameters** + +- `#!dae var float x1` + X-coordinate of the first point +- `#!dae var float x2` + X-coordinate of the second point +- `#!dae var float y1` + Y-coordinate of the first point +- `#!dae var float y2` + Y-coordinate of the second point + +**Return value** + +The function returns the distance between the two points as Ikarus `float`. + diff --git a/docs/zengin/scripts/extenders/lego/tools/misc.pl.md b/docs/zengin/scripts/extenders/lego/tools/misc.pl.md index 2483feef7b..fc270f377c 100644 --- a/docs/zengin/scripts/extenders/lego/tools/misc.pl.md +++ b/docs/zengin/scripts/extenders/lego/tools/misc.pl.md @@ -1,5 +1,6 @@ --- -title: Różne +title: Misc +description: Pakiet LeGo implementujący różne funkcje pomocnicze --- # Misc - różne Pakiet Misc wprowadza różne funkcje pomocnicze, które nie pasowały do żadnego innego pakietu. @@ -13,6 +14,16 @@ Nie dotyczy. ## Implementacja [:material-github: Misc.d na GitHubie](https://github.com/Lehona/LeGo/blob/dev/Misc.d) +## Stałe +Pakiet Misc implementuje satłą `phi` +```dae +const int phi = 1070141312; // PI/2 +``` +która w rzeczywistości jest liczbą `pi` podzieloną przez 2 zapisaną jako ikarusowy float. + +Decymalnie: `1.5707...` + + ## Funkcje ### `atan2f` diff --git a/docs/zengin/scripts/extenders/lego/tools/permmem.md b/docs/zengin/scripts/extenders/lego/tools/permmem.md index 191d81ccd8..367e0fe487 100644 --- a/docs/zengin/scripts/extenders/lego/tools/permmem.md +++ b/docs/zengin/scripts/extenders/lego/tools/permmem.md @@ -32,7 +32,7 @@ func int new(var int inst) The function returns a new, valid PermMem handle. ### `create` -Similar to `new`, but here a pointer is returned directly and not a handle. Caution! Not managed by PermMem! +Similar to [`new`](#new), but here a pointer is returned directly and not a handle. Caution! Not managed by PermMem! ```dae func int create(var int inst) ``` @@ -83,7 +83,7 @@ func void release(var int hndl) Valid PermMem handle ### `delete` -Cleans the handle just like `clear`, only the destructor is also called. +Cleans the handle just like [`clear`](#clear), only the destructor is also called. ```dae func void delete(var int hndl) ``` @@ -93,7 +93,7 @@ func void delete(var int hndl) Valid PermMem handle ### `free` -Similar to `delete`, only here a pointer is destroyed and not a handle. Caution! Not managed by PermMem! +Similar to [`delete`](#delete), only here a pointer is destroyed and not a handle. Caution! Not managed by PermMem! ```dae func void free(var int ptr, var int inst) ``` @@ -333,7 +333,7 @@ func void PM_SaveClassPtr(var string name, var int ptr, var string className) Name of the class of stored pointer ### `PM_SaveClass` -Saves a class like `PM_SaveClassPtr`. +Saves a class like [`PM_SaveClassPtr`](#pm_saveclassptr). ```dae func void PM_SaveClass(var string name, var int ptr, var string className) ``` diff --git a/docs/zengin/scripts/extenders/lego/tools/queue.md b/docs/zengin/scripts/extenders/lego/tools/queue.md index fb110aca03..819052c933 100644 --- a/docs/zengin/scripts/extenders/lego/tools/queue.md +++ b/docs/zengin/scripts/extenders/lego/tools/queue.md @@ -99,7 +99,7 @@ func void Q_ForF(var int queue, var func f) - `#!dae var int queue` Handle of a queue - `#!dae var func f` - This function is executed for all values in the queue (signature: void (zCList*)) + This function is executed for all values in the queue (signature: `void (zCList*)`) ## CallbackQueue @@ -188,5 +188,3 @@ func void CQ_Exhaust(var int queue) - `#!dae var int queue` Handle of a callback queue - -[//]: # (//TODO check if there are missing functions by Emu) diff --git a/docs/zengin/scripts/extenders/lego/tools/string_builder.md b/docs/zengin/scripts/extenders/lego/tools/string_builder.md index d9f8117be5..a4c5531b44 100644 --- a/docs/zengin/scripts/extenders/lego/tools/string_builder.md +++ b/docs/zengin/scripts/extenders/lego/tools/string_builder.md @@ -1,7 +1,11 @@ +--- +title: StringBuilder +description: LeGo package for working with the 2D interface +--- # StringBuilder The StringBuilder is a package, designed to easily concatenate multiple elements into a string (without `ConcatStrings` and `IntToString`). -All created StringBuilders are transient. All functions starting from `SB_InitBuffer`, including it, use the active StringBuilder set with `SB_New` or `SB_Use`, so there is no `#!dae var int stringBuilder` parameter in functions. A look at the example explains what I mean. +All created StringBuilders are transient. All functions starting from [`SB_InitBuffer`](#sb_initbuffer), including it, use the active StringBuilder set with [`SB_New`](#sb_new) or [`SB_Use`](#sb_use), so there is no `#!dae var int stringBuilder` parameter in functions. A look at the example explains what I mean. !!! Warning The StringBuilder works with pointers, not handles like many other LeGo packages. @@ -18,7 +22,7 @@ N/A ## Functions ### `SB_New` -Creates and returns a new `StringBuilder`. At the same time, this new `StringBuilder` is set as active. (See `SB_Use`.) +Creates and returns a new `StringBuilder`. At the same time, this new `StringBuilder` is set as active. (See [`SB_Use`](#sb_use).) ```dae func int SB_New() ``` @@ -34,7 +38,7 @@ func void SB_Use(var int sb) **Parameters** - `#!dae var int sb` - Pointer to a `StringBuilder`, returned from `SB_New` + Pointer to a `StringBuilder`, returned from [`SB_New`](#sb_new) ### `SB_Get` Returns the active `StringBuilder`. @@ -43,7 +47,7 @@ func int SB_Get() ``` **Return value** -The function returns the active `StringBuilder` object - last set with `SB_Use` or just created with `SB_New`. +The function returns the active `StringBuilder` object - last set with [`SB_Use`](#sb_use) or just created with [`SB_New`](#sb_new). ### `SB_InitBuffer` If the size of the resulting string is already known, the buffer can be set manually. This is usually not necessary. @@ -98,10 +102,10 @@ func int SB_GetStream() ``` **Return value** -The function returns the stream as it is. `SB_Destroy` or `SB_Clear` destroy the returned pointer. +The function returns the stream as it is. [`SB_Destroy`](#sb_destroy) or [`SB_Clear`](#sb_clear) destroy the returned pointer. ### `SB_Length` -Returns the current length of the stream. Similar to `STR_Len` from [Ikarus](../../ikarus/index.md) . +Returns the current length of the stream. Similar to [`STR_Len`](../../ikarus/functions/string.md#str_len) from [Ikarus](../../ikarus/index.md) . ```dae func int SB_Length() ``` @@ -171,7 +175,7 @@ func void SBflt(var float x) The appended Daedalus float value ### `SBf` -Appends an Ikarus float in text form, to the active `StringBuilder`. +Appends an [Ikarus float](../../ikarus/floats.md) in text form, to the active `StringBuilder`. ```dae func void SBf(var int x) ``` diff --git a/docs/zengin/scripts/extenders/lego/tools/talents.md b/docs/zengin/scripts/extenders/lego/tools/talents.md index b9ae1b043d..faf9e96590 100644 --- a/docs/zengin/scripts/extenders/lego/tools/talents.md +++ b/docs/zengin/scripts/extenders/lego/tools/talents.md @@ -21,11 +21,11 @@ LeGo_Init(LeGo_PermMem); ## Functions -### `NPC_GetID` +### `Npc_GetID` Returns unique ID specific for provided NPC. ```dae -func int NPC_GetID(var C_NPC slf) +func int Npc_GetID(var C_NPC slf) ``` **Parameters** @@ -36,10 +36,10 @@ func int NPC_GetID(var C_NPC slf) The function returns NPCs unique ID. -### `NPC_FindByID` +### `Npc_FindByID` Finds the NPC pointer of an NPC with the given ID. ```dae -func int NPC_FindByID(var int ID) +func int Npc_FindByID(var int ID) ``` **Parameters** @@ -73,7 +73,7 @@ func void TAL_SetValue(var C_NPC npc, var int talent, var int value) - `#!dae var int value` Value to be set -### TAL_GetValue +### `TAL_GetValue` Returns the value of a saved talent for specified NPC. ```dae func int TAL_GetValue(var C_NPC npc, var int talent) diff --git a/docs/zengin/scripts/extenders/lego/tools/talents.pl.md b/docs/zengin/scripts/extenders/lego/tools/talents.pl.md index 8c2709d027..3ca8f7d0e9 100644 --- a/docs/zengin/scripts/extenders/lego/tools/talents.pl.md +++ b/docs/zengin/scripts/extenders/lego/tools/talents.pl.md @@ -1,5 +1,5 @@ --- -title: Talenty +title: Talents --- # Talents - talenty Ten pakiet robi dwie rzeczy: