DayZ 1.24
Loading...
Searching...
No Matches
RemoteDetonator.c
Go to the documentation of this file.
6
7class RemoteDetonator : Inventory_Base
8{
9 const string COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)";
10 const string COLOR_LED_LIT = "#(argb,8,8,3)color(1,0,0,1.0,co)";
11 const string SELECTION_NAME_LED = "LED";
12
14
15 bool IsKit()
16 {
17 return true;
18 }
19
21 {
22 int selectionIdx = GetHiddenSelectionIndex(SELECTION_NAME_LED);
23
24 switch (pState)
25 {
27 SetObjectTexture(selectionIdx, COLOR_LED_LIT);
28 break;
29 default:
30 SetObjectTexture(selectionIdx, COLOR_LED_OFF);
31 }
32
34 SetSynchDirty();
35 }
36
37 override void SetActions()
38 {
39 super.SetActions();
40
43 }
44}
45
46class RemoteDetonatorTrigger : RemoteDetonator
47{
48 protected const string ANIM_PHASE_TRIGGER = "trigger";
49
50 protected bool m_LED;
52
54 {
56 m_RAIB.SetTrigger();
57
58 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdLow");
59 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdHigh");
60 RegisterNetSyncVariableInt("m_LastLEDState", 0, EnumTools.GetEnumSize(ERemoteDetonatorLEDState));
61
63 }
64
65 override bool IsKit()
66 {
67 return false;
68 }
69
71 {
72 super.OnVariablesSynchronized();
73
74 if (m_RAIB)
75 m_RAIB.OnVariableSynchronized();
76
78 }
79
81 {
82 super.EEItemLocationChanged(oldLoc, newLoc);
83
84 if (m_RAIB)
85 m_RAIB.Pair();
86 }
87
92
93 override void OnCEUpdate()
94 {
95 super.OnCEUpdate();
96
97 if (!IsRuined() && IsConnected() && GetControlledDevice())
98 {
100 {
102
103 return;
104 }
105 }
106
108 }
109
111 {
112 m_RAIB.Pair(trigger);
113 }
114
115 override void UnpairRemote()
116 {
118 m_RAIB.Unpair();
119 }
120
122 {
123 if (GetGame().IsServer())
124 {
125 if (m_RAIB.IsPaired() && !IsRuined())
126 {
129 device.OnActivatedByItem(this);
130 }
131 }
132 }
133
135 {
136 m_RAIB.Pair(pDevice);
137 }
138
140 {
141 return m_RAIB.IsPaired();
142 }
143
145 {
146 return m_RAIB.GetPairDevice();
147 }
148
150 {
151 string type = "RemoteDetonatorTrigger";
154 if (player)
155 {
156 ItemBase inHandsItem = player.GetItemInHands();
157 if (inHandsItem)
158 {
159 if (deviceToPair)
160 {
162 onArmLambda.SetPairDevice(deviceToPair);
163 MiscGameplayFunctions.TurnItemIntoItemEx(player, onArmLambda);
164 }
165 else
166 {
168 MiscGameplayFunctions.TurnItemIntoItemEx(player, lambda);
169 }
170
171
172 rdt = RemoteDetonatorTrigger.Cast(player.GetItemInHands());
173 }
174 else
175 rdt = RemoteDetonatorTrigger.Cast(player.GetHumanInventory().CreateInHands(type));
176
178 if (player.GetItemInHands())
179 player.GetItemAccessor().OnItemInHandsChanged();
180 }
181
182 return rdt;
183 }
184
185 override void OnAnimationPhaseStarted(string animSource, float phase)
186 {
188 {
189 if (phase > 0.01)
191 }
192 }
193
204
205#ifdef DIAG_DEVELOPER
206 override protected string GetDebugText()
207 {
208 string debug_output;
209 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
210 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
211 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
212 return debug_output;
213 }
214#endif
215}
216
217class RemoteDetonatorReceiver : RemoteDetonator
218{
224 override bool IsKit()
226 return false;
227 }
228
229 override void OnWasDetached(EntityAI parent, int slot_id)
230 {
232 }
233
234 override void EEKilled(Object killer)
235 {
236 super.EEKilled(killer);
237
239 }
240
241 override void SetActions()
251{
253 {
254 super.CopyOldPropertiesToNew(old_item, new_item);
255
256 MiscGameplayFunctions.TransferItemProperties(old_item, new_item);
257 }
258}
259
266 m_PairDevice = device;
267 }
268
270 {
271 super.OnSuccess(new_item);
272
273 RemoteDetonator detonator = RemoteDetonator.Cast(new_item);
274 if (detonator)
275 {
276 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
277 if (explosive)
278 {
279 ItemBase receiver = ItemBase.Cast(explosive.GetInventory().CreateAttachment("RemoteDetonatorReceiver"));
280 if (receiver)
281 {
282 MiscGameplayFunctions.TransferItemProperties(detonator, receiver);
283 receiver.LockToParent();
284 explosive.SetTakeable(false);
285 explosive.PairWithDevice(detonator);
286 explosive.Arm();
288 }
289 }
290 }
291
292 override void OnAbort()
294 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
295 if (explosive)
296 {
297 explosive.LockTriggerSlots();
298 explosive.SetTakeable(true);
299 }
300 }
301}
302
304{
307 super.OnSuccess(new_item);
308
309 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
310 if (detonator)
312 if (detonator.GetRemotelyActivatedItemBehaviour())
313 {
314 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
315 if (explosive)
316 explosive.Disarm();
317 }
318 }
319 }
320
321 override void OnAbort()
322 {
323 super.OnAbort();
324
325 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
326 if (detonator)
327 {
328 if (detonator.GetRemotelyActivatedItemBehaviour())
329 {
330 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
331 if (explosive)
332 explosive.LockExplosivesSlots();
333 }
334 }
335 }
336}
ActionAttachExplosivesTriggerCB ActionContinuousBaseCB ActionAttachExplosivesTrigger()
ActionDisarmExplosiveWithRemoteDetonatorCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonator()
ActionDisarmExplosiveWithRemoteDetonatorUnpairedCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonatorUnpaired()
override void OnSuccess(EntityAI new_item)
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void SetActions()
override void EEKilled(Object killer)
const string COLOR_LED_OFF
void UpdateLED(string selection, string color)
string GetDebugText()
void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced=false)
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver()
bool IsKit()
ERemoteDetonatorLEDState m_LastLEDState
override void OnAbort()
ERemoteDetonatorLEDState
@ LIT
@ OFF
const string COLOR_LED_LIT
override void OnWasDetached(EntityAI parent, int slot_id)
const string SELECTION_NAME_LED
ReplaceDetonatorItemLambda ReplaceItemWithNewLambdaBase SetPairDevice(EntityAI device)
class JsonUndergroundAreaTriggerData GetPosition
static int GetEnumSize(typename e)
Return amount of values in enum.
Definition EnConvert.c:620
InventoryLocation.
Definition EnMath.c:7
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
override void SetActions()
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair=null)
override void OnActivatedByItem(notnull ItemBase item)
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
void SetControlledDevice(EntityAI pDevice)
override void OnCEUpdate()
override void OnAnimationPhaseStarted(string animSource, float phase)
override void UnpairRemote()
const string ANIM_PHASE_TRIGGER
ref RemotelyActivatedItemBehaviour m_RAIB
override void PairRemote(notnull EntityAI trigger)
override void OnVariablesSynchronized()
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void OnSuccess(EntityAI new_item)
base class for transformation operations (creating one item from another)
const float EXPLOSIVE_REMOTE_ACTIVATION
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
static proto float SqrFloat(float f)
Returns squared value.