Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ArtilleryWaypointGroupCommand.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Distance below which random offset will not be applied. [m]", params: "0 inf")]
5 protected float m_fPositionOffsetCloseDistance;
6
7 [Attribute(desc: "Distance from which target position offsetting will use max values. [m]\nIf this value is 0 then offset will not be applied", params: "0 inf")]
8 protected float m_fPositionOffsetFarDistance;
9
10 [Attribute(desc: "Max possible offset that can be added to the target position. [m]", params: "0 inf")]
11 protected float m_fMaxPositionOffset;
12
13 [Attribute(desc: "Curve that describes bottom end of the random distance.\nWhen values are reed, the X axis is determined by (DistanceFromCharacterToTargetPosition - PositionOffsetCloseDistance) / PositionOffsetFarDistance,\n while Y axis will be used to determine min offset distance by multipling it by MaxPositionOffset", uiwidget: UIWidgets.CurveDialog, params: "1 1 0 0")]
15
16 [Attribute(desc: "Curve that describes top end of the random distance.\nWhen values are reed, the X axis is determined by (DistanceFromCharacterToTargetPosition - PositionOffsetCloseDistance) / PositionOffsetFarDistance,\n while Y axis will be used to determine max offset distance by multipling it by MaxPositionOffset", uiwidget: UIWidgets.CurveDialog, params: "1 1 0 0")]
18
19#ifdef ENABLE_DIAG
20 protected static ref SCR_DebugShapeManager s_DebugShapes = new SCR_DebugShapeManager();
21#endif
22
23 //------------------------------------------------------------------------------------------------
24 override bool SetWaypointForAIGroup(IEntity target, vector targetPosition, int playerID)
25 {
26 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID));
27 if (!character)
28 return false;
29
30 SpoofTargetPosition(targetPosition, character);
31
32 return super.SetWaypointForAIGroup(target, targetPosition, playerID);
33 }
34
35 //------------------------------------------------------------------------------------------------
39 protected void SpoofTargetPosition(inout vector targetPosition, notnull ChimeraCharacter character)
40 {
41#ifdef ENABLE_DIAG
42 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_COMMANDING_WAYPOINT_POSITIONS))
43 {
44 s_DebugShapes.Clear();
45 s_DebugShapes.AddSphere(targetPosition, 1, Color.GREEN, ShapeFlags.WIREFRAME);
46 }
47#endif
48 if (m_fPositionOffsetFarDistance == 0)
49 return;//no spoofing configured for this command
50
52 if (!gameModeSettings || !gameModeSettings.IsAdditionalArtileryOrderDistancePenaltyEnabled())
53 return;//spoofing disabled in gamemode settings
54
55 vector characterPosition = character.GetOrigin();
56 float distance = vector.Distance(targetPosition, characterPosition);
57 if (distance < m_fPositionOffsetCloseDistance)
58 return;//too close to spoof
59
60 float distanceNormal = (distance - m_fPositionOffsetCloseDistance) / m_fPositionOffsetFarDistance;
61 float minOffsetValue = LegacyCurve.Curve(ECurveType.CurveProperty2D, distanceNormal, m_aMinPositionOffset)[1] * m_fMaxPositionOffset;
62 float maxOffsetValue = LegacyCurve.Curve(ECurveType.CurveProperty2D, distanceNormal, m_aMaxPositionOffset)[1] * m_fMaxPositionOffset;
63
64 if (maxOffsetValue < minOffsetValue)
65 {
66 Print("Warning! Minimal order offset value is lower than maximal! Check configuration of curves for " + m_sCommandName + "at point " + distanceNormal, LogLevel.WARNING);
67 return;
68 }
69
70 targetPosition = SCR_Math2D.GenerateRandomPointInRadius(minOffsetValue, maxOffsetValue, targetPosition, false);
71 targetPosition[1] = SCR_TerrainHelper.GetTerrainY(targetPosition, noUnderwater: true);
72
73#ifdef ENABLE_DIAG
74 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_COMMANDING_WAYPOINT_POSITIONS))
75 {
76 s_DebugShapes.AddSphere(targetPosition, 0.5 + distanceNormal * 5, Color.RED, ShapeFlags.WIREFRAME);
77 Print("Debug: Order position is " + distance + " meters away from the player.");
78 Print("Debug: Using curve values for X = " + Math.Clamp(distanceNormal, 0, 1));
79 Print("Debug: Min possible offset for this distance is " + minOffsetValue);
80 Print("Debug: Max possible offset for this distance is " + maxOffsetValue);
81 }
82#endif
83 }
84
85 //------------------------------------------------------------------------------------------------
86 // constructor
88 {
89 if (m_fPositionOffsetFarDistance < m_fPositionOffsetCloseDistance)
90 {
91 Print("ERROR: Command " + m_sCommandName + " is misconfigured in Commands.conf! Its 'Position Offset Close Distance' (" + m_fPositionOffsetCloseDistance + ") is larger than 'Position Offset Far Distance' (" + m_fPositionOffsetFarDistance + ")", LogLevel.ERROR);
92 m_fPositionOffsetCloseDistance = 0;
93 m_fPositionOffsetFarDistance = 0;
94 }
95
96#ifdef ENABLE_DIAG
97 if (Replication.IsServer()) //position is only spoofed on the server as it is spawning the waypoint
98 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_COMMANDING_WAYPOINT_POSITIONS, "", "Artillery command debug", "AI");
99#endif
100 }
101}
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_AdditionalGameModeSettingsComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
float distance
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Color.c:13
Definition Math.c:22
Diagnostic and developer menu system.
Definition DiagMenu.c:18
Definition Math.c:13
Main replication API.
Definition Replication.c:14
void SpoofTargetPosition(inout vector targetPosition, notnull ChimeraCharacter character)
override bool SetWaypointForAIGroup(IEntity target, vector targetPosition, int playerID)
static vector GenerateRandomPointInRadius(float minRadius, float maxRadius, vector center, bool uniform=true)
Definition SCR_Math2D.c:392
static float GetTerrainY(vector pos, BaseWorld world=null, bool noUnderwater=false, TraceParam trace=null)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
ShapeFlags
Definition ShapeFlags.c:13
SCR_FieldOfViewSettings Attribute
ECurveType
Definition ECurveType.c:13