Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzplayersyncjunctures.c
Go to the documentation of this file.
1 // *************************************************************************************
2 // ! DayZPlayerSyncJunctures - sync junctures for dayz player - static functions
3 // *************************************************************************************
5 {
6  static const int SJ_DAMAGE_HIT = 0;
7  static const int SJ_INJURY = 1;
8  static const int SJ_ACTION_INTERRUPT = 2;
9  static const int SJ_PLAYER_STATES = 3;
10  static const int SJ_QUICKBAR_SET_SHORTCUT = 4;
11  static const int SJ_INVENTORY = 5;
12  static const int SJ_ACTION_ACK_ACCEPT = 6;
13  static const int SJ_ACTION_ACK_REJECT = 7;
14  static const int SJ_WEAPON_ACTION_ACK_ACCEPT = 8;
15  static const int SJ_WEAPON_ACTION_ACK_REJECT = 9;
16  static const int SJ_WEAPON_SET_JAMMING_CHANCE = 10;
17  static const int SJ_UNCONSCIOUSNESS = 11;
18  static const int SJ_DEATH = 12;
19  static const int SJ_PLAYER_FB_MODIFIER = 13;
20  static const int SJ_PLAYER_ADD_MODIFIER = 14;
21  static const int SJ_KURU_REQUEST = 15;
22  static const int SJ_GESTURE_REQUEST = 16;
23  static const int SJ_INVENTORY_REPAIR = 17;
24  static const int SJ_WEAPON_LIFT = 18;
25  static const int SJ_WEAPON_RAISE_COMPLETED = 19;
26  static const int SJ_DELETE_ITEM = 20;
27  static const int SJ_BROKEN_LEGS = 21;
28  static const int SJ_SHOCK = 22;
29  static const int SJ_STAMINA = 23;
30  static const int SJ_STAMINA_MISC = 24;
31  static const int SJ_ADS_RESET = 25;
32  static const int SJ_INVENTORY_FAILURE = 26;
33  #ifdef DEVELOPER
34  static const int SJ_DEBUG_GET_IN_CAR = 200;
35  #endif
36 
37 
38  #ifdef DEVELOPER
39  //-------------------------------------------------------------
43 
44  static void SendGetInCar(DayZPlayer pPlayer, EntityAI car)
45  {
47  ctx.Write(car);
48  pPlayer.SendSyncJuncture(SJ_DEBUG_GET_IN_CAR, ctx);
49  }
50 
51  static bool ReadGetInCarParams(ParamsReadContext pCtx, out EntityAI car)
52  {
53  if (!pCtx.Read(car))
54  return false;
55  return true;
56  }
57  #endif
58 
59  //-------------------------------------------------------------
63 
64  static void SendDeath(DayZPlayer pPlayer, int pType, float pHitDir)
65  {
67 
68  ctx.Write(pType);
69  ctx.Write(pHitDir);
70  pPlayer.SendSyncJuncture(SJ_DEATH, ctx);
71  }
72 
73  static bool ReadDeathParams(ParamsReadContext pCtx, out int pType, out float pHitDir)
74  {
75  if (!pCtx.Read(pType))
76  return false;
77  if (!pCtx.Read(pHitDir))
78  return false;
79 
80  return true;
81  }
82 
83  //-------------------------------------------------------------
87 
88  static void SendDamageHit(DayZPlayer pPlayer, int pType, float pHitDir, bool pFullbody)
89  {
91 
92  ctx.Write(pType);
93  ctx.Write(pHitDir);
94  ctx.Write(pFullbody);
95  pPlayer.SendSyncJuncture(SJ_DAMAGE_HIT, ctx);
96  }
97 
98  static void SendDamageHitEx(DayZPlayer pPlayer, int pType, float pHitDir, bool pFullbody, TotalDamageResult pDamageResult, int pDamageType, EntityAI pSource, string pComponent, string pAmmoType, vector pModelPos)
99  {
101  SyncHitInfo data = new SyncHitInfo;
102 
103  data.m_AnimType = pType;
104  data.m_HitDir = pHitDir;
105  data.m_Fullbody = pFullbody;
106  data.m_HasSource = pSource != null;
107  if ( !pDamageResult )
108  {
109  data.m_HealthDamage = -1.0;
110  }
111  else
112  {
113  data.m_HealthDamage = pDamageResult.GetHighestDamage("Health");
114  }
115 
116  ctx.Write(data);
117  pPlayer.SendSyncJuncture(SJ_DAMAGE_HIT, ctx);
118  }
119 
120  static bool ReadDamageHitParams(ParamsReadContext pCtx, out int pType, out float pHitDir, out bool pFullbody)
121  {
122  if (!pCtx.Read(pType))
123  return false;
124  if (!pCtx.Read(pHitDir))
125  return false;
126  if (!pCtx.Read(pFullbody))
127  return false;
128  return true;
129  }
130 
131  static bool ReadDamageHitParamsEx(ParamsReadContext pCtx, out SyncHitInfo pData)
132  {
133  if (!pCtx.Read(pData))
134  return false;
135  return true;
136  }
137 
138  //-------------------------------------------------------------
142 
143  static void SendInjury(DayZPlayer pPlayer, bool pEnable, eInjuryHandlerLevels level)
144  {
146  ctx.Write(pEnable);
147  ctx.Write(level);
148 
149  pPlayer.SendSyncJuncture(SJ_INJURY, ctx);
150  }
151 
152  static bool ReadInjuryParams(ParamsReadContext pCtx, out bool pEnable, out eInjuryHandlerLevels level)
153  {
154  if ( !pCtx.Read(pEnable) )
155  return false; // error
156  if ( !pCtx.Read(level) )
157  return false; // error
158 
159  return true;
160  }
161 
162  //-------------------------------------------------------------
166 
167  static void SendPlayerUnconsciousness(DayZPlayer pPlayer, bool enable)
168  {
170 
171  ctx.Write(enable);
172 
173  pPlayer.SendSyncJuncture(SJ_UNCONSCIOUSNESS, ctx);
174  }
175 
176  static bool ReadPlayerUnconsciousnessParams(ParamsReadContext pCtx, out bool enable)
177  {
178  if ( !pCtx.Read(enable) )
179  {
180  return false;
181  }
182  return true;
183  }
184 
185  //-------------------------------------------------------------
189 
190  static void SendPlayerFBModifier(PlayerBase pPlayer, int type)
191  {
193  ctx.Write(type);
194 
195  pPlayer.SendSyncJuncture(SJ_PLAYER_FB_MODIFIER, ctx);
196  }
197 
198  static bool ReadPlayerFBModifier(ParamsReadContext pCtx, out int type)
199  {
200  if ( !pCtx.Read(type) )
201  return false; // error
202  return true;
203  }
204 
205  //-------------------------------------------------------------
209 
210  static void SendPlayerSymptomADD(DayZPlayer pPlayer, int type, int state_type)
211  {
213  ctx.Write(state_type);
214  ctx.Write(type);
215 
216 
217  pPlayer.SendSyncJuncture(SJ_PLAYER_ADD_MODIFIER, ctx);
218  }
219 
220  static bool ReadPlayerSymptomADDParams(ParamsReadContext pCtx, out int type)
221  {
222  if ( !pCtx.Read(type) )
223  return false; // error
224  return true;
225  }
226 
227 
228  //-------------------------------------------------------------
232 
233  static void SendPlayerSymptomFB(DayZPlayer pPlayer, DayZPlayerConstants anim_id, int state_type, int stance_mask, float duration)
234  {
236  ctx.Write(state_type);
237  ctx.Write(anim_id);
238  ctx.Write(stance_mask);
239  ctx.Write(duration);
240  //ctx.Write(pPlayer);
241 
242  pPlayer.SendSyncJuncture(SJ_PLAYER_STATES, ctx);
243  }
244 
245  static bool ReadPlayerSymptomFBParams(ParamsReadContext pCtx, out DayZPlayerConstants anim_id, out int stance_mask, out float duration)
246  {
247  if ( !pCtx.Read(anim_id) )
248  return false; // error
249  if ( !pCtx.Read(stance_mask) )
250  return false; // error
251  if ( !pCtx.Read(duration) )
252  return false; // error
253  //if ( !pCtx.Read(pPlayer) )
254  //return false; // error
255  return true;
256  }
257 
258 
259  //-------------------------------------------------------------
263 
264  static void SendActionInterrupt(DayZPlayer pPlayer)
265  {
267  pPlayer.SendSyncJuncture(SJ_ACTION_INTERRUPT, ctx);
268  }
269 
270  static bool ReadActionInterruptParams(ParamsReadContext pCtx)
271  {
272  return true;
273  }
274 
275  //-------------------------------------------------------------
279  static void SendActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
280  {
282  ctx.Write(AckID);
283  if (accept)
284  pPlayer.SendSyncJuncture(SJ_ACTION_ACK_ACCEPT, ctx);
285  else
286  pPlayer.SendSyncJuncture(SJ_ACTION_ACK_REJECT, ctx);
287  }
288 
289 
290  static void SendWeaponActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
291  {
293  ctx.Write(AckID);
294  if (accept)
295  pPlayer.SendSyncJuncture(SJ_WEAPON_ACTION_ACK_ACCEPT, ctx);
296  else
297  pPlayer.SendSyncJuncture(SJ_WEAPON_ACTION_ACK_REJECT, ctx);
298  }
299 
300  //-------------------------------------------------------------
304 
305  static bool ReadKuruRequest(ParamsReadContext pCtx, out float amount)
306  {
307  if ( !pCtx.Read(amount) )
308  return false; // error
309  return true;
310  }
311 
312  static void SendKuruRequest(DayZPlayer pPlayer, float amount)
313  {
315  ctx.Write(amount);
316  pPlayer.SendSyncJuncture(SJ_KURU_REQUEST, ctx);
317  }
318 
319  //-------------------------------------------------------------
323 
324  static void SendQuickbarSetShortcut(DayZPlayer pPlayer, EntityAI item, int index, bool force = false )
325  {
327  ctx.Write(item);
328  ctx.Write(index);
329  ctx.Write(force);
330 
331  pPlayer.SendSyncJuncture(SJ_QUICKBAR_SET_SHORTCUT, ctx);
332  }
333 
334  static void SendWeaponJamChance(DayZPlayer pPlayer, float jamChance )
335  {
337  ctx.Write(jamChance);
338 
339  pPlayer.SendSyncJuncture(SJ_WEAPON_SET_JAMMING_CHANCE, ctx);
340  }
341 
342  /*static bool ReadQuickbarSetShortcut(ParamsReadContext pCtx, out EntityAI item, out int index)
343  {
344  Param2<EntityAI,int> shortcutParam = new Param2<EntityAI,int>(NULL,-1);
345  if( pCtx.Read(shortcutParam))
346  {
347  item = shortcutParam.param1;
348  index = shortcutParam.param2;
349  return true;
350  }
351 
352  return false;
353  }*/
354 
355  static void SendDeleteItem( DayZPlayer pPlayer, EntityAI item )
356  {
358  ctx.Write(item);
359 
360  pPlayer.SendSyncJuncture(SJ_DELETE_ITEM, ctx);
361  }
362 
363 
364  //-------------------------------------------------------------
368 
369  static void SendBrokenLegs(DayZPlayer pPlayer, bool canPlaySound, eBrokenLegs currentState, eBrokenLegs localState)
370  {
372  ctx.Write(canPlaySound);
373  ctx.Write(currentState);
374  ctx.Write(localState);
375 
376  pPlayer.SendSyncJuncture(SJ_BROKEN_LEGS, ctx);
377  }
378 
379  static bool ReadBrokenLegsParams(ParamsReadContext pCtx, out bool canPlaySound, out eBrokenLegs currentState, out eBrokenLegs localState)
380  {
381  if ( !pCtx.Read(canPlaySound) )
382  return false; // error
383  if ( !pCtx.Read(currentState) )
384  return false; // error
385  if ( !pCtx.Read(localState) )
386  return false;
387 
388  return true;
389  }
390 
391  static void SendBrokenLegsEx(DayZPlayer pPlayer, int currentState)
392  {
394  ctx.Write(currentState);
395 
396  pPlayer.SendSyncJuncture(SJ_BROKEN_LEGS, ctx);
397  }
398 
399  static bool ReadBrokenLegsParamsEx(ParamsReadContext pCtx, out int currentState)
400  {
401  if ( !pCtx.Read(currentState) )
402  return false;
403 
404  return true;
405  }
406 
407  //-------------------------------------------------------------
411 
412  static void SendShock(DayZPlayer pPlayer, float shockValue)
413  {
415  ctx.Write(shockValue);
416 
417  pPlayer.SendSyncJuncture(SJ_SHOCK, ctx);
418  }
419 
420  static bool ReadShockParams(ParamsReadContext pCtx, out float shockValue)
421  {
422  if ( !pCtx.Read(shockValue) )
423  return false; // error
424 
425  return true;
426  }
427 }
DayZPlayer
Definition: dayzplayerimplement.c:72
ScriptJunctureData
Definition: gameplay.c:150
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
TotalDamageResult
Definition: damagesystem.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
DayZPlayerSyncJunctures
Definition: dayzplayersyncjunctures.c:4
eInjuryHandlerLevels
eInjuryHandlerLevels
Definition: injuryhandler.c:18
EntityAI
Definition: building.c:5