141 #define GAME_MODE_DEBUG
144 #ifdef GAME_MODE_DEBUG
145 static bool s_DebugRegistered =
false;
148 const static string WB_GAME_MODE_CATEGORY =
"Game Mode";
154 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerId>
m_OnPlayerAuditSuccess =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerId>();
155 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerId>
m_OnPlayerAuditFail =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerId>();
156 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerId>
m_OnPlayerAuditTimeouted =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerId>();
157 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerId>
m_OnPlayerAuditRevived =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerId>();
158 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerId>
m_OnPlayerConnected =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerId>();
159 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerId>
m_OnPlayerRegistered =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerId>();
160 protected ref ScriptInvokerBase<SCR_BaseGameMode_OnPlayerDisconnected>
m_OnPlayerDisconnected =
new ScriptInvokerBase<SCR_BaseGameMode_OnPlayerDisconnected>();
161 protected ref ScriptInvokerBase<SCR_BaseGameMode_OnPlayerDisconnected>
m_OnPostCompPlayerDisconnected =
new ScriptInvokerBase<SCR_BaseGameMode_OnPlayerDisconnected>();
162 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerIdAndEntity>
m_OnPlayerSpawned =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerIdAndEntity>();
163 protected ref ScriptInvokerBase<SCR_BaseGameMode_OnControllableDestroyed>
m_OnPlayerKilled =
new ScriptInvokerBase<SCR_BaseGameMode_OnControllableDestroyed>();
164 protected ref ScriptInvokerBase<SCR_BaseGameMode_OnControllableDestroyed>
m_OnControllableDestroyed =
new ScriptInvokerBase<SCR_BaseGameMode_OnControllableDestroyed>();
165 protected ref ScriptInvokerBase<SCR_BaseGameMode_PlayerIdAndEntity>
m_OnPlayerDeleted =
new ScriptInvokerBase<SCR_BaseGameMode_PlayerIdAndEntity>();
166 protected ref ScriptInvokerBase<SCR_BaseGameMode_OnPlayerRoleChanged>
m_OnPlayerRoleChange =
new ScriptInvokerBase<SCR_BaseGameMode_OnPlayerRoleChanged>();
181 [
Attribute(
"0", uiwidget:
UIWidgets.Flags,
"Test Game Flags for when you run mission via WE.",
"", ParamEnumArray.FromEnum(
EGameFlags), WB_GAME_MODE_CATEGORY)]
184 [
Attribute(
"1", uiwidget:
UIWidgets.CheckBox,
"When false, then Game mode need to handle its very own spawning. If true, then simple default logic is used to spawn and respawn automatically.",
category: WB_GAME_MODE_CATEGORY)]
187 [
Attribute(
"1", uiwidget:
UIWidgets.CheckBox,
"When true, allows players to freely swap their faction after initial assignment.",
category: WB_GAME_MODE_CATEGORY)]
190 [
Attribute(
"30",
UIWidgets.Slider,
params:
"-1 600 1",
desc:
"Time in seconds after which the mission is reloaded upon completion or -1 to disable it.",
category: WB_GAME_MODE_CATEGORY)]
191 private float m_fAutoReloadTime;
199 [
RplProp(onRplName:
"OnGameStateChanged")]
206 [
Attribute(
"1", uiwidget:
UIWidgets.CheckBox,
"If checked the elapsed time will only advance if at least one player is present on the server.",
category: WB_GAME_MODE_CATEGORY)]
256 [
Attribute(
"0",
desc:
"Is the autotune radio feature enabled in this gamemode")]
282 return disabledResourceTypes.Count();
295 if ((
index < 0) == enable)
312 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_ATTRIBUTES_ENABLE_GLOBAL_SUPPLY_USAGE, playerID);
314 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_ATTRIBUTES_DISABLE_GLOBAL_SUPPLY_USAGE, playerID);
391 return stateComponent.GetDuration();
442 component.OnGameModeEnd(m_pGameEndData);
450 component.OnGameModeStart();
458 component.OnGameStateChanged(newState);
506 Print(
"Trying to start a gamemode that is already running.",
LogLevel.WARNING);
512 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_SINGLEPLAYER_DISABLE_TIME_PAUSE,
"",
"Disable time pause",
"Game");
558 Print(
"Trying to end a gamemode that is not running.",
LogLevel.WARNING);
565 m_pGameEndData = endData;
582 return m_pGameEndData;
679 if (IsGameModeStatisticsEnabled())
681 if (!SCR_GameModeStatistics.IsRecording())
682 SCR_GameModeStatistics.StartRecording();
705 if (IsGameModeStatisticsEnabled())
707 if (SCR_GameModeStatistics.IsRecording())
708 SCR_GameModeStatistics.StopRecording();
716 else if (reloadTime == 0)
729 GetGame().GetSaveGameManager().SetSavingAllowed(
false);
732 if (
System.IsCLIParam(
"keepSessionSave") || (persistence && persistence.ShouldKeepSessionData()))
744 const SaveGame currentSave =
GetGame().GetSaveGameManager().GetActiveSave();
746 GetGame().GetSaveGameManager().Purge(currentSave.GetMissionResource(), currentSave.GetPlaythroughNumber());
765 string autoReloadTimeString;
766 if (
System.GetCLIParam(
"autoreload", autoReloadTimeString))
769 if (!autoReloadTimeString.IsEmpty() && autoReloadTimeString !=
"disabled")
770 val =
Math.Clamp(autoReloadTimeString.ToFloat(), -1, 600);
775 return m_fAutoReloadTime;
801 if (
System.GetCLIParam(
"autoshutdown", outValue))
816 backendApi.NewSession();
850 comp.OnPlayerAuditSuccess(iPlayerID);
862 comp.OnPlayerAuditFail(iPlayerID);
869 super.OnPlayerAuditTimeouted(iPlayerID);
875 comp.OnPlayerAuditTimeouted(iPlayerID);
882 super.OnPlayerAuditRevived(iPlayerID);
888 comp.OnPlayerAuditRevived(iPlayerID);
909 comp.OnPlayerConnected(playerId);
925 comp.OnPlayerDisconnected(playerId, cause, timeout);
931 IEntity character =
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId);
935 const CompartmentAccessComponent compAccess = CompartmentAccessComponent.Cast(character.
FindComponent(CompartmentAccessComponent));
939 if (pilotCompartment)
945 carController.Shutdown();
946 carController.StopEngine(
false);
947 carController.SetPersistentHandBrake(
true);
954 heliController.LockPilotControls(
false);
955 heliController.SetPersistentWheelBrake(
true);
956 heliController.SetAutohoverEnabled(
true);
969 CharacterControllerComponent charController = CharacterControllerComponent.Cast(character.
FindComponent(CharacterControllerComponent));
971 charController.SetMovement(0,
vector.Forward);
983 RplComponent.DeleteRplEntity(character,
false);
1004 comp.OnPlayerRegistered(playerId);
1008 if (IsGameModeStatisticsEnabled())
1009 SCR_GameModeStatistics.RecordConnection(playerId,
GetGame().GetPlayerManager().GetPlayerName(playerId));
1020 if (!
System.GetCLIParam(
"config", configPath) || configPath.IsEmpty())
1032 if (!comp.HandlePlayerKilled(playerId, playerEntity, killerEntity, killer))
1048 int victimPlayerId = instigatorContext.GetVictimPlayerID();
1049 if (victimPlayerId < 1)
1052 string incidentType;
1058 incidentType =
" ENEMY";
1063 incidentType =
" TK";
1067 incidentType =
" GM";
1077 int killerPlayerId = instigatorContext.GetKillerPlayerID();
1078 string killerIdentity;
1079 if (killerPlayerId < 1)
1080 killerIdentity =
" was killed by AI";
1081 else if (victimPlayerId == killerPlayerId)
1082 killerIdentity =
" killed himself!";
1086 SCR_ChimeraCharacter victim = SCR_ChimeraCharacter.Cast(instigatorContext.GetVictimEntity());
1088 string victimPosition;
1089 string causeOfDeath;
1092 Faction faction = victim.GetFaction();
1094 victimIdentity +=
" from " + faction.GetFactionKey() +
" faction";
1096 corpsePosition = victim.GetOrigin();
1097 victimPosition =
" at " + corpsePosition.ToString();
1102 array<ref BaseDamageEffect> damageHistory = {};
1103 dmgMgr.GetDamageHistory(damageHistory);
1107 HitZone defaultHitZone = dmgMgr.GetDefaultHitZone();
1108 for (
int i = damageHistory.Count() - 1; i >= 0; i--)
1110 effect = damageHistory[i];
1117 dmgType = effect.GetDamageType();
1124 if (dmgType ==
EDamageType.BLEEDING && effect.GetTotalDamage() < 1)
1130 if (effect.GetInstigator().GetInstigatorPlayerID() != killerPlayerId)
1136 hitZone = effect.GetAffectedHitZone();
1137 if (hitZone && hitZone != defaultHitZone && hitZone.GetName() !=
"Resilience")
1145 causeOfDeath =
" With last inflicted damage type " +
typename.EnumToString(
EDamageType, dmgType);
1147 causeOfDeath +=
" to the '" + hitZone.GetName() +
"' hit zone";
1154 string messageType =
"INFO";
1155 string killerPosition;
1156 string victimDisguiseState;
1159 SCR_ChimeraCharacter killer = SCR_ChimeraCharacter.Cast(instigatorContext.GetKillerEntity());
1162 Faction faction = killer.GetFaction();
1164 killerIdentity +=
" from " + faction.GetFactionKey() +
" faction";
1166 vector pos = killer.GetOrigin();
1167 killerPosition =
string.Format(
" who was at that time at %1 [%2m away from the corpse].", pos.ToString(),
vector.Distance(pos, corpsePosition).ToString(lenDec: 1));
1169 if (killerPlayerId > 0)
1172 param.Start = pos +
vector.Up * 0.1;
1173 param.End = param.Start +
vector.Up * (-1);
1175 param.Exclude = killer;
1177 float traceDistance = killer.GetWorld().TraceMove(param,
FilterCallback);
1178 if (traceDistance >= 1 && param.TraceEnt == null)
1181 killerPosition +=
" No surface found within 1m under that position!";
1182 messageType =
"WARNING";
1186 else if (killerPlayerId > 0)
1190 killerIdentity +=
" from " + faction.GetFactionKey() +
" faction";
1194 victimDisguiseState =
" while being disguised as enemy";
1197 PrintFormat(
"%1: KILL%2: %3%4%5%6%7%8", messageType, incidentType, victimIdentity, victimPosition, victimDisguiseState, killerIdentity, killerPosition, causeOfDeath, level: logLevel);
1222 super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
1239 comp.OnPlayerKilled(instigatorContextData);
1243 if (IsGameModeStatisticsEnabled())
1244 SCR_GameModeStatistics.RecordDeath(playerId, playerEntity, killerEntity, killer);
1261 comp.OnPlayerKilledHandled(playerId, playerEntity, killerEntity, killer);
1278 comp.OnPlayerDeleted(playerId, player);
1295 comp.OnPlayerRoleChange(playerId, roleFlags);
1310 comp.OnWorldPostProcess(world);
1321 super.OnControllableSpawned(entity);
1326 comp.OnControllableSpawned(entity);
1339 super.OnControllableDestroyed(entity, killerEntity, instigator);
1356 comp.OnControllableDestroyed(instigatorContextData);
1379 super.OnControllableDeleted(entity);
1384 comp.OnControllableDeleted(entity);
1388 const int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(entity);
1404 component.OnSpawnPlayerEntityFailure_S(requestComponent, handlerComponent, entity,
data,
reason);
1438 if (!component.PreparePlayerEntity_S(requestComponent, handlerComponent,
data, entity))
1466 component.OnPlayerSpawnFinalize_S(requestComponent, handlerComponent,
data, entity);
1498 SCR_ResourceComponent resourceComp;
1500 int spawnSupplyCost = 0;
1502 spawnSupplyCost = SCR_ArsenalManagerComponent.GetLoadoutCalculatedSupplyCost(loadoutComp.
GetLoadout(),
false, playerID, null, spawnPoint,
base, resourceComp);
1504 if (spawnSupplyCost > 0)
1507 base.AddSupplies(spawnSupplyCost * -1);
1508 else if (resourceComp)
1520 if (!SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled())
1523 SCR_ArsenalManagerComponent arsenalManager;
1524 if (!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
1527 int spawnCost = arsenalManager.GetLoadoutMilitarySupplyAllocationCost(loadoutComponent.
GetLoadout(), requestComponent.GetPlayerId());
1532 if (!playerController)
1535 SCR_PlayerSupplyAllocationComponent playerSupplyAllocationComponent = SCR_PlayerSupplyAllocationComponent.Cast(playerController.FindComponent(SCR_PlayerSupplyAllocationComponent));
1536 if (!playerSupplyAllocationComponent)
1539 playerSupplyAllocationComponent.AddPlayerAvailableAllocatedSupplies(-1 * spawnCost);
1574 int playerId = requestComponent.GetPlayerId();
1579 float spawnPointTime = 0;
1595 if (!spawnPointData)
1600 SCR_ResourceComponent resourceComp;
1602 int spawnSupplyCost = 0;
1606 spawnSupplyCost = SCR_ArsenalManagerComponent.GetLoadoutCalculatedSupplyCost(loadoutComp.
GetLoadout(),
false, requestComponent.GetPlayerId(), null, spawnPointData.
GetSpawnPoint(),
base, resourceComp);
1611 if (
base.GetSupplies() < spawnSupplyCost)
1617 else if (resourceComp)
1620 float availableSupplies;
1623 if (availableSupplies < spawnSupplyCost)
1631 if (SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled())
1634 PlayerController playerController = requestComponent.GetPlayerController();
1635 SCR_ArsenalManagerComponent arsenalManager;
1638 if (arsenalLoadout && playerController && SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
1640 SCR_PlayerSupplyAllocationComponent playerSupplyAllocationComponent = SCR_PlayerSupplyAllocationComponent.Cast(playerController.FindComponent(SCR_PlayerSupplyAllocationComponent));
1641 if (playerSupplyAllocationComponent && !playerSupplyAllocationComponent.HasPlayerEnoughAvailableAllocatedSupplies(arsenalManager.GetLoadoutMilitarySupplyAllocationCost(arsenalLoadout, playerController.GetPlayerId())))
1643 result =
SCR_ESpawnResult.NOT_ALLOWED_NOT_ENOUGH_AVAILABLE_ALLOCATED_SUPPLIES;
1668 writer.WriteIntRange(gameFlags, 0, (
EGameFlags.Last<<1) - 1);
1677 reader.ReadIntRange(gameFlags, 0, (
EGameFlags.Last<<1) - 1);
1679 GetGame().SetGameFlags(gameFlags,
true);
1684 #ifdef GAME_MODE_DEBUG
1688 void Diag_DrawPlayersWindow()
1691 array<int> connectedPlayers = {};
1692 GetGame().GetPlayerManager().GetPlayers(connectedPlayers);
1694 array<int> disconnectedPlayers = {};
1695 GetGame().GetPlayerManager().GetDisconnectedPlayers(disconnectedPlayers);
1697 DbgUI.Begin(
"SCR_BaseGameMode: Connected players");
1699 for (
int i = 0, cnt = connectedPlayers.Count(); i < cnt; i++)
1701 int playerId = connectedPlayers[i];
1702 Diag_DrawPlayerInfo(playerId);
1706 DbgUI.Begin(
"SCR_BaseGameMode: Disconnected players");
1708 for (
int i = 0, cnt = disconnectedPlayers.Count(); i < cnt; i++)
1710 int playerId = disconnectedPlayers[i];
1711 Diag_DrawPlayerInfo(playerId);
1720 void Diag_DrawPlayerInfo(
int playerId)
1722 string tmp =
string.Format(
"Player %1: (name: %2)", playerId,
GetGame().GetPlayerManager().GetPlayerName(playerId));
1723 array<string> extra = {};
1729 string factionKey =
"None";
1730 Faction faction = factionManager.GetPlayerFaction(playerId);
1733 factionKey = faction.GetFactionKey();
1736 extra.Insert(
string.Format(
"Faction: %1", factionKey));
1743 string loadoutKey =
"None";
1744 SCR_BasePlayerLoadout
loadout = loadoutManager.GetPlayerLoadout(playerId);
1747 loadoutKey =
loadout.GetLoadoutName();
1750 extra.Insert(
string.Format(
"Loadout: %1", loadoutKey));
1754 if (!extra.IsEmpty())
1756 const string separator =
"\n ";
1757 for (
int i = 0, count = extra.Count(); i < count; i++)
1759 tmp +=
string.Format(
"%1%2", separator, extra[i]);
1768 void Diag_DrawControlledEntitiesWindow()
1770 array<int> allPlayers = {};
1771 GetGame().GetPlayerManager().GetAllPlayers(allPlayers);
1773 DbgUI.Begin(
"SCR_BaseGameMode: Controlled Entities");
1775 for (
int i = 0, cnt = allPlayers.Count(); i < cnt; i++)
1777 int playerId = allPlayers[i];
1778 Diag_DrawControlledEntityInfo(playerId);
1787 void Diag_DrawControlledEntityInfo(
int playerId)
1789 string tmp =
string.Format(
"Player %1: (name: %2)", playerId,
GetGame().GetPlayerManager().GetPlayerName(playerId));
1790 array<string> extra = {};
1793 if (
GetGame().GetPlayerManager().IsPlayerConnected(playerId))
1795 extra.Insert(
"IsConnected: True");
1798 extra.Insert(
"IsConnected: False");
1801 IEntity controlledEntity =
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId);
1802 if (controlledEntity)
1804 extra.Insert(
string.Format(
"Entity: %1", controlledEntity));
1806 RplComponent rplComponent = RplComponent.Cast(controlledEntity.
FindComponent(RplComponent));
1809 extra.Insert(
string.Format(
"RplId: %1", rplComponent.Id()));
1814 extra.Insert(
"Entity: None");
1819 if (!extra.IsEmpty())
1821 const string separator =
"\n ";
1822 for (
int i = 0, count = extra.Count(); i < count; i++)
1824 tmp +=
string.Format(
"%1%2", separator, extra[i]);
1833 void Diag_DrawComponentsWindow()
1835 DbgUI.Begin(
"SCR_BaseGameMode: Components");
1838 DbgUI.Text(
string.Format(
"NumComponents: %1", numComponents));
1840 for (
int i = 0; i < numComponents; i++)
1852 DbgUI.Text(
string.Format(
"%1: %2",
index, component));
1857 void Diag_DrawGameModeWindow()
1859 DbgUI.Begin(
"SCR_BaseGameMode");
1861 string elapsedTime =
string.Format(
"Elapsed time: %1 s",
GetElapsedTime());
1862 DbgUI.Text(elapsedTime);
1864 string running =
string.Format(
"IsRunning: %1",
IsRunning());
1865 DbgUI.Text(running);
1870 string flags =
string.Format(
"TestFlags: %1 (%2)", SCR_Enum.FlagsToString(
EGameFlags, m_eGameState), m_eGameState);
1876 DbgUI.Text(
"Authority details:");
1879 if (autoReloadDelay > 0)
1881 DbgUI.Text(
string.Format(
"Auto reload: %1 seconds.", autoReloadDelay));
1885 DbgUI.Text(
"Auto reload: Disabled.");
1890 if (DbgUI.Button(
"End Session"))
1893 if (DbgUI.Button(
"Restart Session"))
1910 PlayerController playerController =
GetGame().GetPlayerController();
1911 if (playerController)
1913 IEntity controlledEntity = playerController.GetControlledEntity();
1914 if (controlledEntity)
1919 CharacterControllerComponent controller = character.GetCharacterController();
1922 bool doDisable = !enabled;
1923 controller.SetDisableWeaponControls(doDisable);
1924 controller.SetDisableMovementControls(doDisable);
1932 private float m_fLastRecordTime;
1934 private float m_fLastFlushTime;
1935 private float m_fFlushRecordInterval = 10000;
1938 private void UpdateStatistics(
IEntity owner)
1941 float timeStamp = owner.
GetWorld().GetWorldTime();
1942 if (timeStamp > m_fLastRecordTime + SCR_GameModeStatistics.RECORD_INTERVAL_MS)
1944 m_fLastRecordTime = timeStamp;
1948 array<int> players = {};
1949 pm.GetPlayers(players);
1951 foreach (
int pid : players)
1953 IEntity ctrlEnt = pm.GetPlayerControlledEntity(pid);
1957 SCR_GameModeStatistics.RecordMovement(ctrlEnt, pid);
1961 auto aiWorld = SCR_AIWorld.Cast(
GetGame().GetAIWorld());
1964 array<AIAgent> aiAgents = {};
1965 aiWorld.GetAIAgents(aiAgents);
1966 foreach (AIAgent agent : aiAgents)
1968 SCR_GameModeStatistics.RecordAILOD(agent);
1975 if (timeStamp > m_fLastFlushTime + m_fFlushRecordInterval)
1977 m_fLastFlushTime = timeStamp;
1978 if (IsGameModeStatisticsEnabled())
1980 if (SCR_GameModeStatistics.IsRecording())
1981 SCR_GameModeStatistics.Flush();
2002 return stateComponent.GetAllowControls();
2011 SCR_BaseGameModeStateComponent stateComponent;
2013 return stateComponent;
2077 if (IsGameModeStatisticsEnabled())
2078 UpdateStatistics(owner);
2089 if (isRunning || isPregame)
2091 bool canAdvanceTime =
true;
2099 int playerCount =
GetGame().GetPlayerManager().GetPlayerCount();
2100 if (playerCount == 0)
2101 canAdvanceTime =
false;
2120 if (isPregame && (!pregameComponent || pregameComponent.CanAdvanceState(
SCR_EGameModeState.GAME)))
2157 #ifdef GAME_MODE_DEBUG
2160 Diag_DrawGameModeWindow();
2161 Diag_DrawComponentsWindow();
2162 Diag_DrawPlayersWindow();
2163 Diag_DrawControlledEntitiesWindow();
2184 set<EResourceType> duplicateRemoveSet =
new set<EResourceType>();
2188 duplicateRemoveSet.Insert(resourceType);
2206 Print(
"SCR_BaseGameMode is missing RplComponent!",
LogLevel.ERROR);
2208 Print(
"SCR_BaseGameMode is missing SCR_RespawnSystemComponent!",
LogLevel.WARNING);
2213 array<Managed> additionalComponents =
new array<Managed>();
2217 for (
int i = 0; i < count; i++)
2224 array<Managed> stateComponents =
new array<Managed>();
2225 int stateCount = owner.
FindComponents(SCR_BaseGameModeStateComponent, stateComponents);
2226 for (
int i = 0; i < stateCount; i++)
2228 SCR_BaseGameModeStateComponent stateComponent = SCR_BaseGameModeStateComponent.Cast(stateComponents[i]);
2233 Print(
"Skipping one of SCR_BaseGameStateComponent(s), invalid affiliated state!",
LogLevel.ERROR);
2240 Print(
"Skipping one of SCR_BaseGameStateComponent(s), duplicate component for state: " + stateName +
"!",
LogLevel.ERROR);
2294 #ifdef GAME_MODE_DEBUG
2295 if (!s_DebugRegistered)
2300 s_DebugRegistered =
true;
2312 #ifdef GAME_MODE_DEBUG
2314 s_DebugRegistered =
false;
2318 if (SCR_GameModeStatistics.IsRecording())
2319 SCR_GameModeStatistics.StopRecording();
2326 private bool IsGameModeStatisticsEnabled()
2332 return GetGame().InPlayMode();
SCR_EAIThreatSectorFlags flags
ArmaReforgerScripted GetGame()
bool AreGameFlagsObtained()
EGameFlags
GameMode Game Flags represented by bit mask.
RplMode
Mode of replication.
func SCR_BaseGameMode_OnPlayerRoleChanged
func SCR_BaseGameMode_OnPlayerDisconnected
ScriptInvokerBase< OnPreloadFinished > OnPreloadFinishedInvoker
func SCR_BaseGameMode_PlayerId
func SCR_BaseGameMode_PlayerIdAndEntity
func SCR_BaseGameMode_OnControllableDestroyed
func SCR_BaseGameMode_OnResourceEnabledChanged
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
RplComponent m_RplComponent
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_ECharacterControlType
What kind of controller the character or (in some cases vehicle) has, eg: AI, Player,...
SCR_ECharacterDeathStatusRelations
SCR_ECharacterDisguiseType
Get all prefabs that have the spawner data
Get all prefabs that have the spawner the given labels and are valid in the editor mode param catalogType Type to catalog to get prefabs from param editorMode Editor mode to get valid entries from param faction Faction(Optional)
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SCR_RespawnTimerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
enum EVehicleType IEntity
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
proto external int FindComponents(typename typeName, notnull array< Managed > outComponents)
proto external IEntity GetParent()
Replication connection identity.
ref ScriptInvokerBase< SCR_BaseGameMode_OnPlayerDisconnected > m_OnPlayerDisconnected
ref array< EResourceType > m_aDisabledResourceTypes
bool m_bAutotuneEnabled
is the autotune radio feature enabled
ScriptInvoker GetOnGameEnd()
bool CanBePaused()
Return true if client is offline.
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerAuditRevived()
void SetLocalControls(bool enabled)
SCR_GameModeHealthSettings m_pGameModeHealthSettings
ScriptInvokerBase< SCR_BaseGameMode_OnPlayerDisconnected > GetOnPostCompPlayerDisconnected()
override void OnPlayerConnected(int playerId)
ref ScriptInvoker m_OnControllableSpawned
SCR_EGameModeState GetState()
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > m_OnPlayerSpawned
WorldTimestamp GetGameEndTimeStamp()
EGameFlags m_eTestGameFlags
bool PauseGame(bool pause, SCR_EPauseReason reason=SCR_EPauseReason.SYSTEM)
ScriptInvoker GetOnControllableSpawned()
void OnGameModeEnd(SCR_GameModeEndData endData)
ref ScriptInvokerBase< SCR_BaseGameMode_OnResourceEnabledChanged > m_OnResourceTypeEnabledChanged
bool CanStartSpawnPreload()
bool m_bAdvanceTimeRequiresPlayers
ref SCR_SpawnPreload m_SpawnPreload
bool GetAutotuneEnabled()
override void OnControllableDeleted(IEntity entity)
override void OnPlayerRoleChange(int playerId, EPlayerRole roleFlags)
override void OnPlayerAuditSuccess(int iPlayerID)
ref ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > m_OnPlayerKilled
override void OnControllableDestroyed(IEntity entity, IEntity killerEntity, notnull Instigator instigator)
int GetPlayerRemainingRespawnTime(int playerID)
Returns remaining respawn time in seconds for given player.
ScriptInvoker GetOnControllableDeleted()
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerId > m_OnPlayerAuditFail
RplComponent m_RplComponent
ScriptInvokerBase< SCR_BaseGameMode_OnPlayerDisconnected > GetOnPlayerDisconnected()
ScriptInvoker GetOnWorldPostProcess()
override bool RplSave(ScriptBitWriter writer)
bool IsResourceTypeEnabled(EResourceType resourceType=EResourceType.SUPPLIES)
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerAuditSuccess()
bool CanPlayerSpawn_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, out SCR_ESpawnResult result=SCR_ESpawnResult.SPAWN_NOT_ALLOWED)
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerId > m_OnPlayerRegistered
ref ScriptInvoker m_OnGameEnd
SCR_RespawnTimerComponent m_RespawnTimerComponent
override void OnPlayerRegistered(int playerId)
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerId > m_OnPlayerAuditSuccess
SCR_BaseScoringSystemComponent m_ScoringSystemComponent
void EndGameMode(SCR_GameModeEndData endData)
ref ScriptInvoker m_OnControllableDeleted
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerSpawned()
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > m_OnPlayerDeleted
ref ScriptInvokerBase< SCR_BaseGameMode_OnPlayerRoleChanged > m_OnPlayerRoleChange
void OnPlayerLoadoutSet_S(SCR_PlayerLoadoutComponent loadoutComponent, SCR_BasePlayerLoadout loadout)
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerId > m_OnPlayerConnected
ref ScriptInvoker m_OnGameModeEnd
void ConsumeMilitarySupplyAllocationOnPlayerSpawn_S(SCR_SpawnRequestComponent requestComponent, IEntity spawnPoint, SCR_PlayerLoadoutComponent loadoutComponent)
void OnGameStateChanged()
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerId > m_OnPlayerAuditRevived
override void EOnInit(IEntity owner)
bool GetAllowControlsTarget()
void LogKillEvent(notnull SCR_InstigatorContextData instigatorContext)
SCR_EPauseReason m_ePauseReasons
void ConsumeSuppliesOnPlayerSpawn_S(int playerID, IEntity spawnPoint, SCR_PlayerLoadoutComponent loadoutComp)
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerDeleted()
void SCR_BaseGameMode(IEntitySource src, IEntity parent)
void OnPlayerEntityChanged_S(int playerId, IEntity previousEntity, IEntity newEntity)
void OnPlayerKilledHandled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
Called after player kill behaviour is handled by a component overriding the generic logic.
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerConnected()
ref ScriptInvokerBase< SCR_BaseGameMode_OnPlayerDisconnected > m_OnPostCompPlayerDisconnected
void HandleSpawnPreload(float timeSlice)
bool IsFactionChangeAllowed()
ref map< int, vector > m_mPlayerSpawnPosition
Used on server to respawn player on their original position after reconnecting.
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerAuditFail()
override bool RplLoad(ScriptBitReader reader)
override void OnPlayerAuditFail(int iPlayerID)
override void OnPlayerAuditRevived(int iPlayerID)
bool m_bUseSpawnPreload
Spawn location preload.
override event void OnWorldPostProcess(World world)
void HandleOnTasksInitialized()
Called once tasks are initialized.
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnControllableDestroyed()
ScriptInvoker GetOnGameStart()
bool m_bAllowControls
If false, controls are disable for the time being.
SCR_GameModeHealthSettings GetGameModeHealthSettings()
SCR_RespawnSystemComponent m_pRespawnSystemComponent
WorldTimestamp m_GameEndTimeStamp
void OnSpawnPlayerEntityFailure_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, IEntity entity, SCR_SpawnData data, SCR_ESpawnResult reason)
override void OnPlayerAuditTimeouted(int iPlayerID)
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnPlayerKilled()
OnPreloadFinishedInvoker GetOnPreloadFinished()
SCR_BaseScoringSystemComponent GetScoringSystemComponent()
void OnControllableDestroyedEx(notnull SCR_InstigatorContextData instigatorContextData)
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerRegistered()
ScriptInvoker GetOnGameModeEnd()
float m_fLastTimeCorrection
Last timestamp of sent time correction for the server.
void StartSpawnPreload(vector position)
bool PreparePlayerEntity_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
override void OnGameStart()
bool m_bAutoPlayerRespawn
ref ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > m_OnControllableDestroyed
SCR_BaseGameModeStateComponent GetStateComponent(SCR_EGameModeState state)
ref ScriptInvokerBase< SCR_BaseGameMode_PlayerId > m_OnPlayerAuditTimeouted
int GetDisabledResourceTypes(inout notnull array< EResourceType > disabledResourceTypes)
override bool HandlePlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
void OnPlayerSpawnOnPoint_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, IEntity entity, SCR_SpawnPointSpawnData spawnPointData)
float GetAutoReloadDelay()
bool m_bAllowFactionChange
bool FilterCallback(IEntity e)
ScriptInvokerBase< SCR_BaseGameMode_OnPlayerRoleChanged > GetOnPlayerRoleChange()
ref OnPreloadFinishedInvoker m_OnPreloadFinished
SCR_GameModeEndData GetEndGameData()
ref array< SCR_BaseGameModeComponent > m_aAdditionalGamemodeComponents
void HandleOnGameModeEndSaveData()
void CachePlayerSpawnPosition(int playerID, vector position)
void OnPlayerFactionSet_S(SCR_PlayerFactionAffiliationComponent factionComponent, Faction faction)
ref ScriptInvoker m_OnWorldPostProcess
override void EOnFrame(IEntity owner, float timeSlice)
void OnPlayerKilledEx(notnull SCR_InstigatorContextData instigatorContextData)
sealed bool TryShutdownServer()
override void OnPlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
Default player kill behaviour. Called when a player is killed (and HandlePlayerKilled returns true).
void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
ref ScriptInvoker Event_OnGameStart
ref map< SCR_EGameModeState, SCR_BaseGameModeStateComponent > m_mStateComponents
Map of components per state.
ScriptInvokerBase< SCR_BaseGameMode_OnResourceEnabledChanged > GetOnResourceTypeEnabledChanged()
void SetResourceTypeEnabled(bool enable, EResourceType resourceType=EResourceType.SUPPLIES, int playerID=-1)
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerAuditTimeouted()
SCR_RespawnSystemComponent GetRespawnSystemComponent()
override void OnControllableSpawned(IEntity entity)
bool m_bIsHosted
Is the session hosted by a player?
float m_fTimeCorrectionInterval
Interval of time synchronization in seconds.
void OnResourceTypeEnabledChanged()
\Called when Global Supplies is set to enabled or disabled (Server and client)
void OnPlayerDeleted(int playerId, IEntity player)
SCR_ECharacterDeathStatusRelations GetVictimKillerRelation()
SCR_ECharacterDisguiseType GetVictimDisguiseType()
SCR_ECharacterControlType GetKillerCharacterControlType()
SCR_ECharacterDisguiseType GetKillerDisguiseType()
SCR_ECharacterControlType GetVictimCharacterControlType()
SCR_BasePlayerLoadout GetLoadout()
bool HandlePlayerDisconnect(int playerId, KickCauseCode cause)
Returns true if the players entity has been taken over for reconnection.
static SCR_ReconnectComponent GetInstance()
SCR_SpawnPoint GetSpawnPoint()
EPhysicsLayerPresets
Enum is filled by C++ by data in project config PhysicsSettings.LayerPresets.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
RplCondition
Conditional replication rule. Fine grained selection of receivers.