List of MM Functions & Constants - LeonardoTheMutant/SRB2-Murder-Mystery GitHub Wiki
Functions which allow you to create your own "sub-mods" for the Murder Mystery gametype.
Name | Description |
---|---|
MM.AddLang(string index, table lang) |
Add a translation into MM. index is usually a 2 or 3 characters long name of the language. For example "EN" shows that the language is English. table is the translation data itself. The format of the table can be found here.Note: Index should be all characters UPPERCASE otherwise it won't be accesible! |
MM.LoadSuspenseTracks() |
(Re)loads the table of Suspense music tracks, from which the random Suspense Track will be chosen (unless the map specifies its own track). It scans for the music lumps named as MMSUS# , where # is the hexadecimal number from 0 to F.Note: This function automatically executes when a new add-on is added to SRB2. |
MM.LoadShowdownTracks() |
(Re)loads the table of Showdown Duel music tracks, from which the random Showdown Track will be chosen (unless the map specifies its own track). It scans for the music lumps named as MMSHD# , where # is the hexadecimal number from 0 to F.Note: This function automatically executes when a new add-on is added to SRB2. |
These are the functions that are used in the main game logic script:
Name | Return value | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
MM.InitPlayer(player_t player) |
nil | Initialize the player.mm table with some MM userdata for the player. |
||||||||||
MM.AssignRoles() |
nil | The main role assigner function. Called durring MapLoad hook and when another player joins the game with a single player online.Iterates through all players and gives them the role of Murderer, Sheriff or Civilian randomly. Then it tells the assigned role to each player personally. |
||||||||||
MM.GetRoleMultiplier() |
nil | Get the number of the required role duplicates. It is primarily used in MM_AssignRoles() to understand how many players should share Murderer or Sheriff roles. It is also used to adjust the map timelimit when a level starts. |
||||||||||
MM.PlayerCount([int role]) |
int | Get the total number of players online. If the role is specified return the total number of players who have the role . |
||||||||||
MM.PlayersAlive() |
int | Get the number of players who are still alive (aren't spectators). | ||||||||||
MM.SpawnSHREMD(int x, int y, int z, [int timezone]) |
nil | Spawn the Sheriff's Emerald at (x, y, z) position. timezone argument is optional and is used only to get the timezone the Emerald was spawned in. |
||||||||||
MM.ChatprintGlobal(string message_id, * var) |
nil | Works similarly to chatprint() but prints the message in player's language. Unlike chatprint() this function can print only the messages available in the multilingual MM.text table. Possible values for the arguments of this function are shown below in the Constants section (WIN_* constants). |
||||||||||
MM.TeammatesCount(player_t player) |
int | Returns the number of teammates the player has. Note: Do not use this function for Civilians as they are technically not in a team. |
||||||||||
MM.AreTeammates(player_t player1, player_t player2) |
boolean | Compares if player1 and player2 are in the same team (Murderer team, Sheriff/Hero team).Note: For Civilians this functions returns false because such team does not exist in the game. |
||||||||||
MM.KillPlayerByPlayer(mobj_t player, [mobj_t attacker]) |
nil | Kill player by making him DEAD. attacker is a player who killed the player , it is used to print the killer's name for the player . If the attacker is not specified the killer's name is "your stupidity" instead.Note: Both player and attacker arguments have to be mobj_t ! |
||||||||||
MM.KillPlayerByHazard(mobj_t player, [bool spawnBody]) |
nil | Similar to MM_KillPlayer() but is used to kill by the level hazard (crusher, death pit, drown). Set spawnBody to true to also spawn the dead body (does not spawn one by default).Note: player argument has to be mobj_t ! |
||||||||||
MM.HitTeammate(player_t victim, player_t attacker) |
nil | Make victim being hit by a teammate attacker . This function prints personal messages to both victim and attacker to let them know that they are in one team and they should not hit each other next time. |
||||||||||
MM.EndRound(int win, * var, [int winreason]) |
nil | Finish the round. w specifies the winner, possible values are: 0 - Tie, 1 - Murderers, 2 - Civilians (Sheriffs, Heros & Civilians). winreason is optional but can be one of the WIN_* constants. |
||||||||||
MM.StartSuspenseMusic() |
boolean | Starts the Suspense music and returns true if there are no Sheriffs and no Heroes alive but one Civilian with at least one Sheriff's Emerald dropped. |
||||||||||
MM.StartShowdownMusic() |
boolean | Starts one of the Showdown Duel tunes and returns true if there are no Civilians in the game. |
||||||||||
MM.StartFlashFX(player_t player, int duration, [int color]) |
nil | Initiate a fullscreen flash/spark visual effect for a specific player. Duration is the duration time of the effect's animation frame (animation has 10 frames in total). color sets the color of the effect, when this argument is not given the color will be set to white by default. |
||||||||||
MM.SetRandomInnoAs(int role, int message) |
nil | Similar to MM_AssignRoles() but works for only for Civilians. In some gameplay situations, there has to be a replacement of the player with some important role and this function selects random Civilian to give the role to it. Any of the ROLE_* constants (except ROLE_CIVILIAN ) can act as a possible value for the role argument.Possible values for Message :
|
||||||||||
MM.GetMMSHREMDinterval(int distance) |
int | Get the interval time in tics between each radar beep depending on the dist distance. Used for Civilians' Sheriff Emerald radar. |
||||||||||
MM_IsTimelineCorrect(int timezone1, int timezone2) |
boolean | Check if the events from timezone1 can happen in timezone2 . 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 Note: Both of the arguments are TIMEZONE_* constants. |
||||||||||
MM.GetText(string language, string line, [string/int parameter]) |
string | A safe way to extract the strings from the global MM Text Table (MM.text ) without crashing/erroring LUA. When all 3 arguments are given this function returns the value at MM.text[language][line][parameter] . If only language and line arguments are given the function returns the value from MM.text[language][line] . If the text is not found or the arguments are invalid a blank string is returned instead.Note: Even if the expected return value is table, this function will return an empty string! In Debug Builds: If the text can not be reached or invalid arguments are given an error is triggered with the details. |
||||||||||
MM.PunishPlayer(player_t player, string message, [boolean ban?]) |
nil | Kick player from the game or ban if ban? is set. message is the kick/ban message.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. |
||||||||||
MM_GetWepCfgFlags(int role) |
int | Returns the Weapon Configuration Flags for the given role. This function usually returns the lower 2 bits of the 4-bit configuration value, however, when the Showdown Duel is active the higher 2 bits are returned. This function always returns 0 for ROLE_CIVILIAN because this role has different weapon configuration values. |
Functions for HUD rendering code
See the list of HUD Library functions
Functions of global visibility for Pong 2-player Minigame
Name | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
PONG_SetVelocity(int side) |
Set the Pong Ball's velocity. side determines the ball's direction, accepted values are:
|
||||||||
PONG_Reset() |
Reset the PONG minigame |
Name | Return value | Description |
---|---|---|
P_GetSectorCeilingZAt(sector_t sector, int x, int y) |
fixed_t | Returns the height of the sector ceiling at (x, y), works both for regular sectors and slopes. Ported from SRB2 source code |
P_GetFOFTopZAt(ffloor_t fof, int x, int y) |
fixed_t | Returns the top height of the FOF at (x, y). Ported from SRB2 source code |
P_GetFOFBottomZAt(ffloor_t fof, int x, int y) |
fixed_t | Returns the bottom height of the FOF at (x, y). Ported from SRB2 source code |
isExtendedASCII(string str) |
boolean | Returns true if the str contains a symbol from Extended ASCII Range (0x80 - 0xFF ) |
isStandartASCII(string str) |
boolean | Returns true if all characters in str are from Standart (Printable) ASCII range (0x20 - 0x7F ). |
valid(* arg) |
boolean | Simply checks if both arg and arg.valid are true. |
SOC_IsTrue(* arg) |
boolean | Returns true if the arg says so ("true" as string will return true ). Useful only for boolean-based SOC arguments. |
Here is the list of MM constants:
Constant | Value | Role |
---|---|---|
ROLE_NONE |
0 | No role |
ROLE_MURDERER |
1 | Murderer |
ROLE_SHERIFF |
2 | Sheriff |
ROLE_CIVILIAN |
3 | Civilian |
ROLE_HERO |
4 | Hero |
Possible messages for MM_ChatprintGlobal()
message_id |
Possible value(s) for var
|
Description |
---|---|---|
"MURD_KILLED" , "SHERI_KILLED" , "HERO_KILLED"
|
string | "Murderer/Sheriff/Hero by the name of var is killed!". For "SHERI_KILLED" it just says that the Sheriff is killed |
"SHERI_KILLED_DROP" |
string | Same as "SHERI_KILLED" but also tells that the Sheriff's Emerald is dropped |
"MURD_DIED" , "SHERI_DIED" , "HERO_DIED"
|
string | "Murderer/Sheriff/Hero by the name of var has died in an accident (drown, crushed, fell into the pit)!". For "SHERI_KILLED" it just says that the Sheriff has died |
"SHERI_DIED_DROP" |
string | Same as "SHERI_DIED" but also tells that the Sheriff's Emerald is dropped |
"LAST_QUIT" |
One of the ROLE_* constants (except ROLE_CIVILIAN ) |
"The last player with var role has left the game!" |
"ONE_QUIT" |
One of the ROLE_* constants (except ROLE_CIVILIAN ) |
"One of the players with var role has left the game!" |
"REPLACE_QUIT" |
One of the ROLE_* constants (except ROLE_CIVILIAN ) |
"Player with the var role left the game! Some random Civilian will take his role!" |
"INNO_HURT" |
1 or 2 | "Civilian is hurt" global notice. The context of the message is different depending on who hit the Civilian: 1 - Sheriff, 2 - Hero. |
"WIN" |
One of the WIN_* constants |
The end round message. var is the reason of the round end. |
Win reasons for MM_EndRound("WIN")
and MM_ChatprintGlobal("WIN")
functions
Constant | Value | Description |
---|---|---|
WIN_MURD |
1 | Murderers killed everyone |
WIN_CIVILS |
2 | Sheriffs & Heroes eliminated all Murderers |
WIN_SHERIKILLINNO |
3 | Sheriff killed the last Civilian |
WIN_HEROKILLINNO |
4 | Hero killed the last Civilian |
WIN_NODEFENDERS |
5 | All Sheriffs and Heros are dead |
Time Zone constants tell in what timezone the player (or an object) is existing right now
Constant | Value | Description |
---|---|---|
TIMEZONE_PAST |
1 | Past |
TIMEZONE_PRESENT |
2 | Present |
TIMEZONE_FUTURE_BAD |
3 | Bad Future |
TIMEZONE_FUTURE_GOOD |
4 | Good Future |
These constants describe in which direction in the timeline player will warp
Constant | Value | Description |
---|---|---|
TWS_NONE |
0 | Warp is not set |
TWS_PAST |
1 | Warping to Past |
TWS_FUTURE |
2 | warping to Future |
The constants for the configurations flag checks
Constant | Value | Description |
---|---|---|
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 |