DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Hand_Guards.c
См. документацию.
1
2
7{
14 bool GuardCondition(HandEventBase e) { return true; }
15};
16
17
18class HandGuardAnd extends HandGuardBase
19{
22
23 void HandGuardAnd(HandGuardBase arg0 = null, HandGuardBase arg1 = null) { m_arg0 = arg0; m_arg1 = arg1; }
24
26 {
27 bool result = m_arg0.GuardCondition(e) && m_arg1.GuardCondition(e);
28
29 #ifdef ENABLE_LOGGING
31 {
32 Debug.InventoryHFSMLog("GuardCondition result: " + result + " - " + m_arg0.Type() + " && " + m_arg1.Type(), "HandGuardAnd" , "n/a", "GuardCondition", e.m_Player.ToString() );
33 }
34 #endif
35
36 return result;
37 }
38};
39
40class HandGuardNot extends HandGuardBase
41{
42 ref HandGuardBase m_arg0;
43
44 void HandGuardNot(HandGuardBase arg0 = null) { m_arg0 = arg0; }
45
47 {
48 bool result = !m_arg0.GuardCondition(e);
49
50 #ifdef ENABLE_LOGGING
52 {
53 Debug.InventoryHFSMLog("GuardCondition result: " + result + " - " + m_arg0.Type(), "HandGuardNot" , "n/a", "GuardCondition", e.m_Player.ToString() );
54 }
55 #endif
56 return result;
57 }
58};
59
60class HandGuardOr extends HandGuardBase
61{
62 ref HandGuardBase m_arg0;
63 ref HandGuardBase m_arg1;
64
65 void HandGuardOr(HandGuardBase arg0 = null, HandGuardBase arg1 = null) { m_arg0 = arg0; m_arg1 = arg1; }
66
68 {
69 bool result = m_arg0.GuardCondition(e) || m_arg1.GuardCondition(e);
70
71 #ifdef ENABLE_LOGGING
73 {
74 Debug.InventoryHFSMLog("GuardCondition result: " + result + " - " + m_arg0.Type() + " || " + m_arg1.Type(), "HandGuardOr" , "n/a", "GuardCondition", e.m_Player.ToString() );
75 }
76 #endif
77 return result;
78 }
79};
80
82{
83 protected Man m_Player;
84 void HandGuardHasItemInEvent(Man p = null) { m_Player = p; }
85
87 {
88 EntityAI eai = e.GetSrcEntity();
89 if (eai != NULL /* && CanTakeInHands*/)
90 {
91 #ifdef ENABLE_LOGGING
93 {
94 Debug.InventoryHFSMLog("GuardCondition result: true - " + eai, "HandGuardHasItemInEvent" , "n/a", "GuardCondition", m_Player.ToString() );
95 }
96 #endif
97 return true;
98 }
99
100 #ifdef ENABLE_LOGGING
102 {
103 Debug.InventoryHFSMLog("GuardCondition result: false - " + eai, "HandGuardHasItemInEvent" , "n/a", "GuardCondition", m_Player.ToString() );
104 }
105 #endif
106
107 return false;
108 }
109};
110
111class HandGuardHasWeaponInEvent extends HandGuardHasItemInEvent
112{
113 void HandGuardHasWeapoonInEvent (Man p = null) { }
114
116 {
117 EntityAI eai = e.GetSrcEntity();
118 bool result = false;
119 if (eai)
120 {
121 if (eai.IsWeapon())
122 {
123 result = true;
124 }
125 }
126 #ifdef ENABLE_LOGGING
128 {
129 Debug.InventoryHFSMLog("GuardCondition result: " + result,"HandGuardHasWeaponInEvent", "n/a", "GuardCondition", e.m_Player.ToString() );
130 }
131 #endif
132 return result;
133 }
134};
135
136class HandGuardIsSameItemInHands extends HandGuardBase
137{
138 protected Man m_Player;
139 void HandGuardIsSameItemInHands(Man p = null) { m_Player = p; }
140
142 {
143 bool result = false;
144 if (e.GetSrcEntity() == m_Player.GetHumanInventory().GetEntityInHands())
145 {
146 result = true;
147 }
148
149 #ifdef ENABLE_LOGGING
151 {
152 Debug.InventoryHFSMLog("GuardCondition result: " + result + " - srcItem = " + e.GetSrcEntity() + " hnd= " + m_Player.GetHumanInventory().GetEntityInHands(), "HandGuardIsSameItemInHands" , "n/a", "GuardCondition", e.m_Player.ToString() );
153 }
154 #endif
155 return result;
156 }
157};
158
159class HandGuardHasDestroyedItemInHands extends HandGuardBase
160{
161 protected Man m_Player;
162 void HandGuardHasDestroyedItemInHands(Man p = null) { m_Player = p; }
163
165 {
166 EntityAI hnd = m_Player.GetHumanInventory().GetEntityInHands();
167 if (e.GetSrcEntity())
168 {
169 if (e.GetSrcEntity() == hnd)
170 {
171 #ifdef ENABLE_LOGGING
173 {
174 Debug.InventoryHFSMLog("GuardCondition result: true - has same entity in hands " + hnd, "HandGuardHasDestroyedItemInHands" , "n/a", "GuardCondition", m_Player.ToString() );
175 }
176 #endif
177 return true;
178 }
179
180 if (hnd == null)
181 {
182 #ifdef ENABLE_LOGGING
184 {
185 Debug.InventoryHFSMLog("GuardCondition result: true - hands already empty", "HandGuardHasDestroyedItemInHands" , "n/a", "GuardCondition", m_Player.ToString() );
186 }
187 #endif
188 return true;
189 }
190 }
191 else
192 {
193 #ifdef ENABLE_LOGGING
195 {
196 Debug.InventoryHFSMLog("GuardCondition result: true - hands already empty and item destroyed", "HandGuardHasDestroyedItemInHands" , "n/a", "GuardCondition", m_Player.ToString() );
197 }
198 #endif
199 return true;
200 }
201 #ifdef ENABLE_LOGGING
203 {
204 Debug.InventoryHFSMLog("GuardCondition result: false - destroyed entity not in hands", "HandGuardHasDestroyedItemInHands" , "n/a", "GuardCondition", m_Player.ToString() );
205 }
206 #endif
207 return false;
208 }
209};
210
211class HandGuardHasItemInHands extends HandGuardBase
212{
213 protected Man m_Player;
214 void HandGuardHasItemInHands(Man p = null) { m_Player = p; }
215
217 {
218 bool result = false;
219 if (m_Player.GetHumanInventory().GetEntityInHands())
220 {
221 result = true;
222 }
223
224 #ifdef ENABLE_LOGGING
226 {
227 Debug.InventoryHFSMLog("GuardCondition result: " + result + " - " + m_Player.GetHumanInventory().GetEntityInHands(), "HandGuardHasItemInHands" , "n/a", "GuardCondition", m_Player.ToString() );
228 }
229 #endif
230 return result;
231 }
232};
233
235class HandGuardHasRoomForItem extends HandGuardBase
236{
237 protected Man m_Player;
238 void HandGuardHasRoomForItem(Man p = null) { m_Player = p; }
239
241 {
242 if (e.GetDst() && e.GetDst().IsValid())
243 {
244 if ( !GetGame().IsDedicatedServer())
245 {
246 if (m_Player)
247 m_Player.GetHumanInventory().ClearInventoryReservationEx(e.GetDst().GetItem(),e.GetDst());
248 }
249
250 if (!GameInventory.LocationTestAddEntity(e.GetDst(), false, true, true, true, true, false))
251 {
252 #ifdef ENABLE_LOGGING
254 {
255 Debug.InventoryHFSMLog("GuardCondition result: false - no room at dst=" + InventoryLocation.DumpToStringNullSafe(e.GetDst()), "HandGuardHasRoomForItem" , "n/a", "GuardCondition", m_Player.ToString() );
256 }
257 #endif
258 //if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] HandGuardHasRoomForItem - no room at dst=" + InventoryLocation.DumpToStringNullSafe(e.GetDst()));
259 //Error("[hndfsm] HandGuardHasRoomForItem - no room at dst=" + InventoryLocation.DumpToStringNullSafe(e.GetDst()));
260 return false;
261 }
262
263
264 if ( !GetGame().IsDedicatedServer())
265 {
266 if (m_Player)
267 m_Player.GetHumanInventory().AddInventoryReservationEx(e.GetDst().GetItem(), e.GetDst(), GameInventory.c_InventoryReservationTimeoutShortMS);
268 }
269
270 #ifdef ENABLE_LOGGING
272 {
273 Debug.InventoryHFSMLog("GuardCondition result: true", "HandGuardHasRoomForItem" , "n/a", "GuardCondition", m_Player.ToString() );
274 }
275 #endif
276 return true;
277 }
278
279 #ifdef ENABLE_LOGGING
281 {
282 Debug.InventoryHFSMLog("GuardCondition result: false - e.m_Dst is null", "HandGuardHasRoomForItem" , "n/a", "GuardCondition", m_Player.ToString() );
283 }
284 #endif
285
286 return false;
287 }
288};
289
290class HandGuardCanMove extends HandGuardBase
291{
292 protected Man m_Player;
293 void HandGuardCanMove(Man p = null) { m_Player = p; }
294
296 {
297 HandEventMoveTo es = HandEventMoveTo.Cast(e);
298
299 bool result = e.m_IsJuncture || e.m_IsRemote;
300 if (result == false)
301 {
302 result = GameInventory.LocationCanMoveEntity(es.GetSrc(), es.GetDst());
303 }
304
305 #ifdef ENABLE_LOGGING
307 {
308 Debug.InventoryHFSMLog("GuardCondition result: " + result, "HandGuardCanMove" , "n/a", "GuardCondition", m_Player.ToString() );
309 }
310 #endif
311
312 return result;
313 }
314};
315
316class HandGuardCanSwap extends HandGuardBase
317{
318 protected Man m_Player;
319 void HandGuardCanSwap(Man p = NULL) { m_Player = p; }
320
322 {
323 HandEventSwap es = HandEventSwap.Cast(e);
324
325 bool result = e.m_IsJuncture || e.m_IsRemote;
326 if (result == false)
327 {
328 result = GameInventory.CanSwapEntitiesEx(es.GetSrc().GetItem(), es.m_Src2.GetItem());
329 }
330
331 #ifdef ENABLE_LOGGING
333 {
334 Debug.InventoryHFSMLog("GuardCondition result: " + result, "HandGuardCanSwap" , "n/a", "GuardCondition", m_Player.ToString() );
335 }
336 #endif
337 //if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] HandGuardCanSwap guard - cannot swap");
338 return result;
339 }
340};
341
342class HandGuardCanForceSwap extends HandGuardBase
343{
344 protected Man m_Player;
345 void HandGuardCanForceSwap(Man p = NULL) { m_Player = p; }
346
348 {
349 HandEventForceSwap es = HandEventForceSwap.Cast(e);
350
351 bool result = e.m_IsJuncture || e.m_IsRemote;
352 if (result == false)
353 {
354 result = GameInventory.CanSwapEntitiesEx(es.GetSrc().GetItem(), es.m_Src2.GetItem());
355
356 if (result == false && es.m_Dst2)
357 {
358 result = GameInventory.CanForceSwapEntitiesEx(es.GetSrc().GetItem(), es.m_Dst, es.m_Src2.GetItem(), es.m_Dst2);
359 }
360 }
361
362 #ifdef ENABLE_LOGGING
364 {
365 Debug.InventoryHFSMLog("GuardCondition result: " + result, "HandGuardCanForceSwap" , "n/a", "GuardCondition", m_Player.ToString() );
366 }
367 #endif
368
369 return result;
370 }
371};
372
373class HandGuardInstantForceSwap extends HandGuardBase
374{
375 protected Man m_Player;
376 void HandGuardInstantForceSwap(Man p = NULL) { m_Player = p; }
377
379 {
380 HandEventForceSwap es = HandEventForceSwap.Cast(e);
381
382 InventoryLocation src1 = es.m_Src;
383 InventoryLocation dst2 = es.m_Dst2;
384
385 bool result = false;
386 if (src1.GetType() == InventoryLocationType.CARGO && dst2.GetType() == InventoryLocationType.CARGO)
387 {
388 if (src1.GetParent() == dst2.GetParent())
389 {
390 result = true;
391 }
392 }
393
394 #ifdef ENABLE_LOGGING
396 {
397 Debug.InventoryHFSMLog("GuardCondition result: " + result, "HandGuardInstantForceSwap" , "n/a", "GuardCondition", m_Player.ToString() );
398 }
399 #endif
400
401 return result;
402 }
403};
404
406
DayZPlayer m_Player
Определения Hand_Events.c:42
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
static void InventoryHFSMLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения Debug.c:147
Определения Debug.c:2
Определения Building.c:6
static proto native bool LocationTestAddEntity(notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
test if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
const int c_InventoryReservationTimeoutShortMS
Определения Inventory.c:713
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Определения Inventory.c:628
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Определения Inventory.c:664
script counterpart to engine's class Inventory
Определения Inventory.c:79
override InventoryLocation GetDst()
Определения Hand_Events.c:212
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:209
Определения Hand_Events.c:679
ref HandGuardBase m_arg0
Определения Hand_Guards.c:20
void HandGuardIsSameItemInHands(Man p=null)
Определения Hand_Guards.c:139
Man m_Player
Определения Hand_Guards.c:83
void HandGuardInstantForceSwap(Man p=NULL)
Определения Hand_Guards.c:376
ref HandGuardBase m_arg1
Определения Hand_Guards.c:21
void HandGuardCanMove(Man p=null)
Определения Hand_Guards.c:293
void HandGuardHasRoomForItem(Man p=null)
Определения Hand_Guards.c:238
void HandGuardCanSwap(Man p=NULL)
Определения Hand_Guards.c:319
void HandGuardHasDestroyedItemInHands(Man p=null)
Определения Hand_Guards.c:162
void HandGuardNot(HandGuardBase arg0=null)
Определения Hand_Guards.c:44
void HandGuardOr(HandGuardBase arg0=null, HandGuardBase arg1=null)
Определения Hand_Guards.c:65
void HandGuardHasItemInEvent(Man p=null)
Определения Hand_Guards.c:84
void HandGuardCanForceSwap(Man p=NULL)
Определения Hand_Guards.c:345
void HandGuardAnd(HandGuardBase arg0=null, HandGuardBase arg1=null)
Определения Hand_Guards.c:23
bool GuardCondition(HandEventBase e)
Определения Hand_Guards.c:14
void HandGuardHasItemInHands(Man p=null)
Определения Hand_Guards.c:214
override bool GuardCondition(HandEventBase e)
Определения Hand_Guards.c:25
TODO(kumarjac): This guard is unused but it has a fault and doesn't conform with maximimal/minimal ch...
Определения Hand_Guards.c:7
void HandGuardHasWeapoonInEvent(Man p=null)
Определения Hand_Guards.c:113
override bool GuardCondition(HandEventBase e)
Определения Hand_Guards.c:115
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:226
proto native int GetType()
returns type of InventoryLocation
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
static bool IsInventoryHFSMLogEnable()
Определения Debug.c:668
Определения Debug.c:594
proto native CGame GetGame()