Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
events.c
Go to the documentation of this file.
1 
6 {
28 };
29 
30 
35 {
36  int m_eventID;
37  DayZPlayer m_player;
38  Magazine m_magazine;
39 
40  void WeaponEventBase (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = 0; m_player = p; m_magazine = m; }
42  WeaponEventID GetEventID () { return m_eventID; }
44  WeaponEvents GetAnimEvent () { return -1; }
46  int GetPackedType ()
47  {
48  int animEvent = GetAnimEvent() & 0x0000ffff;
49  int evShl = m_eventID << 16;
50  return evShl | animEvent;
51  }
52 
53  void ReadFromContext (ParamsReadContext ctx) { }
54  void WriteToContext (ParamsWriteContext ctx)
55  {
56  int packedType = GetPackedType();
57  ctx.Write(packedType);
58  ctx.Write(m_player);
59  ctx.Write(m_magazine);
60  }
61 
62  string DumpToString ()
63  {
64  string res = "{ WpnEv id=" + typename.EnumToString(WeaponEventID, GetEventID());
65  res = res + " pl=" + Object.GetDebugName(m_player);
66  res = res + " mag=" + Object.GetDebugName(m_magazine);
67  res = res + " }";
68  return res;
69  }
70 };
71 
74 class WeaponEventMechanism extends WeaponEventBase
75 {
76  void WeaponEventMechanism (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.MECHANISM; }
77 };
80 class WeaponEventTrigger extends WeaponEventBase
81 {
82  void WeaponEventTrigger (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.TRIGGER; }
83 };
86 class WeaponEventTriggerToJam extends WeaponEventBase
87 {
88  void WeaponEventTriggerToJam (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.TRIGGER_JAM; }
89 };
92 class WeaponEventTriggerAutoStart extends WeaponEventBase
93 {
94  void WeaponEventTriggerAutoStart (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.TRIGGER_AUTO_START; }
95 };
98 class WeaponEventTriggerAutoEnd extends WeaponEventBase
99 {
100  void WeaponEventTriggerAutoEnd (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.TRIGGER_AUTO_END; }
101 };
104 class WeaponEventLoad1Bullet extends WeaponEventBase
105 {
106  void WeaponEventLoad1Bullet (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.LOAD1_BULLET; }
107 };
110 class WeaponEventContinuousLoadBulletStart extends WeaponEventBase
111 {
112  void WeaponEventContinuousLoadBulletStart (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.CONTINUOUS_LOADBULLET_START; }
113 };
116 class WeaponEventContinuousLoadBulletEnd extends WeaponEventBase
117 {
118  void WeaponEventContinuousLoadBulletEnd (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.CONTINUOUS_LOADBULLET_END; }
119 };
122 class WeaponEventUnjam extends WeaponEventBase
123 {
124  void WeaponEventUnjam (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.UNJAM; }
125 };
128 class WeaponEventAttachMagazine extends WeaponEventBase
129 {
130  void WeaponEventAttachMagazine (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.ATTACH_MAGAZINE; }
131 };
134 class WeaponEventUnjammingFailedTimeout extends WeaponEventBase
135 {
136  void WeaponEventUnjammingFailedTimeout (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.UNJAMMING_FAILED_TIMEOUT; }
137 };
140 class WeaponEventUnjammingTimeout extends WeaponEventBase
141 {
142  void WeaponEventUnjammingTimeout (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.UNJAMMING_TIMEOUT; }
143 };
147 class WeaponEventDetachMagazine extends WeaponEventBase
148 {
150  void WeaponEventDetachMagazine (DayZPlayer p = NULL, Magazine m = NULL, InventoryLocation il = NULL) { m_eventID = WeaponEventID.DETACH_MAGAZINE; m_dst = il; }
151 
152  override void ReadFromContext (ParamsReadContext ctx)
153  {
154  m_dst = new InventoryLocation;
155  super.ReadFromContext(ctx);
156  m_dst.ReadFromContext(ctx);
157  }
158  override void WriteToContext (ParamsWriteContext ctx)
159  {
160  super.WriteToContext(ctx);
161  m_dst.WriteToContext(ctx);
162  }
163 };
166 class WeaponEventSwapMagazine extends WeaponEventBase
167 {
169  void WeaponEventSwapMagazine (DayZPlayer p = NULL, Magazine m = NULL, InventoryLocation il = NULL){ m_eventID = WeaponEventID.SWAP_MAGAZINE;m_dst = il; }
170 
171  override void ReadFromContext (ParamsReadContext ctx)
172  {
173  super.ReadFromContext(ctx);
174  m_dst = new InventoryLocation;
175  m_dst.ReadFromContext(ctx);
176  }
177  override void WriteToContext (ParamsWriteContext ctx)
178  {
179  super.WriteToContext(ctx);
180  m_dst.WriteToContext(ctx);
181  }
182 };
185 class WeaponEventHumanCommandActionFinished extends WeaponEventBase
186 {
187  void WeaponEventHumanCommandActionFinished (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.HUMANCOMMAND_ACTION_FINISHED; }
188 };
191 class WeaponEventHumanCommandActionAborted extends WeaponEventBase
192 {
193  void WeaponEventHumanCommandActionAborted (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.HUMANCOMMAND_ACTION_ABORTED; }
194 };
197 class WeaponEventReloadTimeout extends WeaponEventBase
198 {
199  void WeaponEventReloadTimeout (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.RELOAD_TIMEOUT; }
200 };
203 class WeaponEventDryFireTimeout extends WeaponEventBase
204 {
205  void WeaponEventDryFireTimeout (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.DRY_FIRE_TIMEOUT; }
206 };
207 
210 class WeaponEventSetNextMuzzleMode extends WeaponEventBase
211 {
212  void WeaponEventSetNextMuzzleMode (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.SET_NEXT_MUZZLE_MODE; }
213 };
214 
216 {
217  WeaponEvents m_type;
218  void WeaponEventAnimation (DayZPlayer p = NULL, Magazine m = NULL) { m_eventID = WeaponEventID.ANIMATION_EVENT; }
219  override int GetAnimEvent () { return m_type; }
220 };
221 
223 WeaponEventBase WeaponEventFactory (WeaponEventID id, int aetype, DayZPlayer p = NULL, Magazine m = NULL)
224 {
225  switch (id)
226  {
227  case WeaponEventID.UNKNOWN: return null;
228  case WeaponEventID.MECHANISM: return new WeaponEventMechanism(p, m);
229  case WeaponEventID.TRIGGER: return new WeaponEventTrigger(p, m);
230  case WeaponEventID.TRIGGER_JAM: return new WeaponEventTriggerToJam(p, m);
231  case WeaponEventID.LOAD1_BULLET: return new WeaponEventLoad1Bullet(p, m);
232  case WeaponEventID.CONTINUOUS_LOADBULLET_START: return new WeaponEventContinuousLoadBulletStart(p, m);
233  case WeaponEventID.CONTINUOUS_LOADBULLET_END: return new WeaponEventContinuousLoadBulletEnd(p, m);
234  case WeaponEventID.UNJAM: return new WeaponEventUnjam(p, m);
235  case WeaponEventID.ATTACH_MAGAZINE: return new WeaponEventAttachMagazine(p, m);
236  case WeaponEventID.UNJAMMING_FAILED_TIMEOUT: return new WeaponEventUnjammingFailedTimeout(p, m);
237  case WeaponEventID.UNJAMMING_TIMEOUT: return new WeaponEventUnjammingTimeout(p, m);
238  case WeaponEventID.DETACH_MAGAZINE: return new WeaponEventDetachMagazine(p, m);
239  case WeaponEventID.SWAP_MAGAZINE: return new WeaponEventSwapMagazine(p, m);
240  case WeaponEventID.HUMANCOMMAND_ACTION_FINISHED: return new WeaponEventHumanCommandActionFinished(p, m);
241  case WeaponEventID.HUMANCOMMAND_ACTION_ABORTED: return new WeaponEventHumanCommandActionAborted(p, m);
242  case WeaponEventID.RELOAD_TIMEOUT: return new WeaponEventReloadTimeout(p, m);
243  case WeaponEventID.DRY_FIRE_TIMEOUT: return new WeaponEventDryFireTimeout(p, m);
244  case WeaponEventID.SET_NEXT_MUZZLE_MODE: return new WeaponEventSetNextMuzzleMode(p, m);
245  case WeaponEventID.ANIMATION_EVENT: return WeaponAnimEventFactory(aetype, p, m);
246  }
247  return NULL;
248 }
249 
252 {
253  switch (type)
254  {
255  case WeaponEvents.ATTACHMENT_HIDE: return new WeaponEventAnimAttachmentHide(p, m);
256  case WeaponEvents.ATTACHMENT_SHOW: return new WeaponEventAnimAttachmentShow(p, m);
257  case WeaponEvents.BULLET_EJECT: return new WeaponEventAnimBulletEject(p, m);
258  case WeaponEvents.BULLET_HIDE: return new WeaponEventAnimBulletHide(p, m);
259  case WeaponEvents.BULLET_HIDE2: return new WeaponEventAnimBulletHide2(p, m);
260  case WeaponEvents.BULLET_IN_CHAMBER: return new WeaponEventAnimBulletInChamber(p, m);
261  case WeaponEvents.BULLET_IN_MAGAZINE: return new WeaponEventAnimBulletInMagazine(p, m);
262  case WeaponEvents.BULLET_SHOW: return new WeaponEventAnimBulletShow(p, m);
263  case WeaponEvents.BULLET_SHOW2: return new WeaponEventAnimBulletShow2(p, m);
264  case WeaponEvents.CANUNJAM_END: return new WeaponEventAnimCanUnjamEnd(p, m);
265  case WeaponEvents.CANUNJAM_START: return new WeaponEventAnimCanUnjamStart(p, m);
266  case WeaponEvents.COCKED: return new WeaponEventAnimCocked(p, m);
267  case WeaponEvents.MAGAZINE_ATTACHED: return new WeaponEventAnimMagazineAttached(p, m);
268  case WeaponEvents.MAGAZINE_DETACHED: return new WeaponEventAnimMagazineDetached(p, m);
269  case WeaponEvents.MAGAZINE_HIDE: return new WeaponEventAnimMagazineHide(p, m);
270  case WeaponEvents.MAGAZINE_SHOW: return new WeaponEventAnimMagazineShow(p, m);
271  case WeaponEvents.SLIDER_OPEN: return new WeaponEventAnimSliderOpen(p, m);
272  case WeaponEvents.UNJAMMED: return new WeaponEventAnimUnjammed(p, m);
273  case WeaponEvents.HAMMER_UNCOCKED: return new WeaponEventAnimHammerUncocked(p, m);
274  case WeaponEvents.HAMMER_COCKED: return new WeaponEventAnimHammerCocked(p, m);
275  case WeaponEvents.CYLINDER_ROTATE: return new WeaponEventCylinderRotate(p, m);
276  //case WeaponEvents.: return new WeaponEventAnim(p, m);
277  }
278  return NULL;
279 }
280 
282 {
283  int packedType;
284  ctx.Read(packedType);
285  DayZPlayer player;
286  ctx.Read(player);
287  Magazine magazine;
288  ctx.Read(magazine);
289 
290  WeaponEventID eventID = packedType >> 16;
291  WeaponEvents animEvent = packedType & 0x0000ffff;
292  WeaponEventBase b = WeaponEventFactory(eventID, animEvent, player, magazine);
293  b.ReadFromContext(ctx);
294  return b;
295 }
296 
297 class WeaponEventAnimAttachmentHide extends WeaponEventAnimation
298 {
299  void WeaponEventAnimAttachmentHide (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.ATTACHMENT_HIDE; }
300 };
301 
302 class WeaponEventAnimAttachmentShow extends WeaponEventAnimation
303 {
304  void WeaponEventAnimAttachmentShow (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.ATTACHMENT_SHOW; }
305 };
306 
307 class WeaponEventAnimBulletEject extends WeaponEventAnimation
308 {
309  void WeaponEventAnimBulletEject (DayZPlayer p = NULL, Magazine m = NULL)
310  {
311  m_type = WeaponEvents.BULLET_EJECT;
312 
313  // Particles for ejecting bullet casings
314  PlayerBase player = PlayerBase.Cast(p);
315 
316  if (player)
317  {
318  ItemBase weapon = player.GetItemInHands();
319 
320  if (weapon && weapon.GetOverheatingValue() > 0)
321  {
322  Weapon_Base weapon_base = Weapon_Base.Cast(weapon);
323  ItemBase suppressor;
324 
325  if (weapon_base)
326  suppressor = weapon_base.GetAttachedSuppressor();
327 
328  ItemBase.PlayBulletCasingEjectParticles(weapon, "", weapon, suppressor, "CfgWeapons" );
329  }
330  }
331  }
332 };
333 
334 class WeaponEventCylinderRotate extends WeaponEventAnimation
335 {
336  void WeaponEventCylinderRotate (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.CYLINDER_ROTATE; }
337 };
338 
339 class WeaponEventAnimBulletHide extends WeaponEventAnimation
340 {
341  void WeaponEventAnimBulletHide (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.BULLET_HIDE; }
342 };
343 
344 class WeaponEventAnimBulletHide2 extends WeaponEventAnimation
345 {
346  void WeaponEventAnimBulletHide2 (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.BULLET_HIDE2; }
347 };
348 
349 class WeaponEventAnimBulletInChamber extends WeaponEventAnimation
350 {
351  void WeaponEventAnimBulletInChamber (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.BULLET_IN_CHAMBER; }
352 };
353 
354 class WeaponEventAnimBulletInMagazine extends WeaponEventAnimation
355 {
356  void WeaponEventAnimBulletInMagazine (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.BULLET_IN_MAGAZINE; }
357 };
358 
359 class WeaponEventAnimBulletShow extends WeaponEventAnimation
360 {
361  void WeaponEventAnimBulletShow (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.BULLET_SHOW; }
362 };
363 
364 class WeaponEventAnimBulletShow2 extends WeaponEventAnimation
365 {
366  void WeaponEventAnimBulletShow2 (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.BULLET_SHOW2; }
367 };
368 
369 class WeaponEventAnimCanUnjamEnd extends WeaponEventAnimation
370 {
371  void WeaponEventAnimCanUnjamEnd (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.CANUNJAM_END; }
372 };
373 
374 class WeaponEventAnimCanUnjamStart extends WeaponEventAnimation
375 {
376  void WeaponEventAnimCanUnjamStart (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.CANUNJAM_START; }
377 };
378 
379 class WeaponEventAnimCocked extends WeaponEventAnimation
380 {
381  void WeaponEventAnimCocked (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.COCKED; }
382 };
383 
384 class WeaponEventAnimMagazineAttached extends WeaponEventAnimation
385 {
386  void WeaponEventAnimMagazineAttached (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.MAGAZINE_ATTACHED; }
387 };
388 
389 class WeaponEventAnimMagazineDetached extends WeaponEventAnimation
390 {
391  void WeaponEventAnimMagazineDetached (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.MAGAZINE_DETACHED; }
392 };
393 
394 class WeaponEventAnimMagazineHide extends WeaponEventAnimation
395 {
396  void WeaponEventAnimMagazineHide (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.MAGAZINE_HIDE; }
397 };
398 
399 class WeaponEventAnimMagazineShow extends WeaponEventAnimation
400 {
401  void WeaponEventAnimMagazineShow (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.MAGAZINE_SHOW; }
402 };
403 
404 class WeaponEventAnimSliderOpen extends WeaponEventAnimation
405 {
406  void WeaponEventAnimSliderOpen (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.SLIDER_OPEN; }
407 };
408 
409 class WeaponEventAnimUnjammed extends WeaponEventAnimation
410 {
411  void WeaponEventAnimUnjammed (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.UNJAMMED; }
412 };
413 
414 
415 class WeaponEventAnimHammerUncocked extends WeaponEventAnimation
416 {
417  void WeaponEventAnimHammerUncocked (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.HAMMER_UNCOCKED; }
418 };
419 
420 class WeaponEventAnimHammerCocked extends WeaponEventAnimation
421 {
422  void WeaponEventAnimHammerCocked (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.HAMMER_COCKED; }
423 };
424 
425 /*
426 class WeaponEventAnim extends WeaponEventAnimation
427 {
428  void WeaponEventAnim (DayZPlayer p = NULL, Magazine m = NULL) { m_type = WeaponEvents.; }
429 };
430 */
ItemBase
Definition: inventoryitem.c:730
TRIGGER
@ TRIGGER
Definition: events.c:9
ReadFromContext
void ReadFromContext(ParamsReadContext ctx)
Definition: hand_events.c:70
m_player
DayZPlayer m_player
Definition: randomgeneratorsyncmanager.c:15
TRIGGER_JAM
@ TRIGGER_JAM
Definition: events.c:10
m_dst
ref InventoryLocation m_dst
Definition: dayzplayerinventory.c:13
ATTACH_MAGAZINE
@ ATTACH_MAGAZINE
Definition: events.c:17
RELOAD_TIMEOUT
@ RELOAD_TIMEOUT
Definition: events.c:24
UNJAMMING_TIMEOUT
@ UNJAMMING_TIMEOUT
Definition: events.c:19
WriteToContext
void WriteToContext(ParamsWriteContext ctx)
Definition: hand_events.c:72
ANIMATION_EVENT
@ ANIMATION_EVENT
Definition: events.c:27
LOAD1_BULLET
@ LOAD1_BULLET
Definition: events.c:13
WeaponEventID
WeaponEventID
identifier for events. mainly for rpc purposes
Definition: events.c:5
SET_NEXT_MUZZLE_MODE
@ SET_NEXT_MUZZLE_MODE
Definition: events.c:26
SWAP_MAGAZINE
@ SWAP_MAGAZINE
Definition: events.c:21
CreateWeaponEventFromContext
WeaponEventBase CreateWeaponEventFromContext(ParamsReadContext ctx)
Definition: events.c:281
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
WeaponEvents
WeaponEvents
events
Definition: human.c:955
WeaponEventFactory
WeaponEventBase WeaponEventFactory(WeaponEventID id, int aetype, DayZPlayer p=NULL, Magazine m=NULL)
creates weapon fsm events
Definition: events.c:223
WeaponAnimEventFactory
WeaponEventBase WeaponAnimEventFactory(WeaponEvents type, DayZPlayer p=NULL, Magazine m=NULL)
creates animation system events
Definition: events.c:251
TRIGGER_AUTO_START
@ TRIGGER_AUTO_START
Definition: events.c:11
DayZPlayer
Definition: dayzplayerimplement.c:72
UNJAMMING_FAILED_TIMEOUT
@ UNJAMMING_FAILED_TIMEOUT
Definition: events.c:18
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
DETACH_MAGAZINE
@ DETACH_MAGAZINE
Definition: events.c:20
PlayerBase
Definition: playerbaseclient.c:1
DRY_FIRE_TIMEOUT
@ DRY_FIRE_TIMEOUT
Definition: events.c:25
CONTINUOUS_LOADBULLET_END
@ CONTINUOUS_LOADBULLET_END
Definition: events.c:15
TRIGGER_AUTO_END
@ TRIGGER_AUTO_END
Definition: events.c:12
UNJAM
@ UNJAM
Definition: events.c:16
Object
Definition: objecttyped.c:1
HUMANCOMMAND_ACTION_ABORTED
@ HUMANCOMMAND_ACTION_ABORTED
Definition: events.c:23
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
WeaponEventAnimation
Definition: events.c:297
HUMANCOMMAND_ACTION_FINISHED
@ HUMANCOMMAND_ACTION_FINISHED
Definition: events.c:22
CONTINUOUS_LOADBULLET_START
@ CONTINUOUS_LOADBULLET_START
Definition: events.c:14
MECHANISM
@ MECHANISM
Definition: events.c:8
UNKNOWN
@ UNKNOWN
Definition: events.c:7