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