Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseMineAction.c
Go to the documentation of this file.
2{
3 [Attribute(defvalue: "10", desc: "How long the user action will be shown as inactive after starting arming. [s]", params: "0 inf 0.01")]
4 protected float m_fActionTimeout;
5
6 [Attribute(defvalue: "0", desc: "Can this user action be used while prone")]
7 protected bool m_bCanBeUsedProne;
8
9 [Attribute(desc: "Additional rotation that will be applied when orientating the mine")]
11
13 protected SCR_PressureTriggerComponent m_MineTriggereComp;
14 protected bool m_bBlockUserAction;
15
16 protected const float MAX_HEIGHT_DIFFERENCE = 0.4;
17 protected const string CANNOT_PERFORM_PRONE = "#AR-UserAction_CannotPerformWhileProne";
18
19 //------------------------------------------------------------------------------------------------
20 protected void OrientToForward(vector forward, inout vector mat[4])
21 {
22 vector angles = forward.VectorToAngles() + m_vAdditionalRotation;
23 forward = angles.AnglesToVector();
24 mat[0] = forward * mat[1];
25 mat[2] = mat[1] * -mat[0];
26 }
27
28 //------------------------------------------------------------------------------------------------
29 protected void AllowActionUsage()
30 {
31 m_bBlockUserAction = false;
32 }
33
34 //------------------------------------------------------------------------------------------------
35 override event void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
36 {
37 m_bBlockUserAction = true;
38 GetGame().GetCallqueue().CallLater(AllowActionUsage, 1000 * m_fActionTimeout);
39 }
40
41 //------------------------------------------------------------------------------------------------
42 override bool CanBePerformedScript(IEntity user)
43 {
45 return false;
46
47 ChimeraCharacter character = ChimeraCharacter.Cast(user);
48 if (!character)
49 return false;
50
51 CharacterControllerComponent controller = character.GetCharacterController();
52 if (!controller)
53 return false;
54
55 if (!m_bCanBeUsedProne && controller.GetStance() == ECharacterStance.PRONE)
56 {
58 return false;
59 }
60
61 IEntity owner = GetOwner();
62 if (!owner)
63 return false;
64
65 if (SCR_WorldTools.IsObjectUnderwater(owner))
66 return false;
67
68 vector mat[4];
69 owner.GetTransform(mat);
70 if (vector.Dot(mat[1], vector.Up) < 0.5) // Rject based on the angle of placement
71 return false;
72
73 if (Math.AbsFloat(mat[3][1] - user.GetOrigin()[1]) > MAX_HEIGHT_DIFFERENCE)
74 return false;
75
76 return true;
77 }
78
79 //------------------------------------------------------------------------------------------------
80 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
81 {
83 m_MineTriggereComp = SCR_PressureTriggerComponent.Cast(GetOwner().FindComponent(SCR_PressureTriggerComponent));
84 }
85
86 //------------------------------------------------------------------------------------------------
87 override bool CanBeShownScript(IEntity user)
88 {
90 return false;
91
92 if (!m_Item)
93 return false;
94
95 if (m_Item.IsLocked())
96 return false;
97
98 if (m_Item.GetParentSlot())
99 return false;
100
101 return super.CanBeShownScript(user);
102 }
103}
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< string > angles
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SetCannotPerformReason(string reason)
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external void GetTransform(out vector mat[])
Definition Math.c:13
override bool CanBePerformedScript(IEntity user)
override bool CanBeShownScript(IEntity user)
InventoryItemComponent m_Item
const string CANNOT_PERFORM_PRONE
override event void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
void OrientToForward(vector forward, inout vector mat[4])
const float MAX_HEIGHT_DIFFERENCE
SCR_PressureTriggerComponent m_MineTriggereComp
ECharacterStance
SCR_FieldOfViewSettings Attribute