diff --git a/addons/finger/Configs/ACE/Settings.conf b/addons/finger/Configs/ACE/Settings.conf new file mode 100644 index 00000000..e445351c --- /dev/null +++ b/addons/finger/Configs/ACE/Settings.conf @@ -0,0 +1,6 @@ +ACE_SettingsConfig { + m_aInitialModSettings { + ACE_Finger_Settings "{626D5B540473CB13}" { + } + } +} \ No newline at end of file diff --git a/addons/finger/Configs/ACE/Settings.conf.meta b/addons/finger/Configs/ACE/Settings.conf.meta new file mode 100644 index 00000000..094ecd2f --- /dev/null +++ b/addons/finger/Configs/ACE/Settings.conf.meta @@ -0,0 +1,17 @@ +MetaFileClass { + Name "{A305FEB7400A2965}Configs/ACE/Settings.conf" + Configurations { + CONFResourceClass PC { + } + CONFResourceClass XBOX_ONE : PC { + } + CONFResourceClass XBOX_SERIES : PC { + } + CONFResourceClass PS4 : PC { + } + CONFResourceClass PS5 : PC { + } + CONFResourceClass HEADLESS : PC { + } + } +} \ No newline at end of file diff --git a/addons/finger/scripts/Game/ACE_Finger/Editor/Components/Editor/ACE_Finger_EditorComponent.c b/addons/finger/scripts/Game/ACE_Finger/Editor/Components/Editor/ACE_Finger_EditorComponent.c index 412bf916..bf6687ae 100644 --- a/addons/finger/scripts/Game/ACE_Finger/Editor/Components/Editor/ACE_Finger_EditorComponent.c +++ b/addons/finger/scripts/Game/ACE_Finger/Editor/Components/Editor/ACE_Finger_EditorComponent.c @@ -8,10 +8,13 @@ class ACE_Finger_EditorComponentClass: SCR_BaseEditorComponentClass //! Equivalent to SCR_PingEditorComponent for finger pings class ACE_Finger_EditorComponent : SCR_BaseEditorComponent { - [Attribute(defvalue: "1000", desc: "Maximum pointing distance in meters")] + [RplProp(), Attribute(defvalue: "1000", desc: "Maximum pointing distance in meters.")] protected float m_fMaxPointingDistanceM; - [Attribute(defvalue: "10", desc: "Range of the ping in meters. Only players in range will see it.")] + [Attribute(defvalue: "true", desc: "Whether the ping can attach to entities.")] + bool m_bCanPingAttach; + + [RplProp(), Attribute(defvalue: "10", desc: "Range of the ping in meters. Only players in range will see it. Anyone can see it if negative.")] protected float m_fPingRangeM; [Attribute(defvalue: "6", desc: "Lifetime of ping in seconds")] @@ -27,6 +30,23 @@ class ACE_Finger_EditorComponent : SCR_BaseEditorComponent protected ref ScriptInvoker Event_OnPingEntityUnregister = new ScriptInvoker; protected float m_fLastPingTime = 0; + //------------------------------------------------------------------------------------------------ + override protected void OnPostInit(IEntity owner) + { + super.OnPostInit(owner); + + if (!Replication.IsServer()) + return; + + ACE_Finger_Settings settings = ACE_SettingsHelperT.GetModSettings(); + if (settings) + { + m_fMaxPointingDistanceM = settings.m_fMaxPointingDistanceM; + m_bCanPingAttach = settings.m_bCanPingAttach; + m_fPingRangeM = settings.m_fPingRangeM; + } + } + //------------------------------------------------------------------------------------------------ //! Method for local player to request pings on a position or target void SendPing(vector targetPos, SCR_EditableEntityComponent target = null) @@ -51,6 +71,10 @@ class ACE_Finger_EditorComponent : SCR_BaseEditorComponent [RplRpc(RplChannel.Reliable, RplRcver.Server)] protected void RpcAsk_SendPing(int reporterID, vector reporterPos, vector targetPos, RplId targetID) { + // Drop target if pings can't be attached + if (!m_bCanPingAttach) + targetID = RplId.Invalid(); + // Send ping to server as well if not dedicated if (RplSession.Mode() != RplMode.Dedicated) RpcDo_SendPing(reporterID, reporterPos, targetPos, targetID); @@ -64,7 +88,10 @@ class ACE_Finger_EditorComponent : SCR_BaseEditorComponent protected void RpcDo_SendPing(int reporterID, vector reporterPos, vector targetPos, RplId targetID) { IEntity player = GetGame().GetPlayerController().GetControlledEntity(); - if (!player || vector.Distance(player.GetOrigin(), reporterPos) > m_fPingRangeM) + if (!player) + return; + + if (m_fPingRangeM >= 0 && vector.Distance(player.GetOrigin(), reporterPos) > m_fPingRangeM) return; SCR_EditableEntityComponent target = SCR_EditableEntityComponent.Cast(Replication.FindItem(targetID)); diff --git a/addons/finger/scripts/Game/ACE_Finger/Mission/ACE_MissionHeaderSettings.c b/addons/finger/scripts/Game/ACE_Finger/Mission/ACE_MissionHeaderSettings.c new file mode 100644 index 00000000..741cf688 --- /dev/null +++ b/addons/finger/scripts/Game/ACE_Finger/Mission/ACE_MissionHeaderSettings.c @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------------------------ +//! Add mod settings to mission header +[BaseContainerProps()] +modded class ACE_MissionHeaderSettings +{ + [Attribute()] + protected ref ACE_Finger_Settings m_ACE_Finger_Settings; + + //------------------------------------------------------------------------------------------------ + //! Applies settings from mission header to config + override void ApplyToSettingsConfig(notnull ACE_SettingsConfig config) + { + if (m_ACE_Finger_Settings) + config.SetModSettings(m_ACE_Finger_Settings); + } +} diff --git a/addons/finger/scripts/Game/ACE_Finger/Settings/ACE_Finger_Settings.c b/addons/finger/scripts/Game/ACE_Finger/Settings/ACE_Finger_Settings.c new file mode 100644 index 00000000..82ca22b0 --- /dev/null +++ b/addons/finger/scripts/Game/ACE_Finger/Settings/ACE_Finger_Settings.c @@ -0,0 +1,14 @@ +//------------------------------------------------------------------------------------------------ +//! Settings for a mod +[BaseContainerProps()] +class ACE_Finger_Settings : ACE_ModSettings +{ + [RplProp(), Attribute(defvalue: "1000", desc: "Maximum pointing distance in meters.")] + float m_fMaxPointingDistanceM; + + [Attribute(defvalue: "true", desc: "Whether the ping can attach to entities.")] + bool m_bCanPingAttach; + + [Attribute(defvalue: "10", desc: "Range of the ping in meters. Only players in range will see it. Anyone can see it if negative.")] + float m_fPingRangeM; +} diff --git a/docs/src/content/docs/components/finger.mdx b/docs/src/content/docs/components/finger.mdx index f225d5a4..9a167a9d 100644 --- a/docs/src/content/docs/components/finger.mdx +++ b/docs/src/content/docs/components/finger.mdx @@ -17,3 +17,27 @@ Allows players to point in a direction with their fingers, when they do so peopl - Use the `Point with finger briefly` keybind in `Character` category (Default: Ctrl+~) +## Settings + +Certain aspects of this mod can be configured in the mission header section of a server config file. An overview of available fields is given below in the table: + +| Field | Type | Default | Description | +| ----------------------- | ----- | ------- | ---------------------------------------------------------------------------------------------- | +| m_fMaxPointingDistanceM | float | 1000 | Maximum pointing distance in meters. | +| m_bCanPingAttach | bool* | true | Whether the ping can attach to entities. | +| m_fPingRangeM | float | 10 | Range of the ping in meters. Only players in range will see it. Anyone can see it if negative. | + +\* Note that bool has to be provided as integer in the config: 1 (true) or 0 (false). + +Example for the `missionHeader` in a server config: +``` +"missionHeader": { + "m_ACE_Settings": { + "m_ACE_Finger_Settings": { + "m_fMaxPointingDistanceM": 1000, + "m_bCanPingAttach": 1, + "m_fPingRangeM": 10 + } + } +} +```