Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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
20 void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced = false)
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
33 m_LastLEDState = pState;
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 {
76 m_RAIB.OnVariableSynchronized();
77 }
78
80 }
81
82 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
83 {
84 super.EEItemLocationChanged(oldLoc, newLoc);
85
86 if (m_RAIB)
87 {
88 m_RAIB.Pair();
89 }
90 }
91
96
97 override void OnCEUpdate()
98 {
99 super.OnCEUpdate();
100
101 if (!IsRuined() && IsConnected() && GetControlledDevice())
102 {
104 {
106
107 return;
108 }
109 }
110
112 }
113
114 override void PairRemote(notnull EntityAI trigger)
115 {
116 m_RAIB.Pair(trigger);
117 }
118
119 override void UnpairRemote()
120 {
122 m_RAIB.Unpair();
123 }
124
125 override void OnActivatedByItem(notnull ItemBase item)
126 {
127 if (g_Game.IsServer())
128 {
129 if (m_RAIB.IsPaired() && !IsRuined())
130 {
131 ItemBase device = ItemBase.Cast(GetControlledDevice());
132 if (device && vector.DistanceSq(GetPosition(), device.GetPosition()) <= Math.SqrFloat(UAMaxDistances.EXPLOSIVE_REMOTE_ACTIVATION))
133 {
134 device.OnActivatedByItem(this);
135 }
136 }
137 }
138 }
139
141 {
142 m_RAIB.Pair(pDevice);
143 }
144
146 {
147 return m_RAIB.IsPaired();
148 }
149
151 {
152 return m_RAIB.GetPairDevice();
153 }
154
155 static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair = null)
156 {
157 string type = "RemoteDetonatorTrigger";
159 PlayerBase player = PlayerBase.Cast(pEntity);
160 if (player)
161 {
162 ItemBase inHandsItem = player.GetItemInHands();
163 if (inHandsItem)
164 {
165 if (deviceToPair)
166 {
167 ReplaceDetonatorItemOnArmLambda onArmLambda = new ReplaceDetonatorItemOnArmLambda(inHandsItem, type);
168 onArmLambda.SetPairDevice(deviceToPair);
169 MiscGameplayFunctions.TurnItemIntoItemEx(player, onArmLambda);
170 }
171 else
172 {
173 ReplaceDetonatorItemLambda lambda = new ReplaceDetonatorItemLambda(inHandsItem, type);
174 MiscGameplayFunctions.TurnItemIntoItemEx(player, lambda);
175 }
176
177
178 rdt = RemoteDetonatorTrigger.Cast(player.GetItemInHands());
179 }
180 else
181 rdt = RemoteDetonatorTrigger.Cast(player.GetHumanInventory().CreateInHands(type));
182
184 if (player.GetItemInHands())
185 player.GetItemAccessor().OnItemInHandsChanged();
186 }
187
188 return rdt;
189 }
190
191 override void OnAnimationPhaseStarted(string animSource, float phase)
192 {
193 if (animSource == ANIM_PHASE_TRIGGER)
194 {
195 if (phase > 0.01)
196 {
198 }
199 }
200 }
201
212
213#ifdef DIAG_DEVELOPER
214 override protected string GetDebugText()
215 {
216 string debug_output;
217 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
218 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
219 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
220 return debug_output;
221 }
222#endif
223}
224
225class RemoteDetonatorReceiver : RemoteDetonator
226{
232 override bool IsKit()
234 return false;
235 }
236
237 override void OnWasDetached(EntityAI parent, int slot_id)
238 {
240 }
241
242 override void EEKilled(Object killer)
243 {
244 super.EEKilled(killer);
245
247 }
248
249 override void SetActions()
251 super.SetActions();
252
255 }
256}
257
259{
260 override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
261 {
262 super.CopyOldPropertiesToNew(old_item, new_item);
263
264 MiscGameplayFunctions.TransferItemProperties(old_item, new_item);
265 }
266}
267
268class ReplaceDetonatorItemOnArmLambda : ReplaceDetonatorItemLambda
269{
270 EntityAI m_PairDevice
271
274 m_PairDevice = device;
275 }
276
277 override void OnSuccess(EntityAI new_item)
278 {
279 super.OnSuccess(new_item);
280
281 RemoteDetonator detonator = RemoteDetonator.Cast(new_item);
282 if (detonator)
283 {
284 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
285 if (explosive)
286 {
287 ItemBase receiver = ItemBase.Cast(explosive.GetInventory().CreateAttachment("RemoteDetonatorReceiver"));
288 if (receiver)
289 {
290 MiscGameplayFunctions.TransferItemProperties(detonator, receiver);
291 receiver.LockToParent();
292 explosive.SetTakeable(false);
293 explosive.PairWithDevice(detonator);
294 explosive.Arm();
295 }
296 }
297 }
298 }
300 override void OnAbort()
301 {
302 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
303 if (explosive)
304 {
305 explosive.LockTriggerSlots();
306 explosive.SetTakeable(true);
307 }
308 }
309}
310
312{
313 override void OnSuccess(EntityAI new_item)
314 {
315 super.OnSuccess(new_item);
316
317 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
318 if (detonator)
319 {
320 if (detonator.GetRemotelyActivatedItemBehaviour())
321 {
322 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
323 if (explosive)
324 {
325 explosive.Disarm();
326 }
327 }
328 }
329 }
331 override void OnAbort()
332 {
333 super.OnAbort();
334
335 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
336 if (detonator)
337 {
338 if (detonator.GetRemotelyActivatedItemBehaviour())
339 {
340 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
341 if (explosive)
342 {
343 explosive.LockExplosivesSlots();
344 }
345 }
346 }
347 }
348}
class LogManager EntityAI
ActionAttachExplosivesTriggerCB ActionContinuousBaseCB ActionAttachExplosivesTrigger()
ActionDisarmExplosiveWithRemoteDetonatorCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonator()
ActionDisarmExplosiveWithRemoteDetonatorUnpairedCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonatorUnpaired()
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void SetActions()
class EconomyOutputStrings OFF
static int GetEnumSize(typename e)
Return amount of values in enum.
Definition enconvert.c:636
InventoryLocation.
Definition enmath.c:7
override void OnCEUpdate()
const string ANIM_PHASE_TRIGGER
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
override void PairRemote(notnull EntityAI trigger)
void SetControlledDevice(EntityAI pDevice)
override void UnpairRemote()
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair=null)
override void OnActivatedByItem(notnull ItemBase item)
ref RemotelyActivatedItemBehaviour m_RAIB
override void OnVariablesSynchronized()
override void OnAnimationPhaseStarted(string animSource, float phase)
override void SetActions()
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void OnSuccess(EntityAI new_item)
void ReplaceItemWithNewLambdaBase(EntityAI old_item, string new_item_type)
void OnAbort()
Step Out - notification on abort.
const float EXPLOSIVE_REMOTE_ACTIVATION
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
DayZGame g_Game
Definition dayzgame.c:3942
override void EEKilled(Object killer)
void ExplosivesBase()
static proto float SqrFloat(float f)
Returns squared value.
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
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
ERemoteDetonatorLEDState
@ LIT
const string COLOR_LED_LIT
override void OnWasDetached(EntityAI parent, int slot_id)
ref RemotelyActivatedItemBehaviour m_RAIB
const string SELECTION_NAME_LED
ReplaceDetonatorItemLambda ReplaceItemWithNewLambdaBase SetPairDevice(EntityAI device)