DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
RemoteDetonator.c
Go to the documentation of this file.
2{
3 OFF = 0,
5}
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 {
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 {
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
93 {
94 return m_RAIB;
95 }
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 (GetGame().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
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 ReplaceItemWithNewLambdaBase lambda = new ReplaceDetonatorItemLambda(inHandsItem, type);
166 MiscGameplayFunctions.TurnItemIntoItemEx(player, lambda);
167 rdt = RemoteDetonatorTrigger.Cast(player.GetItemInHands());
168 }
169 else
170 {
171 rdt = RemoteDetonatorTrigger.Cast(player.GetHumanInventory().CreateInHands(type));
172 }
173
175 if (player.GetItemInHands())
176 {
177 player.GetItemAccessor().OnItemInHandsChanged();
178 }
179 }
180
181 return rdt;
182 }
183
184 override void OnAnimationPhaseStarted(string animSource, float phase)
185 {
186 if (animSource == ANIM_PHASE_TRIGGER)
187 {
188 if (phase > 0.01)
189 {
191 }
192 }
193 }
194
195 override void SetActions()
196 {
197 super.SetActions();
198
200
204 }
205
206#ifdef DIAG_DEVELOPER
207 override protected string GetDebugText()
208 {
209 string debug_output;
210 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
211 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
212 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
213 return debug_output;
214 }
215#endif
216}
217
218class RemoteDetonatorReceiver : RemoteDetonator
219{
225 override bool IsKit()
227 return false;
228 }
229
230 override void OnWasDetached(EntityAI parent, int slot_id)
231 {
233 }
234
235 override void EEKilled(Object killer)
236 {
237 super.EEKilled(killer);
238
240 }
241
242 override void SetActions()
244 super.SetActions();
245
248 }
249}
250
252{
253 override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
254 {
255 super.CopyOldPropertiesToNew(old_item, new_item);
256
257 MiscGameplayFunctions.TransferItemProperties(old_item, new_item);
258 }
259}
ActionAttachExplosivesTriggerCB ActionContinuousBaseCB ActionAttachExplosivesTrigger()
ActionDisarmExplosiveWithRemoteDetonatorCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonator()
ActionDisarmExplosiveWithRemoteDetonatorUnpairedCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonatorUnpaired()
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void SetActions()
override void EEKilled(Object killer)
const string COLOR_LED_OFF
protected void UpdateLED(string selection, string color)
string GetDebugText()
void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced=false)
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver()
bool IsKit()
ERemoteDetonatorLEDState
@ LIT
@ OFF
const string COLOR_LED_LIT
override void OnWasDetached(EntityAI parent, int slot_id)
const string SELECTION_NAME_LED
protected ERemoteDetonatorLEDState m_LastLEDState
class JsonUndergroundAreaTriggerData GetPosition
static int GetEnumSize(typename e)
Return amount of values in enum.
Definition EnConvert.c:623
override void SetActions()
Definition Mace.c:3
InventoryLocation.
Definition EnMath.c:7
override void OnCEUpdate()
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity)
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
protected const string ANIM_PHASE_TRIGGER
override void PairRemote(notnull EntityAI trigger)
void SetControlledDevice(EntityAI pDevice)
override void UnpairRemote()
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
override void OnActivatedByItem(notnull ItemBase item)
override void OnVariablesSynchronized()
protected ref RemotelyActivatedItemBehaviour m_RAIB
override void OnAnimationPhaseStarted(string animSource, float phase)
override void SetActions()
override void CopyOldPropertiesToNew(notnull EntityAI old_item, 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.
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.