Skip to content

Commit

Permalink
Update the documentation
Browse files Browse the repository at this point in the history
& make sense of some variable names in the code (as well as the variables themself)
  • Loading branch information
LeonardoTheMutant committed Nov 13, 2024
1 parent c2a81cd commit 2fd01c4
Show file tree
Hide file tree
Showing 26 changed files with 268 additions and 218 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
## List of functions and constants

### For LTM's Murder Mystery `1.0-ALPHA`

---
# List of functions and constants for LTM's Murder Mystery `1.0-ALPHA`

This document contains the description of some important and globaly defined functions as well as constants which are used in Murder Mystery's LUA source code.

Expand All @@ -23,15 +19,14 @@ This document contains the description of some important and globaly defined fun
- Win reasons (`WIN_*`)
- Time Zones (`TIMEZONE_*`)
- Time Warp (`TWS_*`)
- [The core `MM` table](#the-core-mm-table)

# Functions
## Functions

## `INIT.LUA`

### Customisation API

There is a customization function defined in <code>MM</code> table inside the code which allows you to create your own "sub-mods" for the Murder Mystery gametype.
There is a customization function defined in the [<code>MM</code>](./MM_Userdata_Structure.md#the-core-mm-table) table inside the code which allows you to create your own "sub-mods" for the Murder Mystery gametype.

| Name | Description |
| --- | --- |
Expand Down Expand Up @@ -60,7 +55,7 @@ These are the functions that are used in [`GAME.LUA`](../LUA/MAIN//GAME.LUA) (th
| <code>**MM_StartSuspenceMusic**()</code> | *boolean* | Starts the Suspence music and returns `true` if there are no Sheriffs and no Heroes alive but one Innocent with at least one Sheriff's Emerald dropped. |
| <code>**MM_StartShowdownMusic**()</code> | *boolean* | Starts one of the Showdown Duel tunes and returns `true` if there are no Innocents in the game.|
| <code>**MM_SetRandomInnoAs**(*int* role, *int* message)</code> | nil | Similar to <code>**MM_AssignRoles()**</code> but works for only for Innocents. In some gameplay situations, there has to be a replacement of the player with some important <code>role</code> and this function selects random Innocent to give the <code>role</code> to it. Any of the `ROLE_*` constants (except `ROLE_INNOCENT`) can act as a possible value for the <code>role</code> argument.<br>Possible values for <code>Message</code>:<table><tr><th>Value</th><th>Message</th></tr><tr><td>1</td><td>*"You became a Murderer"*</td></tr><tr><td>2</td><td>*"You became a Sheriff"*</td></tr><tr><td>3</td><td>*"You became a Hero"*</td></tr><tr><td>4</td><td>*"You were rewarded the role of Hero"*</td></tr></table> |
| <code>**MM_GetMMSHREMLinterval**(*int* distance)</code> | *int* | Get the interval time in tics between each radar beep depending on the <code>dist</code> distance. Used for Innocents' Sheriff Emerald radar. |
| <code>**MM_GetMMSHREMDinterval**(*int* distance)</code> | *int* | Get the interval time in tics between each radar beep depending on the <code>dist</code> distance. Used for Innocents' Sheriff Emerald radar. |
| <code>**MM_IsTimelineCorrect**(*int* timezone1, *int* timezone2)</code> | *boolean* | Check if the events from <code>timezone1</code> can happen in <code>timezone2</code>. For example, if the event has happened in the *Past* the consequence of this event can be seen in the *Present*, *Bad Future*, and *Good Future*. But the event from the *Present*, *Bad Future*, or the *Good Future* cannot be seen in the *Past* (because it happened in the future). For easier understanding imagine a one-way road (timeline): `Past > Present > Bad/Good Future`<br>*Note:* Both of the arguments are `TIMEZONE_*` constants. |
| <code>**MM_GetText**(*string* language, *string* line, [*string*/*int* parameter])</code> | *string* | A safe way to extract the strings from the global MM Text Table (<code>MM.text</code>) without crashing/erroring LUA. When all 3 arguments are given this function returns the value at <code>MM.text[language][line][parameter]</code>. If only <code>language</code> and <code>line</code> arguments are given the function returns the value from <code>MM.text[language][line]</code>. If the text is not found or the arguments are invalid a blank string is returned instead.<br>*Note:* Even if the expected return value is table, this function will return an empty string!<br>*In Debug Builds:* If the text can not be reached or invalid arguments are given an error is triggered with the details. |
| <code>**MM_PunishPlayer**(*player_t* player, *string* message, [*boolean* ban?])</code> | *nil* | Kick player from the game or ban if <code>ban?</code> is set. <code>message</code> is the kick/ban message.<br>*Note:* If the player who is going to be punished is the host, SRB2 automatically closes for this player, causing the server to shut down. |
Expand Down Expand Up @@ -104,7 +99,7 @@ Functions that are used in more than one script
| --- | --- | --- |
| <code>**PlayerCount**([*int* role])</code> | *int* | Get the total number of players online. If the <code>role</code> is specified return the total number of players who have the <code>role</code>. |
| <code>**PlayersAlive**()</code> | *int* | Get the number of players who are still alive (aren't spectators). |
| <code>**MM_SpawnSHREML**(*int* x, *int* y, *int* z, [*int* timezone])</code> | nil | Spawn the Sheriff's Emerald at (x, y, z) position. <code>timezone</code> argument is optional and is used only go get the timezone the Emerald was spawned in. |
| <code>**MM_SpawnSHREMD**(*int* x, *int* y, *int* z, [*int* timezone])</code> | nil | Spawn the Sheriff's Emerald at (x, y, z) position. <code>timezone</code> argument is optional and is used only go get the timezone the Emerald was spawned in. |
| <code>**P_GetSectorCeilingZAt**(*sector_t* sector, *int* x, *int* y)</code> | *fixed_t* | Returns the height of the sector ceiling at (x, y), works both for regular sectors and slopes. Ported from SRB2 source code |
| <code>**P_GetFOFTopZAt**(*ffloor_t* fof, *int* x, *int* y)</code> | *fixed_t* | Returns the top height of the FOF at (x, y). Ported from SRB2 source code |
| <code>**P_GetFOFBottomZAt**(*ffloor_t* fof, *int* x, *int* y)</code> | *fixed_t* | Returns the bottom height of the FOF at (x, y). Ported from SRB2 source code |
Expand Down Expand Up @@ -183,25 +178,4 @@ The constants for the configurations flag checks. Useful only with the `mm_wepco
| `WEPCFG_REDONLY` | 1 | Only the Weapon Slot 1 is usable (Red/Infinite rings. Knife)
| `WEPCFG_DISABLERED` | 2 | Weapon Slot 1 is occupied by the Knife only |

# The core `MM` table

The description of each value in the `MM` table. The `MM` constant itself is defined in [INIT.LUA](../INIT.LUA)

| Name | Type | Description | Example value |
| --- | --- | --- | --- |
| <code>version</code> | *string* | Version number of the add-on | <code>"1.0-ALPHA"</code> |
| <code>debug</code> | *boolean* | Enable/Disable the add-on's *Debug Mode* functionality<br>*Note:* **The add-on must boot with this variable set to <code>true</code> to use the Debug in any form.** | <code>true</code> |
| <code>releasedate</code> | *string* | The release date of the add-on version. | <code>"August 19th 2024"</code> |
| <code>text</code> | *table* | Collection of all text used in **Murder Mystery** with all translations. This variable is **netsynced** | *See [the template file](../LUA/TEXT/EN.LUA)* |
| <code>RoleColor</code> | *string[5]* | The text colors for roles | *See [<code>INIT.LUA</code>](../INIT.LUA)* |
| <code>RoleColorHUD</code> | *string[5]* | The HUD text colors for roles | *See [<code>INIT.LUA</code>](../INIT.LUA)* |
| <code>hud</code> | *table* | HUD control variables for each sub-renderer (<code>MM.hud.game</code>, <code>MM.hud.scores</code>, <code>MM.hud.intermission</code>). Each sub-renderer has two attributes: <code>enabled</code> (custom scripts can disable MM's HUD renderers by setting this to <code>false</code>) and <code>pos</code> (coordinates of the different HUD elements) | *See [<code>INIT.LUA</code>](../INIT.LUA)* |
| <code>weaponconfig</code> | *int[4]* | Table to contain the Weapon Configurations. Updated by the `mm_wepconfig` CVAR. | *See [MM_WEPCONFIG.PNG](MM_WEPCONFIG.PNG) and [<code>INIT.LUA</code>](../INIT.LUA)* |
| <code>shwdwn</code> | *string* | The 6-character name of the current Showdown Duel track playing, also marks if the Duel is happening right now or not | "S2MSBS" |
| <code>winner</code> | *int* | The winner of the round, can be one of the 3 possible values: *0* - Tie, *1* - Murderer, *2* - Civilians (Sheriffs, Heros and Innocents). This variable is **netsynced** | 0 |
| <code>winreason</code> | *int* | The win reason, can be one of the <code>WIN_*</code> constants. This variable is **netsynced** | 1 |
| <code>timelimit</code> | *int* | Works just like SRB2's vanilla `timelimit` but MM uses its own. The value is measured in Minutes. This variable is **netsynced** | 5 |
| <code>shremls</code> | *mobj_t[]* | The table containing all dropped *Sheriff Emerald* objects | *See [<code>LUA/GAME.LUA</code>](../LUA/GAME.LUA)* |
| <code>pong</code> | *table* | Variables for Pong 2-player minigame. This variable is **netsynced** | *See [<code>INIT.LUA</code>](../INIT.LUA) and [<code>LUA/MINIGAMES/MINIGAMES.LUA</code>](../LUA/MINIGAMES/MINIGAMES.LUA)* |

# That's all folks!
62 changes: 62 additions & 0 deletions SRC/DEV_DOCS/MM_Userdata_Structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# MM Userdata structure for LTM's Murder Mystery `1.0-ALPHA`

This document describes the structure of the MM data

## Table of contents
- [player_t.mm](#player_tmm)
- [MT_SHREMD](#mt_shremd)
- [Global <code>MM</code> table](#the-core-mm-table)

### player_t.mm

MM userdata related to the player. In the examples below, <code>p</code> is used as the name of the <code>player_t</code> variable. **An access to the MM-related variable <code>var</code> of <code>player_t</code> is written as <code>p.mm.var</code>**.

| Name | Type | Description |
| --- | --- | --- |
| **role** | *int*, one of the <code>ROLE_*</code> constants | Specifies the player's current role in the game. See the [documentation](./MM_Func&Const_List.md#constants) for the details on the constants for this variable. |
| **kills** | *int* | The number of kills the player has made. In **PONG** 2-player minigame this variable acts as the score per-player. |
| **killername** | *string* | The name of the player who killed player <code>p</code>.<br>***Note:*** The code has a special exception for the killer player's name set as `"your stupidity"` as it sometimes is used to identify the players who died by the map hazard (crusher, pit, drowned in water, etc.). This name will be also translated on HUD. |
| **lang** | *string* | The player's currently set language. Translates all the game messages and HUD-related text into the specified language. For example, <code>p.mm.lang = "EN"</code> will set the player's language to English. |
| **weapondelay** | *tic_t* | It is very similar to the <code>p.weapondelay</code>, but this one (<code>p.mm.weapondelay</code>) is used for the MM recreation of the weapons since the vanilla variable is always set to 0 to prevent the vanilla weapons from firing. |
| **sneak** | *boolean* | This variable tells whether or not the player is currently sneaking. While sneaking, the player makes no footstep sounds and leaves no footmarks on the ground. |
| **afk** | *tic_t* | The player's AFK timer. Depending on the value of the `mm_afk` Console Variable, it is used to calculate and kick the innactive players. |
| **camping** | *tic_t* | "Camping timer" for players with the **Murderer** role. Depending on the value of the `mm_camping` Console Variable, it is used to kick players with <code>p.mm.role == ROLE_MURDERER</code> who are sitting near the dropped *Sheriff's Emerald* for longer than 30 seconds. |
| **chatdelay** | *tic_t* | The player's delay timer which controls the time interval the player must wait before sending another message. |
| **shremd_dist** | *fixed_t* | The distance to the closest dropped *Sheriff's Emerald*. It is calcualted only for the **Murderers** (for calculating <code>p.mm.camping</code>) and **Innocents**. (for Emerald Radar). |
| **hud** | *userdata table* | The table with the player's HUD related data: <table><tr><th>Name</th><th>Type</th><th>Description</th></tr><tr><td>**fx_translucency**</td><td>*int*</td><td>The translucency of the fullscreen flash/spark effect. The effect is inactive when the value is set to 0 or >=10.</td></tr><tr><td>**fx_duration**</td><td>*int*</td><td>The duration of the effect's frame. It should be noted that the formula for calculating the progression of the effect frame looks like<br><code>if (not (leveltime & p.mm.fx_duration)) then p.mm.fx_translucency = $ + 1 end</code><br> which means the <code>p.mm.fx_duration</code> can only represent the amount of frames as `(2^n) - 1`.</td></tr><tr><td>**fx_color**</td><td>*int*</td><td>The SRB2's pallet color used for the effect.</td></tr><tr><td>**roleflicker**</td><td>*tic_t*</td><td>The amount of time (in tics) the role label on HUD should flicker.</td></tr></table> |
| **timetravel** | *userdata table* | The table with the player's Time Travel related data: <table><tr><th>Name</th><th>Type</th><th>Description</th></tr><tr><td>**timezone**</td><td>*int*, one of the <code>TIMEZONE_*</code>* constants</td><td>The time zone the player is currently in. For maps that do not utilize the time travel mechanic the value of this variable will always be <code>TIMEZONE_PRESENT</code>. See [the documentation](./MM_Func&Const_List.md#constants) for the details on the constants for this variable.</td></tr><tr><td>**timesign**</td><td>*int*, one of the <code>TWS_*</code>* constants</td><td>The time warp sign (Past/Future sign) the player is currently holding. This variable is set back to <code>TWS_NONE</code> when the player succesfully warps into another time zone or has failed to keep enough speed for the warp. See [the documentation](./MM_Func&Const_List.md#constants) for the details on the constants for this variable.</td></tr><tr><td>**warptimer**</td><td>*tic_t*</td><td>The amount of time (in tics) player is in the warping state.</td></tr></table> |
| **help** | *userdata table* | The table with the player's GUI manual related data: <table><tr><th>Name</th><th>Type</th><th>Description</th></tr><tr><td>**active**</td><td>*boolean*</td><td>Tells whether or not the help manual is activated at the moment. It can be activated by the player by activating the `mmhelp` Console Command.</td></tr><tr><td>**page**</td><td>*int*</td><td>The number of the manual page the player is currently looking at.</td></tr><tr><td>**pos**</td><td>*int*</td><td>The current possition on the page.</td></tr></table> |

### <code>MT_SHREMD</code>
The userdata of the dropped Sheriff Emerald's object (<code>MT_SHREMD</code>)

| Name | Type | Description |
| --- | --- | --- |
| **x** | *fixed_t* | The Emerald's X possition |
| **y** | *fixed_t* | The Emerald's Y possition |
| **z** | *fixed_t* | The Emerald's Z possition |
| **timezone** | *int*, one of the <code>TIMEZONE_*</code> constants | The timezone the emerald is dropped in |

### The core `MM` table

The description of each value in the `MM` table. The `MM` constant itself is defined in [INIT.LUA](../INIT.LUA)

| Name | Type | Description |
| --- | --- | --- |
| <code>**version**</code> | *string* | Version number of the add-on. |
| <code>**debug**</code> | *boolean* | Enable/Disable the add-on's *Debug Mode* functionality<br>*Note:* **The add-on must boot with this variable set to <code>true</code> to use the Debug in any form.** |
| <code>**builddate**</code> | *string* | The build date of the add-on. |
| <code>**text**</code> | *table* | Collection of all text used in **Murder Mystery** with all translations. This variable is **netsynced**. See the [source code](../LUA/) for details. |
| <code>**RoleColor**</code> | *string[5]* | The vanilla text colors for roles, use one of the <code>ROLE_*</code> constants as index to get the color for the specified role. For the dead player color access <code>MM.RoleColor[5]</code>.|
| <code>**RoleColorHUD**</code> | *string[5]* | The MM text colors for roles, use one of the <code>ROLE_*</code> constants as index to get the color for the specified role. For the dead player color access <code>MM.RoleColorHUD[5]</code>. |
| <code>**hud**</code> | *table* | HUD control variables for each sub-renderer (<code>MM.hud.game</code>, <code>MM.hud.scores</code>, <code>MM.hud.intermission</code>). Each sub-renderer has two attributes: <code>**enabled**</code> (custom scripts can disable MM's HUD renderers by setting this to <code>false</code>) and <code>pos</code> (coordinates of the different HUD elements). |
| <code>**weaponconfig**</code> | *int[4]* | Table to contain the Weapon Configurations. Updated by the `mm_wepconfig` CVAR. See [MM_WEPCONFIG.PNG](MM_WEPCONFIG.PNG) and [INIT.LUA](../INIT.LUA) for details. |
| <code>**shwdwn**</code> | *string* | The 6-character name of the current Showdown Duel track playing, also marks if the Duel is happening right now or not | "S2MSBS" |
| <code>**winner**</code> | *int* | The winner of the round, can be one of the 3 possible values: *0* - Tie, *1* - Murderer, *2* - Civilians (Sheriffs, Heros and Innocents). This variable is **netsynced**. |
| <code>**winreason**</code> | *int* | The win reason, can be one of the <code>WIN_*</code> constants. This variable is **netsynced**. |
| <code>**timelimit**</code> | *int* | Works just like SRB2's vanilla `timelimit` but MM uses its own. The value is measured in Minutes. This variable is **netsynced**. |
| <code>**shremds**</code> | *mobj_t[]* | The table containing all dropped *Sheriff Emerald* objects (<code>MT_SHREMD</code>). |
| <code>**pong**</code> | *table* | Variables for Pong 2-player minigame. This variable is **netsynced**. See [INIT.LUA](../INIT.LUA) and [LUA/MINIGAMES/MINIGAMES.LUA](../LUA/MINIGAMES/MINIGAMES.LUA) for details. |
| <code>**MM.AddLang**(*string* index, *table* lang)</code> | *function* | Add a translation into MM. <code>index</code> is usually a 2 or 3 characters long name of the language. For example `"EN"` shows that the language is English. <code>table</code> is the translation data itself. The format of the <code>table</code> can be found [here](../LUA/TEXT/EN.LUA).<br>*Note:* Index should be all characters **UPPERCASE** otherwise it won't be accesible! |

# That's all folks!
8 changes: 5 additions & 3 deletions SRC/FOR_DEVELOPERS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ MM_LTMs_MurderMystery_v1.0-ALPHA.pk3
+-INIT.LUA - Init, freeslot, add-on PK3 properties, and some objects
|
+-DEV_DOCS-\
| +-List_of_Func_and_Const.md - Documentation of functions and constants
| \-MM_HUD_Library.md - Documentation of the "Murder Mystery HUD library"
| +-MM_Func&Const_List.md - Documentation of functions and constants
| +-MM_HUD_Library.md - Documentation of the "Murder Mystery HUD library"
| +-MM_Userdata_Structure.md - Documentation of the various MM userdata tables
| \-MM_WEPCONFIG.PNG - Visual explanation of the CVAR of the same name (in binary form)
|
+-LUA-\
| |
Expand All @@ -28,7 +30,7 @@ MM_LTMs_MurderMystery_v1.0-ALPHA.pk3
| | +-MINIGAME.LUA - Main logic code for "PONG" and "SONIC RUN" minigames
| |
| +-TEXT-\
| | +-EN.LUA - All Text and messages used in the add-on (English version), also a template file for other languages
| | \-EN.LUA - All Text and messages used in the add-on (English version), also a template file for other languages
| |
| +-ABILITIES.LUA - Character abilities & sneak
| +-CCMD.LUA - MMHELP and MMLANG commands
Expand Down
Loading

0 comments on commit 2fd01c4

Please sign in to comment.