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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
// *************************************************************************************
// ! DayZPlayerSyncJunctures - sync junctures for dayz player - static functions
// *************************************************************************************
class DayZPlayerSyncJunctures
{
	static const int SJ_DAMAGE_HIT						= 0;
	static const int SJ_INJURY							= 1;
	static const int SJ_ACTION_INTERRUPT				= 2;
	static const int SJ_PLAYER_STATES					= 3;
	static const int SJ_QUICKBAR_SET_SHORTCUT			= 4;
	static const int SJ_INVENTORY						= 5;
	static const int SJ_ACTION_ACK_ACCEPT				= 6;
	static const int SJ_ACTION_ACK_REJECT				= 7;
	static const int SJ_WEAPON_ACTION_ACK_ACCEPT		= 8;
	static const int SJ_WEAPON_ACTION_ACK_REJECT		= 9;
	static const int SJ_WEAPON_SET_JAMMING_CHANCE		= 10;
	static const int SJ_UNCONSCIOUSNESS					= 11;
	static const int SJ_DEATH					     	= 12;
	static const int SJ_PLAYER_FB_MODIFIER				= 13;
	static const int SJ_PLAYER_ADD_MODIFIER				= 14;
	static const int SJ_KURU_REQUEST					= 15;
	static const int SJ_GESTURE_REQUEST					= 16;
	static const int SJ_INVENTORY_REPAIR				= 17;
	static const int SJ_WEAPON_LIFT						= 18;
	static const int SJ_WEAPON_RAISE_COMPLETED			= 19;
	static const int SJ_DELETE_ITEM						= 20;
	static const int SJ_BROKEN_LEGS						= 21;
	static const int SJ_SHOCK							= 22;
	static const int SJ_STAMINA							= 23;
	static const int SJ_STAMINA_MISC					= 24;
	static const int SJ_ADS_RESET						= 25;
	static const int SJ_INVENTORY_FAILURE				= 26;
	#ifdef DEVELOPER
	static const int SJ_DEBUG_GET_IN_CAR				= 200;
	#endif
	
	
	#ifdef DEVELOPER
	//-------------------------------------------------------------
	//!
	//!Get in Car
	//! 

	static void SendGetInCar(DayZPlayer pPlayer, EntityAI car)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(car);
		pPlayer.SendSyncJuncture(SJ_DEBUG_GET_IN_CAR, ctx);
	}
	
	static bool ReadGetInCarParams(ParamsReadContext pCtx, out EntityAI car)
	{
		if (!pCtx.Read(car))
			return false;
		return true;
	}
	#endif
	
	//-------------------------------------------------------------
	//!
	//! Death
	//! 

	static void SendDeath(DayZPlayer pPlayer, int pType, float pHitDir)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		
		ctx.Write(pType);
		ctx.Write(pHitDir);
		pPlayer.SendSyncJuncture(SJ_DEATH, ctx);
	}
	
	static bool ReadDeathParams(ParamsReadContext pCtx, out int pType, out float pHitDir)
	{
		if (!pCtx.Read(pType))
			return false;
		if (!pCtx.Read(pHitDir))
			return false;

		return true;
	}

	//-------------------------------------------------------------
	//!
	//! DamageHit
	//! 

	static void SendDamageHit(DayZPlayer pPlayer, int pType, float pHitDir, bool pFullbody)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		
		ctx.Write(pType);
		ctx.Write(pHitDir);
		ctx.Write(pFullbody);
		pPlayer.SendSyncJuncture(SJ_DAMAGE_HIT, ctx);
	}
	
	static void SendDamageHitEx(DayZPlayer pPlayer, int pType, float pHitDir, bool pFullbody, TotalDamageResult pDamageResult, int pDamageType, EntityAI pSource, string pComponent, string pAmmoType, vector pModelPos)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		SyncHitInfo data = new SyncHitInfo;
		
		data.m_AnimType = pType;
		data.m_HitDir = pHitDir;
		data.m_Fullbody = pFullbody;
		data.m_HasSource = pSource != null;
		if ( !pDamageResult )
		{
			data.m_HealthDamage = -1.0;
		}
		else
		{
			data.m_HealthDamage = pDamageResult.GetHighestDamage("Health");
		}
		
		ctx.Write(data);
		pPlayer.SendSyncJuncture(SJ_DAMAGE_HIT, ctx);
	}
	
	static bool ReadDamageHitParams(ParamsReadContext pCtx, out int pType, out float pHitDir, out bool pFullbody)
	{
		if (!pCtx.Read(pType))
			return false;
		if (!pCtx.Read(pHitDir))
			return false;
		if (!pCtx.Read(pFullbody))
			return false;	
		return true;
	}
	
	static bool ReadDamageHitParamsEx(ParamsReadContext pCtx, out SyncHitInfo pData)
	{
		if (!pCtx.Read(pData))
			return false;
		return true;
	}

	//-------------------------------------------------------------
	//!
	//! Injury
	//! 
	
	static void SendInjury(DayZPlayer pPlayer, bool pEnable, eInjuryHandlerLevels level)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(pEnable);
		ctx.Write(level);

		pPlayer.SendSyncJuncture(SJ_INJURY, ctx);
	}
	
	static bool ReadInjuryParams(ParamsReadContext pCtx, out bool pEnable, out eInjuryHandlerLevels level)
	{
		if ( !pCtx.Read(pEnable) )
			return false; // error		
		if ( !pCtx.Read(level) )
			return false; // error
		
		return true;
	}

	//-------------------------------------------------------------
	//!
	//! Conscious / Unconscious
	//! 
	
	static void SendPlayerUnconsciousness(DayZPlayer pPlayer, bool enable)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;

		ctx.Write(enable);
		
		pPlayer.SendSyncJuncture(SJ_UNCONSCIOUSNESS, ctx);
	}
	
	static bool ReadPlayerUnconsciousnessParams(ParamsReadContext pCtx, out bool enable)
	{
		if ( !pCtx.Read(enable) )
		{
			return false;
		}
		return true;
	}
	
	//-------------------------------------------------------------
	//!
	//! Full body
	//! 
	
	static void SendPlayerFBModifier(PlayerBase pPlayer, int type)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(type);
		
		pPlayer.SendSyncJuncture(SJ_PLAYER_FB_MODIFIER, ctx);
	}
	
	static bool ReadPlayerFBModifier(ParamsReadContext pCtx, out int type)
	{
		if ( !pCtx.Read(type) )
			return false; // error
		return true;
	}
	
	//-------------------------------------------------------------
	//!
	//! Additive Symptoms
	//!
	
	static void SendPlayerSymptomADD(DayZPlayer pPlayer, int type, int state_type)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(state_type);
		ctx.Write(type);


		pPlayer.SendSyncJuncture(SJ_PLAYER_ADD_MODIFIER, ctx);
	}
	
	static bool ReadPlayerSymptomADDParams(ParamsReadContext pCtx, out int type)
	{
		if ( !pCtx.Read(type) )
			return false; // error		
		return true;
	}
	
	
	//-------------------------------------------------------------
	//!
	//! Full body Symptoms
	//! 
	
	static void SendPlayerSymptomFB(DayZPlayer pPlayer, DayZPlayerConstants anim_id, int state_type, int stance_mask, float duration)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(state_type);
		ctx.Write(anim_id);
		ctx.Write(stance_mask);
		ctx.Write(duration);
		//ctx.Write(pPlayer);
		
		pPlayer.SendSyncJuncture(SJ_PLAYER_STATES, ctx);
	}
	
	static bool ReadPlayerSymptomFBParams(ParamsReadContext pCtx, out DayZPlayerConstants anim_id, out int stance_mask, out float duration)
	{
		if ( !pCtx.Read(anim_id) )
			return false; // error
		if ( !pCtx.Read(stance_mask) )
			return false; // error
		if ( !pCtx.Read(duration) )
			return false; // error
		//if ( !pCtx.Read(pPlayer) )
			//return false; // error
		return true;
	}


	//-------------------------------------------------------------
	//!
	//! Action interrupt
	//! 
	
	static void SendActionInterrupt(DayZPlayer pPlayer)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		pPlayer.SendSyncJuncture(SJ_ACTION_INTERRUPT, ctx);
	}
	
	static bool ReadActionInterruptParams(ParamsReadContext pCtx)
	{		
		return true;
	}
	
	//-------------------------------------------------------------
	//!
	//! Action Acknowledgment
	//! 
	static void SendActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(AckID);
		if (accept)
			pPlayer.SendSyncJuncture(SJ_ACTION_ACK_ACCEPT, ctx);
		else
			pPlayer.SendSyncJuncture(SJ_ACTION_ACK_REJECT, ctx);
	}
	
	
	static void SendWeaponActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(AckID);
		if (accept)
			pPlayer.SendSyncJuncture(SJ_WEAPON_ACTION_ACK_ACCEPT, ctx);
		else
			pPlayer.SendSyncJuncture(SJ_WEAPON_ACTION_ACK_REJECT, ctx);
	}
		
	//-------------------------------------------------------------
	//!
	//! Kuru Disease Shake
	//! 
	
	static bool ReadKuruRequest(ParamsReadContext pCtx, out float amount)
	{
		if ( !pCtx.Read(amount) )
			return false; // error		
		return true;
	}
	
	static void SendKuruRequest(DayZPlayer pPlayer, float amount)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(amount);
		pPlayer.SendSyncJuncture(SJ_KURU_REQUEST, ctx);
	}
	
	//-------------------------------------------------------------
	//!
	//! Quickbar
	//! 
	
	static void SendQuickbarSetShortcut(DayZPlayer pPlayer, EntityAI item, int index, bool force = false )
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(item);
		ctx.Write(index);
		ctx.Write(force);

		pPlayer.SendSyncJuncture(SJ_QUICKBAR_SET_SHORTCUT, ctx);
	}
	
	static void SendWeaponJamChance(DayZPlayer pPlayer, float jamChance )
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(jamChance);

		pPlayer.SendSyncJuncture(SJ_WEAPON_SET_JAMMING_CHANCE, ctx);
	}

	/*static bool ReadQuickbarSetShortcut(ParamsReadContext pCtx, out EntityAI item, out int index)
	{	
		Param2<EntityAI,int> shortcutParam = new Param2<EntityAI,int>(NULL,-1);
		if( pCtx.Read(shortcutParam))
		{
			item = shortcutParam.param1;
			index = shortcutParam.param2;
			return true;	
		}

		return false;
	}*/
	
	static void SendDeleteItem( DayZPlayer pPlayer, EntityAI item )
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(item);

		pPlayer.SendSyncJuncture(SJ_DELETE_ITEM, ctx);
	}
	
	
	//-------------------------------------------------------------
	//!
	//! BrokenLegs
	//! 
	
	static void SendBrokenLegs(DayZPlayer pPlayer, bool canPlaySound, eBrokenLegs currentState, eBrokenLegs localState)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(canPlaySound);
		ctx.Write(currentState);
		ctx.Write(localState);

		pPlayer.SendSyncJuncture(SJ_BROKEN_LEGS, ctx);
	}
	
	static bool ReadBrokenLegsParams(ParamsReadContext pCtx, out bool canPlaySound, out eBrokenLegs currentState, out eBrokenLegs localState)
	{
		if ( !pCtx.Read(canPlaySound) )
			return false; // error		
		if ( !pCtx.Read(currentState) )
			return false; // error
		if ( !pCtx.Read(localState) )
			return false;
		
		return true;
	}
	
	static void SendBrokenLegsEx(DayZPlayer pPlayer, int currentState)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(currentState);

		pPlayer.SendSyncJuncture(SJ_BROKEN_LEGS, ctx);
	}
	
	static bool ReadBrokenLegsParamsEx(ParamsReadContext pCtx, out int currentState)
	{
		if ( !pCtx.Read(currentState) )
			return false;
		
		return true;
	}
	
	//-------------------------------------------------------------
	//!
	//! Shock
	//! 
	
	static void SendShock(DayZPlayer pPlayer, float shockValue)
	{
		ScriptJunctureData ctx = new ScriptJunctureData;
		ctx.Write(shockValue);

		pPlayer.SendSyncJuncture(SJ_SHOCK, ctx);
	}
	
	static bool ReadShockParams(ParamsReadContext pCtx, out float shockValue)
	{
		if ( !pCtx.Read(shockValue) )
			return false; // error
		
		return true;
	}
}