1 #ifdef BREAK_COMPILATION
2 THIS DEFINE BREAKS
GAME SCRIPT MODULE COMPILATION
3 DO NOT REMOVE IT, IT IS NEEDED FOR VARIOUS TESTS
25 enum EDiagMenuGame : EDiagMenuGameLib
67 protected ref SCR_Stack<SCR_GameErrorMessage>
m_aErrorStack =
new SCR_Stack<SCR_GameErrorMessage>();
74 protected ref ScriptCallQueue
m_Callqueue =
new ScriptCallQueue();
122 Print(
"Trying to register a SCR_DataCollectorComponent, but one is already registered!", LogLevel.ERROR);
146 Print(
"Trying to register a SCR_BuildingDestructionManagerComponent, but one is already registered!", LogLevel.ERROR);
175 Print(
"Trying to register a SCR_SoundManagerEntity, but one is already registered!", LogLevel.ERROR);
282 GameSessionStorage.s_Data[
"m_iRejoinAttempt"] =
"0";
288 Print(
"Cinematic start");
294 Print(
"Cinematic end");
304 SCR_CharacterCameraHandlerComponent camHandlerComp = SCR_CharacterCameraHandlerComponent.Cast(playerEntity.FindComponent(SCR_CharacterCameraHandlerComponent));
307 camHandlerComp.UpdateHeadVisibility(cameraPosition);
318 string group, reason;
324 string format =
"Kick cause code: group=%1 '%2', reason=%3 '%4'";
325 string strDetail =
string.Format(format , groupInt, group, reasonInt, reason);
326 Print(
string.Format(format, groupInt, group, reasonInt, reason), LogLevel.NORMAL);
329 string dialogTag = group +
"_" + reason;
332 if (group ==
"<unknown>")
333 dialogTag =
"DEFAULT_ERROR";
337 if (reason ==
"<unknown>")
364 reason =
"<unknown>";
367 case RplKickCauseGroup.REPLICATION:
368 group =
"REPLICATION";
371 case RplError.SYSTEM_FAILURE: reason =
"SYSTEM_FAILURE";
return true;
372 case RplError.DISCONNECTION: reason =
"DISCONNECTION";
return true;
373 case RplError.CONNECTION_FAILURE: reason =
"CONNECTION_FAILURE";
return true;
374 case RplError.TIMEOUT: reason =
"TIMEOUT";
return true;
375 case RplError.FLOODED: reason =
"FLOODED";
return true;
376 case RplError.STALLED: reason =
"STALLED";
return true;
377 case RplError.SERVICE_FAILURE: reason =
"SERVICE_FAILURE";
return true;
378 case RplError.JIP_ERROR: reason =
"JIP_ERROR";
return true;
379 case RplError.SHUTDOWN: reason =
"SHUTDOWN";
return true;
380 case RplError.CREATION_FAILURE: reason =
"CREATION_FAILURE";
return true;
384 case KickCauseGroup.BATTLEYE_INIT:
385 group =
"BATTLEYE_INIT";
388 case BattlEyeInitError.LOAD_ERROR: reason =
"LOAD_ERROR";
return true;
389 case BattlEyeInitError.UNSUPPORTED_VERSION: reason =
"UNSUPPORTED_VERSION";
return true;
390 case BattlEyeInitError.OTHER_ERROR: reason =
"OTHER_ERROR";
return true;
394 case KickCauseGroup.BATTLEYE:
398 case BattlEyeKickReason.CLIENT_NOT_RESPONDING: reason =
"CLIENT_NOT_RESPONDING";
return true;
399 case BattlEyeKickReason.QUERY_TIMEOUT: reason =
"QUERY_TIMEOUT";
return true;
400 case BattlEyeKickReason.GAME_RESTART_REQUIRED: reason =
"GAME_RESTART_REQUIRED";
return true;
401 case BattlEyeKickReason.BAD_SERVICE_VERSION: reason =
"BAD_SERVICE_VERSION";
return true;
402 case BattlEyeKickReason.DISALLOWED_PROGRAM: reason =
"DISALLOWED_PROGRAM";
return true;
403 case BattlEyeKickReason.CORRUPTED_MEMORY: reason =
"CORRUPTED_MEMORY";
return true;
404 case BattlEyeKickReason.CORRUPTED_DATA: reason =
"CORRUPTED_DATA";
return true;
405 case BattlEyeKickReason.WINAPI_FAILURE: reason =
"WINAPI_FAILURE";
return true;
406 case BattlEyeKickReason.GLOBAL_BAN: reason =
"GLOBAL_BAN";
return true;
407 case BattlEyeKickReason.ADMIN_BAN: reason =
"ADMIN_BAN";
return true;
408 case BattlEyeKickReason.ADMIN_KICK: reason =
"ADMIN_KICK";
return true;
409 case BattlEyeKickReason.INVALID_SERVER_CONFIG: reason =
"INVALID_SERVER_CONFIG";
return true;
413 case KickCauseGroup.DATA:
417 case DataError.VERSION_MISMATCH: reason =
"VERSION_MISMATCH";
return true;
418 case DataError.RDB_MISMATCH: reason =
"RDB_MISMATCH";
return true;
419 case DataError.SCRIPT_MISMATCH: reason =
"SCRIPT_MISMATCH";
return true;
420 case DataError.WORLD_LOAD_ERROR: reason =
"WORLD_LOAD_ERROR";
return true;
421 case DataError.WORLD_LOAD_INCONSISTENCY: reason =
"WORLD_LOAD_INCONSISTENCY";
return true;
422 case DataError.ADDON_LOAD_ERROR: reason =
"ADDON_LOAD_ERROR";
return true;
432 case PlatformKickReason.NO_CROSSPLAY_PRIVILEGE: reason =
"NO_CROSSPLAY_PRIVILEGE";
return true;
437 group =
"PLAYER_MANAGER";
445 case SCR_PlayerManagerKickReason.KICKED_BY_GM: reason =
"KICKED_BY_GM";
return true;
446 case SCR_PlayerManagerKickReason.BANNED_BY_GM: reason =
"BANNED_BY_GM";
return true;
447 case SCR_PlayerManagerKickReason.FRIENDLY_FIRE: reason =
"FRIENDLY_FIRE";
return true;
448 case SCR_PlayerManagerKickReason.DISRUPTIVE_BEHAVIOUR: reason =
"DISRUPTIVE_BEHAVIOUR";
return true;
460 string strAttempt = GameSessionStorage.s_Data[
"m_iRejoinAttempt"];
464 if (strAttempt.IsEmpty())
466 GameSessionStorage.s_Data[
"m_iRejoinAttempt"] =
"0";
470 attempt = strAttempt.ToInt();
475 GameSessionStorage.s_Data[
"m_iRejoinAttempt"] = attempt.ToString();
501 MenuManager menuManager = GetMenuManager();
506 if (currentDialog !=
null)
519 dialog.SetTitle(errorMessage.GetTitle());
520 dialog.SetMessage(errorMessage.GetMessage());
605 if (System.IsConsoleApp())
607 DSSession session =
GetGame().GetBackendApi().GetDSSession();
617 WidgetManager.SetCursor(0);
626 if (RplSession.Mode() != RplMode.Client)
628 DiagMenu.RegisterMenu(
SCR_DebugMenuID.DEBUGUI_DEPLOYABLE_SPAWNPOINTS,
"Deployable SpawnPoints",
"Game");
629 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_DEPLOYABLE_SPAWNPOINTS_ENABLE_DIAG,
"",
"Show Exclusion Zones",
"Deployable SpawnPoints");
632 DiagMenu.RegisterItem(
SCR_DebugMenuID.DEBUGUI_INPUT_MANAGER,
"",
"Show input manager",
"GameCode",
"disabled,active,all");
635 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_GAME_BOUNDS_OVERLAP_PREFAB,
"",
"Show bounds overlap target info",
"Game");
636 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_GAME_CURSOR_TARGET_PREFAB,
"",
"Show cursor target info",
"Game");
637 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_GAME_COPY_ENF_VIEW_LINK,
"lctrl+lshift+l",
"Copy view link",
"Game");
640 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_UI_CLOSE_ALL_MENUS,
"",
"Close All Menus",
"UI");
641 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_UI_OPEN_MAIN_MENU,
"",
"Open Main Menu",
"UI");
642 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_UI_LOG_UNDER_CURSOR,
"",
"Log widgets under cursor",
"UI");
645 if (!GetWorldEntity() || RplSession.Mode() != RplMode.Client)
658 #ifndef PLATFORM_CONSOLE
659 if (System.IsCLIParam(
"listScenarios"))
665 #ifdef PLATFORM_CONSOLE
679 if (settingsVideoModule)
681 int lastUsedPresetID = -1;
682 BaseContainer videoSettings =
GetGame().GetGameUserSettings().GetModule(
"SCR_VideoSettings");
685 videoSettings.Get(
"m_iLastUsedPreset", lastUsedPresetID);
686 if (lastUsedPresetID == -1 && System.GetPlatform() == EPlatform.XBOX_SERIES_S)
687 settingsVideoModule.SetConsolePreset(EVideoQualityPreset.SERIES_S_PRESET_QUALITY);
688 else if (lastUsedPresetID == -1 && System.GetPlatform() == EPlatform.XBOX_SERIES_X)
689 settingsVideoModule.SetConsolePreset(EVideoQualityPreset.SERIES_X_PRESET_QUALITY);
691 if (lastUsedPresetID != -1)
692 settingsVideoModule.SetConsolePreset(lastUsedPresetID);
704 MenuManager menuManager =
GetGame().GetMenuManager();
705 if (!menuManager || menuManager.IsAnyMenuOpen() || menuManager.IsAnyDialogOpen())
713 static void OnShowPlayerList()
715 MenuManager manager =
GetGame().GetMenuManager();
716 if (manager.IsAnyMenuOpen() || manager.IsAnyDialogOpen())
724 static void OnShowGroupMenu()
733 static void OpenPauseMenu(
bool hideParentMenu =
true,
bool fadeBackground =
false)
741 pauseMenu.FadeBackground(
true,
true);
749 MenuManager menuManager =
GetGame().GetMenuManager();
750 if (menuManager.IsAnyDialogOpen())
768 playerFaction =
SCR_Faction.Cast(factionManager.GetLocalPlayerFaction());
773 MenuManager menuManager =
GetGame().GetMenuManager();
774 if (menuManager.IsAnyDialogOpen())
777 MenuBase menu = MenuBase.Cast(menuManager.FindMenuByPreset(
ChimeraMenuPreset.GroupMenu));
778 MenuBase playerMenu = MenuBase.Cast(menuManager.FindMenuByPreset(
ChimeraMenuPreset.PlayerListMenu));
785 GetGame().GetMenuManager().CloseMenu(menu);
795 GetGame().GetMenuManager().CloseAllMenus();
801 gameMode.OnGameEnd();
849 inputManager.AddActionListener(
"ShowScoreboard", EActionTrigger.DOWN, OnShowPlayerList);
850 inputManager.AddActionListener(
"ShowGroupMenu", EActionTrigger.DOWN, OnShowGroupMenu);
851 inputManager.AddActionListener(
"MenuOpen", EActionTrigger.DOWN,
OnMenuOpen);
854 inputManager.AddActionListener(
"MenuOpenWB", EActionTrigger.DOWN,
OnMenuOpen);
863 inputManager.RemoveActionListener(
"ShowScoreboard", EActionTrigger.DOWN, OnShowPlayerList);
864 inputManager.RemoveActionListener(
"ShowGroupMenu", EActionTrigger.DOWN, OnShowGroupMenu);
865 inputManager.RemoveActionListener(
"MenuOpen", EActionTrigger.DOWN,
OnMenuOpen);
868 inputManager.RemoveActionListener(
"MenuOpenWB", EActionTrigger.DOWN,
OnMenuOpen);
873 private ref QueryTargetDiag m_pQueryTargetDiag =
new QueryTargetDiag();
876 private bool GetQueryTargetInfo(IEntity ent, out
string name, out
string tree)
881 EntityPrefabData prefabData = ent.GetPrefabData();
885 name = prefabData.GetPrefabName();
888 BaseContainer cont = prefabData.GetPrefab();
891 string contName = cont.GetName();
892 if (!contName.IsEmpty())
902 cont = cont.GetAncestor();
910 override void OnUpdate(BaseWorld world,
float timeslice)
912 super.OnUpdate(world, timeslice);
917 if (!GetMenuManager().IsAnyMenuOpen())
936 bool bGetEnfLinkToClipboard = DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_GAME_COPY_ENF_VIEW_LINK);
937 if (bGetEnfLinkToClipboard)
940 vector cameraTransform[4];
941 world.GetCurrentCamera(cameraTransform);
942 System.ExportToClipboard(GetWorldEditorLink(cameraTransform));
947 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_GAME_CURSOR_TARGET_PREFAB))
949 CameraManager cameraManager =
GetGame().GetCameraManager();
952 CameraBase current = cameraManager.CurrentCamera();
955 DbgUI.Begin(
"Cursor target info");
956 IEntity ent = current.GetCursorTarget();
960 vector pos = ent.GetOrigin();
963 string name = ent.GetName();
966 pname =
"Unnamed entity";
968 pname =
"Name: " + name;
976 if (GetQueryTargetInfo(ent, prfab, ptree))
978 pepos =
"Position: <" + pos[0] +
", " + pos[1] +
", " + pos[2] +
">";
980 Physics phys = ent.GetPhysics();
981 if( phys && phys.GetVelocity().Length() > 0 )
983 string pevel =
"Velocity: " + phys.GetVelocity().Length();
989 DbgUI.Text(
"Prefab: " + prfab);
990 DbgUI.Text(
"Prefab Inheritance Tree: " + ptree);
993 string infoText =
string.Format(
"%1\n%2\nPrefab: \"%3\"\nPrefab Inheritance Tree: \"%4\"", pname, pepos, prfab, ptree);
995 if (DbgUI.Button(
"Copy to clipboard"))
997 System.ExportToClipboard(infoText);
1002 ent.GetWorldBounds(mins, maxs);
1003 Shape boundingFill = Shape.Create(ShapeType.BBOX, ARGB(5, 0, 255, 0), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.TRANSP, mins, maxs);
1004 Shape boundingWire = Shape.Create(ShapeType.BBOX, ARGB(200, 0, 255, 255), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.WIREFRAME | ShapeFlags.TRANSP, mins, maxs);
1006 DebugTextWorldSpace.Create(current.GetWorld(), infoText, DebugTextFlags.FACE_CAMERA | DebugTextFlags.CENTER | DebugTextFlags.ONCE, pos[0], maxs[1] + 0.5, pos[2], 8, ARGB(255, 0, 255, 255), ARGB(64, 0, 0, 0));
1013 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_GAME_BOUNDS_OVERLAP_PREFAB))
1015 CameraManager cameraManager =
GetGame().GetCameraManager();
1018 CameraBase current = cameraManager.CurrentCamera();
1021 DbgUI.Begin(
"Bounds overlap target info");
1022 vector cameraMat[4];
1023 current.GetWorldTransform(cameraMat);
1025 m_pQueryTargetDiag.Prepare();
1026 m_pQueryTargetDiag.DoQuery(current.GetWorld(), cameraMat[3], cameraMat[3] + 3.0 * cameraMat[2]);
1027 IEntity ent = m_pQueryTargetDiag.GetClosestEntity(cameraMat[3]);
1031 vector pos = ent.GetOrigin();
1034 string name = ent.GetName();
1036 if( name.IsEmpty() )
1037 pname =
"Unnamed entity";
1039 pname =
"Name: " + name;
1047 if (GetQueryTargetInfo(ent, prfab, ptree))
1049 pepos =
"Position: <" + pos[0] +
", " + pos[1] +
", " + pos[2] +
">";
1051 Physics phys = ent.GetPhysics();
1052 if( phys && phys.GetVelocity().Length() > 0 )
1054 string pevel =
"Velocity: " + phys.GetVelocity().Length();
1060 DbgUI.Text(
"Prefab: " + prfab);
1061 DbgUI.Text(
"Prefab Inheritance Tree: " + ptree);
1064 string infoText =
string.Format(
"%1\n%2\nPrefab: \"%3\"\nPrefab Inheritance Tree: \"%4\"", pname, pepos, prfab, ptree);
1065 if (DbgUI.Button(
"Copy to clipboard"))
1067 System.ExportToClipboard(infoText);
1072 ent.GetWorldBounds(mins, maxs);
1073 Shape boundingFill = Shape.Create(ShapeType.BBOX, ARGB(5, 0, 255, 0), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.TRANSP, mins, maxs);
1074 Shape boundingWire = Shape.Create(ShapeType.BBOX, ARGB(200, 0, 255, 255), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.WIREFRAME | ShapeFlags.TRANSP, mins, maxs);
1076 DebugTextWorldSpace.Create(current.GetWorld(), infoText, DebugTextFlags.FACE_CAMERA | DebugTextFlags.CENTER | DebugTextFlags.ONCE, pos[0], maxs[1] + 0.5, pos[2], 8, ARGB(255, 0, 255, 255), ARGB(64, 0, 0, 0));
1087 GetGame().GetMenuManager().CloseAllMenus();
1101 array<Widget> widgets = {};
1103 WidgetManager.GetMousePos(mouseX, mouseY);
1104 WidgetManager.TraceWidgets(mouseX, mouseY,
GetGame().GetWorkspace(), widgets);
1105 int count = widgets.Count();
1106 Print(
string.Format(
"Widgets under cursor (x = %1, y = %2): %3", mouseX, mouseY, count), LogLevel.NORMAL);
1107 for (
int i; i < count; i++)
1109 Print(
" " +
SCR_WidgetTools.GetHierarchyLog(widgets[i]), LogLevel.NORMAL);
1143 string fileNameFiltered = FilePath.StripExtension(fileName, ext);
1145 fileName = fileNameFiltered;
1158 Print(
"Trying to register a SCR_LoadoutManager, but one is already registered!", LogLevel.ERROR);
1173 Print(
"Trying to unregister a SCR_LoadoutManager, but none is registered!", LogLevel.ERROR);
1179 Print(
"Trying to unregister an invalid SCR_LoadoutManager!", LogLevel.ERROR);
1185 Print(
"Trying to unregister a SCR_LoadoutManager, but different one is registered!", LogLevel.ERROR);
1189 Print(
"SCR_LoadoutManager unregistered successfully, released instance: " + instance, LogLevel.VERBOSE);
1205 static string GetWorldEditorLink(vector transformation[4])
1208 vector
position = transformation[3];
1211 vector angles = Math3D.MatrixToAngles(transformation);
1215 string fullLink =
GetGame().GetWorldFile();
1216 string fullLinkLower = fullLink;
1217 fullLinkLower.ToLower();
1218 int begin = fullLinkLower.IndexOf(
"worlds/");
1219 string worldPath = fullLink.Substring(begin, fullLink.Length() - begin);
1222 string link =
string.Format(
1223 "enfusion://WorldEditor/%1;%2,%3,%4;%5,%6,%7",
1251 return header.m_sName;
1259 Print(
string.Format(
"PlayGameConfig {Resource: %1; Addons: %2}", sResource, addonsList), LogLevel.NORMAL);
1261 if (sResource.Empty)
1263 Print(
string.Format(
"PlayGameConfig: Empty resource passed!"), LogLevel.NORMAL);
1268 GetGame().GetMenuManager().CloseAllMenus();
1270 Print(
string.Format(
"Failed to start scenario."), LogLevel.ERROR);
1279 GetGame().GetMenuManager().CloseAllMenus();
1281 Print(
"Failed to host config", LogLevel.ERROR);
1297 ResourceName config =
"{CB4130E7FBE99D74}Configs/Workshop/DefaultScenarios.conf";
1298 Resource resource = BaseContainerTools.LoadContainer(config);
1302 BaseContainer entries = resource.GetResource().ToBaseContainer();
1306 array<ResourceName> resources = {};
1308 entries.Get(
"m_aDefaultScenarios", resources);
1319 foreach (ResourceName r : resources)
1325 resources.Insert(scenario);
1331 protected static bool CheckMissionHeader(MissionWorkshopItem mission)
1337 Print(
string.Format(
"Mission header doesn't exist or is not of SCR_MissionHeader class: %1", mission.Name()), LogLevel.ERROR);
1341 string worldPath = header.GetWorldPath();
1342 if (worldPath.IsEmpty())
1344 Print(
string.Format(
"Mission world path is incorrect: %1", mission.Name()), LogLevel.ERROR);
1353 static SCR_2DPIPSightsComponent GetCurrentPIPSights()
1356 if (!controlledEntity)
1359 ChimeraCharacter character = ChimeraCharacter.Cast(controlledEntity);
1363 BaseWeaponManagerComponent weaponManager = character.GetCharacterController().GetWeaponManagerComponent();
1367 BaseSightsComponent currentSights = weaponManager.GetCurrentSights();
1371 SCR_2DPIPSightsComponent pip = SCR_2DPIPSightsComponent.Cast(currentSights);
1383 static bool IsScreenPointInPIPSights(vector screenPosition, SCR_2DPIPSightsComponent sightsComponent)
1385 if (!sightsComponent)
1388 return sightsComponent.IsScreenPositionInSights(screenPosition);
1395 #ifdef PLATFORM_CONSOLE
1419 g_ARGame =
new ArmaReforgerScripted;
1430 class QueryTargetDiag
1432 private ref array<IEntity> m_aQueriedTargetEntities = {};
1439 m_aQueriedTargetEntities.Clear();
1448 void DoQuery(BaseWorld world, vector from, vector to)
1450 world.QueryEntitiesByLine(from, to, QueryTargetEntity);
1454 private bool QueryTargetEntity(IEntity ent)
1456 if (CameraBase.Cast(ent))
1459 m_aQueriedTargetEntities.Insert(ent);
1464 IEntity GetFirstEntity()
1466 if (m_aQueriedTargetEntities.Count() > 0)
1467 return m_aQueriedTargetEntities[0];
1476 IEntity GetClosestEntity(vector relativeTo)
1478 IEntity closest =
null;
1479 float sqDistance =
float.MAX;
1480 foreach (IEntity ent : m_aQueriedTargetEntities)
1482 float currentSqDist = vector.DistanceSq(ent.GetOrigin(), relativeTo);
1483 if (currentSqDist < sqDistance)
1486 sqDistance = currentSqDist;