General Game Mode Setup – Arma Reforger
Lou Montana (talk | contribs) m (Text replacement - "</syntaxhighlight>" to "</enforce>") |
Pr9inichek (talk | contribs) m (miss one symbol) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
The '''SCR_BaseGameMode''' entity is the lowest usable game mode implementation that allows you to set up a custom game mode. | The '''SCR_BaseGameMode''' entity is the lowest usable game mode implementation that allows you to set up a custom game mode. | ||
The core idea behind | The core idea behind {{Link/Enfusion|armaR|SCR_BaseGameMode}} is the expansion via specialised components of {{Link/Enfusion|armaR|SCR_BaseGameModeComponent}} type. | ||
These provide the user with API that allows hooking onto certain game events as necessary. Many provided components can work standalone and can be mixed and matched. | These provide the user with API that allows hooking onto certain game events as necessary. Many provided components can work standalone and can be mixed and matched. | ||
Line 17: | Line 17: | ||
|- | |- | ||
| '''Plain''' | | '''Plain''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/MP/MpTest.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/MP/MpTest.ent}} | ||
| | | | ||
* Simplest scenario | * Simplest scenario | ||
* Automatic respawn | * Automatic respawn | ||
* Free for all | * Free for all | ||
<!-- | |||
|- | |- | ||
| '''Deathmatch''' | | '''Deathmatch''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/Deathmatch/TestGameMode_Deathmatch_Auto.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/Deathmatch/TestGameMode_Deathmatch_Auto.ent}} | ||
| | | | ||
* Scoring | * Scoring | ||
Line 31: | Line 32: | ||
|- | |- | ||
| '''Deathmatch''' | | '''Deathmatch''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/Deathmatch/TestGameMode_Deathmatch_Selection.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/Deathmatch/TestGameMode_Deathmatch_Selection.ent}} | ||
| | | | ||
* Scoring | * Scoring | ||
Line 38: | Line 39: | ||
|- | |- | ||
| '''Team Deathmatch''' | | '''Team Deathmatch''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/TeamDeathmatch/TestGameMode_TeamDeathmatch_Auto.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/TeamDeathmatch/TestGameMode_TeamDeathmatch_Auto.ent}} | ||
| | | | ||
* Scoring | * Scoring | ||
Line 45: | Line 46: | ||
|- | |- | ||
| '''Team Deathmatch''' | | '''Team Deathmatch''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/TeamDeathmatch/TestGameMode_TeamDeathmatch_Selection.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/TeamDeathmatch/TestGameMode_TeamDeathmatch_Selection.ent}} | ||
| | | | ||
* Scoring | * Scoring | ||
Line 52: | Line 53: | ||
|- | |- | ||
| '''Capture Point''' | | '''Capture Point''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/CapturePoint/TestGameMode_CapturePoint.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/CapturePoint/TestGameMode_CapturePoint.ent}} | ||
| | | | ||
* CP Scoring | * CP Scoring | ||
Line 59: | Line 60: | ||
|- | |- | ||
| '''Capture & Hold''' | | '''Capture & Hold''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/CaptureAndHold/TestGameMode_CaptureAndHold.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/CaptureAndHold/TestGameMode_CaptureAndHold.ent}} | ||
| | | | ||
* C&H Scoring | * C&H Scoring | ||
Line 66: | Line 67: | ||
|- | |- | ||
| '''Game Master''' | | '''Game Master''' | ||
| enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/GameMaster/TestGameMode_GameMaster.ent | | {{Link|enfusion://ResourceManager/~ArmaReforger:worlds/FeatureTests/GameModes/GameMaster/TestGameMode_GameMaster.ent}} | ||
| | | | ||
* Game master logic | * Game master logic | ||
--> | |||
|} | |} | ||
Line 83: | Line 85: | ||
|- | |- | ||
| '''SCR_BaseGameMode''' | | '''SCR_BaseGameMode''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/Plain/GameMode_Plain.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/Plain/GameMode_Plain.et}} | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/GameMode_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/GameMode_Base.et}} | ||
| | | Specialises game mode by using components and their combinations. Must always have a ''SCR_RespawnSystemComponent'' and specialised ''SCR_RespawnHandlerComponent'' to allow proper spawning. See {{Link|#Requirements}}. | ||
|- | |- | ||
| '''SCR_FactionManager''' | | '''SCR_FactionManager''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_FFA.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_FFA.et}} | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_Base.et}} | ||
| Provides list of available factions and their properties. For free for all modes, use the FFA faction. | | Provides list of available factions and their properties. For free for all modes, use the FFA faction. | ||
|- | |- | ||
| '''SCR_LoadoutManager''' | | '''SCR_LoadoutManager''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_FFA.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_FFA.et}} | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_Base.et}} | ||
| Provides list of available loadouts and their properties. For free for all modes, use the FFA faction. | | Provides list of available loadouts and their properties. For free for all modes, use the FFA faction. | ||
|- | |- | ||
| '''SCR_SpawnPoint''' | | '''SCR_SpawnPoint''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_FFA.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_FFA.et}} | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_Base.et}} | ||
| Provides information to the respawn system, marking a location available for spawning at. Set per faction. For free for all modes, use the FFA faction. | | Provides information to the respawn system, marking a location available for spawning at. Set per faction. For free for all modes, use the FFA faction. | ||
|} | |} | ||
Line 111: | Line 113: | ||
|- | |- | ||
| '''SCR_BaseGameMode''' | | '''SCR_BaseGameMode''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/Plain/GameMode_Plain.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/Plain/GameMode_Plain.et}} | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/GameMode_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Modes/GameMode_Base.et}} | ||
| | | Specialises game mode by using components and their combinations. Must always have a ''SCR_RespawnSystemComponent'' and specialised ''SCR_RespawnHandlerComponent'' to allow proper spawning. See {{Link|#Requirements}}. | ||
|- | |- | ||
| '''SCR_FactionManager''' | | '''SCR_FactionManager''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_USxUSSR.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_USxUSSR.et}} | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Factions/FactionManager_Base.et}} | ||
| Provides list of available factions and their properties. | | Provides list of available factions and their properties. | ||
|- | |- | ||
| '''SCR_LoadoutManager''' | | '''SCR_LoadoutManager''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_USxUSSR.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_USxUSSR.et}} | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Managers/Loadouts/LoadoutManager_Base.et}} | ||
| Provides list of available loadouts and their properties. | | Provides list of available loadouts and their properties. | ||
|- | |- | ||
| '''SCR_SpawnPoint''' | | '''SCR_SpawnPoint''' | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_USSR.et (USSR) | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_USSR.et}} (USSR) | ||
enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_US.et (US) | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_US.et}} (US) | ||
| enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_Base.et | | {{Link|enfusion://ResourceManager/~ArmaReforger:Prefabs/MP/Spawning/SpawnPoint_Base.et}} | ||
| Provides information to the respawn system, marking a location available for spawning at. Set per faction. | | Provides information to the respawn system, marking a location available for spawning at. Set per faction. | ||
|} | |} | ||
Line 135: | Line 137: | ||
== Requirements == | == Requirements == | ||
{{Feature|informative|See {{Link|Arma Reforger:Respawn Setup}} in order to setup a game mode's respawn properly.}} | |||
Line 153: | Line 147: | ||
<enforce> | <enforce> | ||
BaseGameMode baseGameMode = GetGame().GetGameMode(); | BaseGameMode baseGameMode = GetGame().GetGameMode(); | ||
SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(baseGameMode); | |||
</enforce> | </enforce> | ||
'''SCR_FactionManager''': single instance in the world - mandatory. | '''SCR_FactionManager''': single instance in the world - mandatory. | ||
Line 160: | Line 154: | ||
<enforce> | <enforce> | ||
FactionManager baseFactionManager = GetGame().GetFactionManager(); | FactionManager baseFactionManager = GetGame().GetFactionManager(); | ||
SCR_FactionManager factionManager = SCR_FactionManager.Cast( baseFactionManager ); | SCR_FactionManager factionManager = SCR_FactionManager.Cast(baseFactionManager); | ||
</enforce> | </enforce> | ||
'''SCR_LoadoutManager''' : single instance in the world - mandatory. | '''SCR_LoadoutManager''': single instance in the world - mandatory. | ||
Provides available loadouts and API for retrieving and finding these by indices. | Provides available loadouts and API for retrieving and finding these by indices. | ||
Line 181: | Line 175: | ||
<enforce> | <enforce> | ||
int myId; /* = my_local_id */ | int myId; /* = my_local_id */ | ||
RespawnComponent baseRespawnComponent = GetGame().GetPlayerManager().GetPlayerRespawnComponent( myId ); | RespawnComponent baseRespawnComponent = GetGame().GetPlayerManager().GetPlayerRespawnComponent(myId); | ||
SCR_RespawnComponent respawnComponent = SCR_RespawnComponent.Cast( baseRespawnComponent ); | SCR_RespawnComponent respawnComponent = SCR_RespawnComponent.Cast(baseRespawnComponent); | ||
// Client: if myId is local playerId, respawn component is returned. Null otherwise. (Owned PlayerController component only) | // Client: if myId is local playerId, respawn component is returned. Null otherwise. (Owned PlayerController component only) | ||
// Authority: if myId is valid playerId, respawn component is returned. Null otherwise. (Any PlayerController component) | // Authority: if myId is valid playerId, respawn component is returned. Null otherwise. (Any PlayerController component) | ||
Line 196: | Line 190: | ||
* '''POSTGAME''' (e.g. show scoreboard, next scenario voting) | * '''POSTGAME''' (e.g. show scoreboard, next scenario voting) | ||
For particular implementation and details, see | For particular implementation and details, see {{Link/Enfusion|armaR|SCR_EGameModeState}}, {{Link/Enfusion|armaR|SCR_GameModeEndData}} and <enforce inline>SCR_BaseGameMode.OnGameStateChanged()</enforce>. | ||
=== Gamemode End === | === Gamemode End === | ||
Line 202: | Line 196: | ||
The game mode transitions into POSTGAME state once the authority deems so by calling the '''EndGameMode()''' method. | The game mode transitions into POSTGAME state once the authority deems so by calling the '''EndGameMode()''' method. | ||
This method accepts an instance of | This method accepts an instance of {{Link/Enfusion|armaR|SCR_GameModeEndData}}, which is a small serialisable structure that is replicated to all clients and contains somewhat arbitrary data. | ||
This can be used to | This can be used to synchronise the end state (''winner player, winner faction, ...'') to show e.g. the end-game screen. | ||
Latest revision as of 07:23, 21 July 2024
The SCR_BaseGameMode entity is the lowest usable game mode implementation that allows you to set up a custom game mode.
The core idea behind SCR_BaseGameMode is the expansion via specialised components of SCR_BaseGameModeComponent type.
These provide the user with API that allows hooking onto certain game events as necessary. Many provided components can work standalone and can be mixed and matched.
Example Scenarios
To easily get familiar with how game modes can be set up now, please see the following scenarios:
Mode | Link | Description |
---|---|---|
Plain | MpTest.ent |
|
Basic Setup
To setup the most basic scenario the user must add the following. For the simplest set-up add all items from the "Pre-made" column.
Free for All
Type | Pre-made Prefab | Base Prefab | Description |
---|---|---|---|
SCR_BaseGameMode | GameMode_Plain.et | GameMode_Base.et | Specialises game mode by using components and their combinations. Must always have a SCR_RespawnSystemComponent and specialised SCR_RespawnHandlerComponent to allow proper spawning. See Requirements. |
SCR_FactionManager | FactionManager_FFA.et | FactionManager_Base.et | Provides list of available factions and their properties. For free for all modes, use the FFA faction. |
SCR_LoadoutManager | LoadoutManager_FFA.et | LoadoutManager_Base.et | Provides list of available loadouts and their properties. For free for all modes, use the FFA faction. |
SCR_SpawnPoint | SpawnPoint_FFA.et | SpawnPoint_Base.et | Provides information to the respawn system, marking a location available for spawning at. Set per faction. For free for all modes, use the FFA faction. |
Faction Based
Type | Pre-made Prefab | Base Prefab | Description |
---|---|---|---|
SCR_BaseGameMode | GameMode_Plain.et | GameMode_Base.et | Specialises game mode by using components and their combinations. Must always have a SCR_RespawnSystemComponent and specialised SCR_RespawnHandlerComponent to allow proper spawning. See Requirements. |
SCR_FactionManager | FactionManager_USxUSSR.et | FactionManager_Base.et | Provides list of available factions and their properties. |
SCR_LoadoutManager | LoadoutManager_USxUSSR.et | LoadoutManager_Base.et | Provides list of available loadouts and their properties. |
SCR_SpawnPoint | SpawnPoint_USSR.et (USSR)
SpawnPoint_US.et (US) |
SpawnPoint_Base.et | Provides information to the respawn system, marking a location available for spawning at. Set per faction. |
Requirements
Instances
SCR_BaseGameMode: single instance in the world - mandatory.
Ties game mode together, manages attached SCR_BaseGameModeComponent(s), calls necessary methods.
SCR_FactionManager: single instance in the world - mandatory.
Provides available factions and API for retrieving and finding these by keys or indices.
SCR_LoadoutManager: single instance in the world - mandatory.
Provides available loadouts and API for retrieving and finding these by indices.
SCR_RespawnSystemComponent: single instance in the world, attached to game mode. Mandatory.
Provides means of setting and request/response player faction, loadout and spawn points.
SCR_RespawnComponent: Not to confuse with SCR_RespawnSystemComponent!
This component is and should always be attached to a player controller. That means that remote client will always be able to retrieve their local SCR_RespawnComponent only! The authority will be able to retrieve and iterate over all SCR_RespawnComponent.
Game State
The game has three pre-defined states that can be set by the server and are automatically replicated with appropriate callback to the clients. This can be omitted, leaving the game always in GAME state.
- PREGAME (e.g. wait for n players?)
- GAME (core game loop)
- POSTGAME (e.g. show scoreboard, next scenario voting)
For particular implementation and details, see SCR_EGameModeState, SCR_GameModeEndData and SCR_BaseGameMode.OnGameStateChanged().
Gamemode End
The game mode transitions into POSTGAME state once the authority deems so by calling the EndGameMode() method.
This method accepts an instance of SCR_GameModeEndData, which is a small serialisable structure that is replicated to all clients and contains somewhat arbitrary data. This can be used to synchronise the end state (winner player, winner faction, ...) to show e.g. the end-game screen.
Troubleshooting
My game mode is not working as it was before, errors are logged into the console regarding missing game mode, what do I do?
Navigate to the Basic Setup section.
Drag prefabs from the Faction Based table if you want to have US versus USSR game mode or Free for All table if FFA is what you are looking for.