Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actionviewoptics.c
Go to the documentation of this file.
2{
4 {
6 m_CommandUID = DayZPlayerConstants.CMD_GESTUREFB_LOOKOPTICS;
7 m_CommandUIDProne = DayZPlayerConstants.CMD_GESTUREFB_LOOKOPTICS;
8
9 m_Text = "#Look_Through";
10 }
11
12 override void CreateConditionComponents()
13 {
16 }
17
18 override bool IsFullBody(PlayerBase player)
19 {
20 return true;
21 }
22
23 override bool IsCameraLockOnPerform()
24 {
25 return false;
26 }
27
28 override bool CanBeUsedLeaning()
29 {
30 return false;
31 }
32
33 override bool HasProgress()
34 {
35 return false;
36 }
37
38 override bool HasTarget()
39 {
40 return false;
41 }
42
43 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
44 {
45 ItemOptics optic;
46 if (Class.CastTo(optic, item) && !optic.IsInOptics() && !player.IsNVGLowered())
47 {
48 return true;
49 }
50 return false;
51 }
52
53 override bool ActionConditionContinue(ActionData action_data)
54 {
55 return true;
56 }
57
58 override void OnStartClient(ActionData action_data)
59 {
60 super.OnStartClient(action_data);
61
62 GetGame().GetMission().AddActiveInputExcludes({"actonViewOpticExcl"});
63 }
64
65 override void OnStartServer(ActionData action_data)
66 {
67 super.OnStartServer(action_data);
68
69 if (!GetGame().IsMultiplayer())
70 GetGame().GetMission().AddActiveInputExcludes({"actonViewOpticExcl"});
71 }
72
73 override void OnStartAnimationLoopServer(ActionData action_data)
74 {
75 ItemOptics optic;
76 if (Class.CastTo(optic, action_data.m_MainItem))
77 {
78 if (!optic.IsInOptics())
79 {
80 EnterOptics(optic, action_data.m_Player);
81 }
82 }
83 }
84
85 override void OnStartAnimationLoopClient(ActionData action_data)
86 {
87 ItemOptics optic;
88 if (Class.CastTo(optic, action_data.m_MainItem))
89 {
90 if (!optic.IsInOptics())
91 {
92 EnterOptics(optic, action_data.m_Player);
93 }
94 }
95 }
96
97 override void OnEndClient(ActionData action_data)
98 {
99 ItemOptics optic;
100 if (Class.CastTo(optic, action_data.m_MainItem) && optic.IsInOptics())
101 {
102 ExitOptics(optic, action_data.m_Player);
103 }
104 GetGame().GetMission().RemoveActiveInputExcludes({"actonViewOpticExcl"});
105 }
106
107 override void OnEndServer(ActionData action_data)
108 {
109 super.OnEndServer(action_data);
110
111 ItemOptics optic;
112 if (Class.CastTo(optic, action_data.m_MainItem) && optic.IsInOptics())
113 {
114 ExitOptics(optic, action_data.m_Player);
115 }
116
117 if (!GetGame().IsMultiplayer())
118 GetGame().GetMission().RemoveActiveInputExcludes({"actonViewOpticExcl"});
119 }
120
121 override void OnEndAnimationLoopClient(ActionData action_data)
122 {
123 ItemOptics optic;
124 if (Class.CastTo(optic, action_data.m_MainItem))
125 {
126 ExitOptics(optic, action_data.m_Player);
127 }
128 }
129
130 override void OnEndAnimationLoopServer(ActionData action_data)
131 {
132 ItemOptics optic;
133 if (Class.CastTo(optic, action_data.m_MainItem))
134 {
135 ExitOptics(optic, action_data.m_Player);
136 }
137 }
138
139 bool CanWork(ItemBase item)
140 {
141 if (!item.HasEnergyManager())
142 {
143 return true;
144 }
145 else if (item.GetCompEM() && item.GetCompEM().CanWork())
146 {
147 return true;
148 }
149
150 return false;
151 }
152
153 void EnterOptics(ItemOptics optic, PlayerBase player)
154 {
155 player.SetIronsights(false);
156 player.SetHandheldOpticsInUse(true);
157 player.SetOptics(true);
158
159 optic.EnterOptics();
160 optic.HideSelection("hide");
161
162 if (optic.HasEnergyManager())
163 optic.GetCompEM().SwitchOn();
164
165 player.GetAimingModel().SetAimNoiseAllowed(false);
166 }
167
168 void ExitOptics(ItemOptics optic, PlayerBase player)
169 {
170 player.ExitSights();
171 player.SetHandheldOpticsInUse(false);
172
173 optic.ShowSelection("hide");
174 optic.ExitOptics();
175
176 if (optic.HasEnergyManager())
177 optic.GetCompEM().SwitchOff();
178
179 player.GetAimingModel().SetAimNoiseAllowed(true);
180 }
181}
string m_Text
Definition actionbase.c:58
ref CCIBase m_ConditionItem
Definition actionbase.c:64
ref CCTBase m_ConditionTarget
Definition actionbase.c:65
Super root of all classes in Enforce script.
Definition enscript.c:11
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
bool IsFullBody()