Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzplayermeleefightlogic_lightheavy.c
Go to the documentation of this file.
3 {
4  EVADE = 0
5 }
6 
8 {
10  const float EVADE_COOLDOWN = 0.5;
11 
12  //
13  const float CLOSE_TARGET_DISTANCE = 1.5;
14 
16  const string DUMMY_LIGHT_AMMO = "Dummy_Light";
17  const string DUMMY_HEAVY_AMMO = "Dummy_Heavy";
18 
19  protected PlayerBase m_Player;
23  protected Mission m_Mission;
24 
25  protected bool m_IsInBlock;
26  protected bool m_IsEvading;
27 
28  protected bool m_IsInComboRange;
29  protected bool m_WasPreviousHitProcessed;
30 
32  {
33  Init(player);
34  }
35 
37  {
38  m_DZPlayer = player;
39  m_Player = PlayerBase.Cast(player);
40  m_MeleeCombat = m_Player.GetMeleeCombat();
41  m_Mission = GetGame().GetMission();
42 
43  m_IsInBlock = false;
44  m_IsEvading = false;
46  m_HitType = EMeleeHitType.NONE;
47 
49  }
50 
52 
53  bool IsInBlock()
54  {
55  return m_IsInBlock;
56  }
57 
58  void SetBlock(bool block)
59  {
60  m_IsInBlock = block;
61  }
62 
63  bool IsEvading()
64  {
65  return m_IsEvading;
66  }
67 
69  {
70  return m_HitType;
71  }
72 
73  bool CanFight()
74  {
75  if (m_Player.IsEmotePlaying())
76  return false;
77 
78  if (m_Player.GetActionManager() && m_Player.GetActionManager().GetRunningAction())
79  return false;
80 
81  return true;
82  }
83 
84  protected void RegisterCooldowns()
85  {
88  }
89 
91  {
92  if (pInputs.IsMeleeFastAttackModifier() && m_Player.CanConsumeStamina(EStaminaConsumers.MELEE_HEAVY))
93  {
94  return EMeleeHitType.HEAVY;
95  }
96 
97  return EMeleeHitType.LIGHT;
98  }
99 
101  {
102  if (!m_Player.CanConsumeStamina(EStaminaConsumers.MELEE_HEAVY))
103  {
104  return EMeleeHitType.NONE;
105  }
106 
108  if (pEntity.HasBayonetAttached())
109  {
110  return EMeleeHitType.WPN_STAB;
111  }
112  else if (pEntity.HasButtstockAttached())
113  {
114  return EMeleeHitType.WPN_HIT_BUTTSTOCK;
115  }
116 
117  return EMeleeHitType.WPN_HIT;
118  }
119 
120  protected float GetAttackTypeByDistanceToTarget(EntityAI pTarget, EMeleeTargetType pTargetType = EMeleeTargetType.ALIGNABLE)
121  {
122  if (pTargetType == EMeleeTargetType.NONALIGNABLE)
123  {
124  return 1.0;
125  }
126 
128  if (IsShortDistance(pTarget, Math.SqrFloat(CLOSE_TARGET_DISTANCE)))
129  {
130  return 1.0;
131  }
132 
134  return 0.0;
135  }
136 
137  bool HandleFightLogic(int pCurrentCommandID, HumanInputController pInputs, EntityAI pEntityInHands, HumanMovementState pMovementState, out bool pContinueAttack)
138  {
139  HumanInventoryWithFSM invFSM = HumanInventoryWithFSM.Cast(m_Player.GetHumanInventory());
140  if (invFSM && !invFSM.IsIdle())
141  return false;
142 
143  HumanCommandMove hcm = m_Player.GetCommand_Move();
144  InventoryItem itemInHands = InventoryItem.Cast(pEntityInHands);
145  bool isFireWeapon = itemInHands && itemInHands.IsWeapon();
146 
148  if (HandleHitEvent(pCurrentCommandID, pInputs, itemInHands, pMovementState, pContinueAttack))
149  return false;
150 
152  if ((pInputs.IsAttackButtonDown() && !isFireWeapon) || (pInputs.IsMeleeWeaponAttack() && isFireWeapon) || (pContinueAttack && isFireWeapon))
153  {
154  //Debug.MeleeLog(m_Player, string.Format("HandleFightLogic[1] attackButtonDown=%1, meleeWeaponAttack=%2, pContinueAttack=%3, isFireWeapon=%4", pInputs.IsAttackButtonDown(), pInputs.IsMeleeWeaponAttack(), pContinueAttack, isFireWeapon));
155 
157  if (m_IsInBlock || m_IsEvading)
158  return false;
159 
161  if (itemInHands && !itemInHands.IsMeleeWeapon() && !isFireWeapon)
162  return false;
163 
165  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE)
166  {
167  //Debug.MeleeLog(m_Player, "HandleFightLogic[1a]");
169  if (isFireWeapon)
170  {
171  return HandleInitialFirearmMelee(pCurrentCommandID, pInputs, itemInHands, pMovementState, pContinueAttack);
172  }
173  else
174  {
176  if (pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
177  {
178  return HandleInitialMeleeErc(pCurrentCommandID, pInputs, itemInHands, pMovementState, pContinueAttack);
179  }
181  else if (pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
182  {
183  return HandleProneKick(pCurrentCommandID, pInputs, itemInHands, pMovementState, pContinueAttack);
184  }
186  else if (pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT && m_Player.IsSprintFull())
187  {
188  return HandleSprintAttack(pCurrentCommandID, pInputs, itemInHands, pMovementState, pContinueAttack);
189  }
190  }
191  }
193  else if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_MELEE2)
194  {
195  m_IsInComboRange = m_Player.GetCommand_Melee2().IsInComboRange();
196  if (m_IsInComboRange)
197  {
198  return HandleComboHit(pCurrentCommandID, pInputs, itemInHands, pMovementState, pContinueAttack);
199  }
200  }
201  }
203  else if (!isFireWeapon && pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE)
204  {
206  if (pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
207  {
208  int roll = pInputs.IsMeleeLREvade();
209  if (roll != 0)
210  {
212  if (!m_Player.CanConsumeStamina(EStaminaConsumers.MELEE_EVADE))
213  {
214  return false;
215  }
216 
217  float angle;
218  if (roll == 1)
219  {
220  angle = -90; // left
221  }
222  else
223  {
224  angle = 90; // right
225  }
226 
227  // start melee evade
228  m_IsEvading = true;
230  hcm.StartMeleeEvadeA(angle);
231  m_Player.DepleteStamina(EStaminaModifiers.MELEE_EVADE);
232 
233  //Inflict shock when sidestepping with broken legs
234  if (m_Player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
235  {
236  m_Player.m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_LIGHT_MELEE_SHOCK);
237  m_Player.m_ShockHandler.CheckValue(true);
238  }
239  }
240  }
241 
243  if (pInputs.IsWeaponRaised() && pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH)
244  {
245  //Debug.MeleeLog(m_Player, "HandleFightLogic[2b]");
246  if (DayZPlayerUtils.PlayerCanChangeStance(m_Player, DayZPlayerConstants.STANCEIDX_RAISEDERECT))
247  {
248  //Debug.MeleeLog(m_Player, "HandleFightLogic[2c]");
249  hcm.ForceStance(DayZPlayerConstants.STANCEIDX_RAISEDERECT);
250 
251  return false;
252  }
253  }
254 
257  if (!isFireWeapon && (pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT || pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE))
258  {
259  float angle2;
260 
261  if (hcm.GetCurrentInputAngle(angle2) && (angle2 < -130.0 || angle2 > 130))
262  {
263  hcm.SetMeleeBlock(true);
264  SetBlock(true);
265  }
266  else
267  {
268  hcm.SetMeleeBlock(false);
269  SetBlock(false);
270  }
271  }
272  else
273  {
274  hcm.SetMeleeBlock(false);
275  SetBlock(false);
276  }
277  }
278 
279  return false;
280  }
281 
283  protected bool HandleHitEvent(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
284  {
286  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_MELEE2)
287  {
288  HumanCommandMelee2 hmc2a = m_Player.GetCommand_Melee2();
289  if (hmc2a)
290  {
292  if (hmc2a.WasHit())
293  {
294  //Debug.MeleeLog(m_Player, "HandleHitEvent[START]");
295  //Debug.MeleeLog(m_Player, string.Format("HandleHitEvent[1] target=%1, hitPos=%2, hitZoneIdx=%3, finisherType=%4", m_MeleeCombat.GetTargetEntity(), m_MeleeCombat.GetHitPos().ToString(), m_MeleeCombat.GetHitZoneIdx(), m_MeleeCombat.GetFinisherType()));
296  if (m_MeleeCombat.GetFinisherType() == -1)
297  {
298  //Debug.MeleeLog(m_Player, string.Format("HandleHitEvent[2] target=%1, hitPos=%2, hitZoneIdx=%3, finisherType=%4", m_MeleeCombat.GetTargetEntity(), m_MeleeCombat.GetHitPos().ToString(), m_MeleeCombat.GetHitZoneIdx(), m_MeleeCombat.GetFinisherType()));
300  m_MeleeCombat.Update(itemInHands, m_HitType, true);
301  }
302 
304  EvaluateHit(itemInHands);
305 
306  //Get gloves
307  ClothingBase gloves;
308  if (m_HitType == EMeleeHitType.KICK)
309  {
310  //We kick so "gloves" will be the shoes
311  gloves = ClothingBase.Cast(m_Player.GetItemOnSlot("FEET"));
312  }
313  else
314  {
315  gloves = ClothingBase.Cast(m_Player.GetItemOnSlot("GLOVES"));
316  }
317 
318  //If we hit something, inflict damage
319  DamageHands(m_Player, gloves, itemInHands);
320 
321  m_MeleeCombat.ResetTarget();
322 
323  EnableControls();
324 
326 
327  //Debug.MeleeLog(m_Player, "HandleHitEvent[END]");
328 
329  return true;
330  }
331  }
332  }
333 
334  return false;
335  }
336 
338  protected bool HandleInitialFirearmMelee(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
339  {
341  Weapon_Base weapon = Weapon_Base.Cast(itemInHands);
342  if (weapon.IsWaitingForActionFinish())
343  return false;
344 
345  HumanCommandMove hcm = m_Player.GetCommand_Move();
346 
348  if (hcm.GetCurrentMovementSpeed() <= 2.05 && (pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT || pContinueAttack) && !m_Player.IsFighting())
349  {
351  if ( m_HitType == EMeleeHitType.NONE )
352  return false;
353 
354  m_MeleeCombat.Update(itemInHands, m_HitType);
355 
356  EntityAI target;
357  EMeleeTargetType targetType;
358  GetTargetData(target, targetType);
359  float attackByDistance = GetAttackTypeByDistanceToTarget(target, targetType);
360 
361  m_Player.StartCommand_Melee2(target, m_HitType == EMeleeHitType.WPN_STAB, attackByDistance, m_MeleeCombat.GetHitPos());
362  m_Player.DepleteStamina(EStaminaModifiers.MELEE_HEAVY);
363  DisableControls();
364 
365  pContinueAttack = false; // reset continueAttack flag
366 
367  return true;
368  }
370  else if ( pMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH )
371  {
372  if (hcm)
373  {
374  hcm.ForceStance(DayZPlayerConstants.STANCEIDX_RAISEDERECT);
375  pContinueAttack = true;
376  return false;
377  }
378  }
379 
380  return false;
381  }
382 
384  protected bool HandleInitialMeleeErc(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
385  {
386  //Debug.MeleeLog(m_Player, "HandleInitialMeleeErc[1]");
387 
389  m_MeleeCombat.Update(itemInHands, m_HitType);
390 
391  //Debug.MeleeLog(m_Player, string.Format("HandleInitialMeleeErc[2] %1", EnumTools.EnumToString(EMeleeHitType, m_HitType)));
392 
393  EntityAI target;
394  EMeleeTargetType targetType;
395  GetTargetData(target, targetType);
396  float attackByDistance = GetAttackTypeByDistanceToTarget(target, targetType);
397 
398  // finisher attack hittype override
399  int finisherType = m_MeleeCombat.GetFinisherType();
400  if (finisherType != -1)
401  {
402  int animationType = DetermineFinisherAnimation(finisherType);
403  if (animationType > -1)
404  {
405  //Debug.MeleeLog(m_Player, string.Format("HandleInitialMeleeErc[3a] target=%1, finisherType=%2, animationType=%3, hitPositionWS=%4", target, finisherType, animationType, m_MeleeCombat.GetHitPos().ToString()));
406  m_Player.StartCommand_Melee2(target, animationType, attackByDistance, m_MeleeCombat.GetHitPos());
407  }
408  else
409  {
410  //Debug.MeleeLog(m_Player, string.Format("HandleInitialMeleeErc[3b] target=%1, finisherType=%2, animationType=%3, hitPositionWS=%4", target, finisherType, (m_HitType == EMeleeHitType.HEAVY).ToString(), m_MeleeCombat.GetHitPos().ToString()));
411  m_Player.StartCommand_Melee2(target, m_HitType == EMeleeHitType.HEAVY, attackByDistance, m_MeleeCombat.GetHitPos());
412  }
413 
414  m_HitType = finisherType;
415  target.SetBeingBackstabbed(finisherType);
416  }
417  else
418  {
419  //Debug.MeleeLog(m_Player, string.Format("HandleInitialMeleeErc[3d] target=%1, animationType=%2, hitPositionWS=%3", target, (m_HitType == EMeleeHitType.HEAVY).ToString(), m_MeleeCombat.GetHitPos().ToString()));
420  m_Player.StartCommand_Melee2(target, m_HitType == EMeleeHitType.HEAVY, attackByDistance, m_MeleeCombat.GetHitPos());
421  }
422 
423  if (m_HitType == EMeleeHitType.HEAVY)
424  {
425  m_Player.DepleteStamina(EStaminaModifiers.MELEE_HEAVY);
426  if (m_Player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
427  {
428  m_Player.m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_HEAVY_MELEE_SHOCK);
429  m_Player.m_ShockHandler.CheckValue(true);
430  }
431  }
432  else
433  {
434  m_Player.DepleteStamina(EStaminaModifiers.MELEE_LIGHT);
435  if (m_Player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
436  {
437  m_Player.m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_LIGHT_MELEE_SHOCK);
438  m_Player.m_ShockHandler.CheckValue(true);
439  }
440  }
441 
443 
444  DisableControls();
445 
446  return true;
447  }
448 
450  protected bool HandleProneKick(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
451  {
452  HumanCommandWeapons hcw = m_Player.GetCommandModifier_Weapons();
453 
454  float hcw_angle = hcw.GetBaseAimingAngleLR();
457  if ( ( hcw_angle < -90 || hcw_angle > 90 ) && m_Player.GetBrokenLegs() != eBrokenLegs.BROKEN_LEGS )
458  {
459  // targetting
460  m_HitType = EMeleeHitType.KICK;
461  m_MeleeCombat.Update(itemInHands, m_HitType);
462 
463  EntityAI target;
464  EMeleeTargetType targetType;
465  GetTargetData(target, targetType);
466  float attackByDistance = GetAttackTypeByDistanceToTarget(target, targetType);
467 
468  // command
469  m_Player.StartCommand_Melee2(target, false, attackByDistance, m_MeleeCombat.GetHitPos());
470  m_Player.DepleteStamina(EStaminaModifiers.MELEE_HEAVY);
471  DisableControls();
472 
473  return true;
474  }
475 
476  return false;
477  }
478 
480  protected bool HandleSprintAttack(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
481  {
483  m_HitType = EMeleeHitType.SPRINT;
484  m_MeleeCombat.Update(itemInHands, m_HitType);
485 
486  EntityAI target;
487  EMeleeTargetType targetType;
488  GetTargetData(target, targetType);
489  float attackByDistance = GetAttackTypeByDistanceToTarget(target, targetType);
490 
492  //Debug.MeleeLog(m_Player, string.Format("HandleSprintAttack[1] target=%1, animationType=%2, hitPositionWS=%3", target, false, m_MeleeCombat.GetHitPos().ToString()));
493  m_Player.StartCommand_Melee2(target, false, attackByDistance, m_MeleeCombat.GetHitPos());
494  m_Player.DepleteStamina(EStaminaModifiers.MELEE_HEAVY);
495  DisableControls();
496 
497  return true;
498  }
499 
501  protected bool HandleComboHit(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
502  {
503  //Debug.MeleeLog(m_Player, "HandleComboHit::");
504 
506  if (m_HitType == EMeleeHitType.NONE)
507  return false;
508 
510  if (m_MeleeCombat.GetFinisherType() > -1)
511  return false;
512 
513  EntityAI target;
514  EMeleeTargetType targetType;
515  GetTargetData(target, targetType);
516  float attackByDistance = GetAttackTypeByDistanceToTarget(target, targetType);
517 
519  if (itemInHands && itemInHands.IsWeapon())
520  {
522  }
523  else
524  {
526  }
527 
529  //Debug.MeleeLog(m_Player, string.Format("HandleComboHit:: %1", EnumTools.EnumToString(EMeleeHitType, m_HitType)));
532  {
533  m_MeleeCombat.Update(itemInHands, m_HitType);
534  }
535 
537  bool isHeavy = (m_HitType == EMeleeHitType.HEAVY || m_HitType == EMeleeHitType.WPN_STAB);
538  m_Player.GetCommand_Melee2().ContinueCombo(isHeavy, attackByDistance, target, m_MeleeCombat.GetHitPos());
539  DisableControls();
540 
542  if (m_Player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
543  {
544  float shock = PlayerConstants.BROKEN_LEGS_HEAVY_MELEE_SHOCK;
545 
546  if (!isHeavy)
547  shock = PlayerConstants.BROKEN_LEGS_LIGHT_MELEE_SHOCK;
548 
549  m_Player.m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_HEAVY_MELEE_SHOCK);
550  m_Player.m_ShockHandler.CheckValue(true);
551  }
552 
554  switch (m_HitType)
555  {
556  case EMeleeHitType.HEAVY:
557  case EMeleeHitType.SPRINT:
558  case EMeleeHitType.WPN_STAB:
559  case EMeleeHitType.WPN_HIT_BUTTSTOCK:
560  case EMeleeHitType.WPN_HIT:
561  m_Player.DepleteStamina(EStaminaModifiers.MELEE_HEAVY);
562  break;
563  default:
564  m_Player.DepleteStamina(EStaminaModifiers.MELEE_LIGHT);
565  break;
566  }
567 
568  m_IsInComboRange = false;
569 
570  return true;
571  }
572 
573  protected void EvaluateHit(InventoryItem weapon)
574  {
575  EntityAI target = m_MeleeCombat.GetTargetEntity();
576 
577  if (target)
578  {
579  if (target.IsInherited(DayZPlayer))
580  {
581  EvaluateHit_Player(weapon, target);
582  }
583  else if (target.IsInherited(DayZInfected))
584  {
585  EvaluateHit_Infected(weapon, target);
586  }
587  else if (target.GetMeleeTargetType() == EMeleeTargetType.NONALIGNABLE)
588  {
589  EvaluateHit_NonAlignableObjects(weapon, target);
590  }
591  else
592  {
593  EvaluateHit_Common(weapon, target);
594  }
595 
596  m_MeleeCombat.CheckMeleeItem();
597  }
598  }
599 
600  protected void EvaluateHit_Player(InventoryItem weapon, Object target)
601  {
602  int hitZoneIdx = m_MeleeCombat.GetHitZoneIdx();
603  int weaponMode = m_MeleeCombat.GetWeaponMode();
604  int forcedWeaponMode = -1;
605  vector hitPosWS;
606  bool forcedDummy = false;
607 
608  PlayerBase targetPlayer = PlayerBase.Cast(target);
610  if (targetPlayer)
611  {
612  vector targetPos = targetPlayer.GetPosition();
613  vector agressorPos = m_Player.GetPosition();
614 
615  // We get the angle from which an infected hit the blocking player
616  float hitAngle = Math.RAD2DEG * Math.AbsFloat(Math3D.AngleFromPosition(targetPos, MiscGameplayFunctions.GetHeadingVector(targetPlayer), agressorPos));
617 
619  if (targetPlayer.GetMeleeFightLogic() && targetPlayer.GetMeleeFightLogic().IsInBlock() && hitAngle <= GameConstants.PVP_MAX_BLOCKABLE_ANGLE)
620  {
621  if (weaponMode > 0)
622  {
623  forcedWeaponMode = --weaponMode; // Heavy -> Light shift
624  }
625  else
626  forcedDummy = true; // dummy hits, cannot shift lower than 0
627  }
628  }
629 
630  EvaluateHit_Common(weapon, target, forcedDummy, forcedWeaponMode);
631  }
632 
633  protected void EvaluateHit_Infected(InventoryItem weapon, Object target)
634  {
635  //If the finisher attack haven't been performed, then use normal hit
636  if (!EvaluateFinisherAttack(weapon, target))
637  EvaluateHit_Common(weapon, target);
638  }
639 
641  protected bool EvaluateFinisherAttack(InventoryItem weapon, Object target)
642  {
643  //Debug.MeleeLog(m_Player, string.Format("EvaluateFinisherAttack[1] target=%1, hitPos=%2, hitZoneIdx=%3, finisherType=%4", m_MeleeCombat.GetTargetEntity(), m_MeleeCombat.GetHitPos().ToString(), m_MeleeCombat.GetHitZoneIdx(), m_MeleeCombat.GetFinisherType()));
644 
645  if (m_MeleeCombat.GetFinisherType() > -1)
646  {
647  if (GetGame().IsServer())
648  DamageSystem.CloseCombatDamage(m_Player, target, m_MeleeCombat.GetHitZoneIdx(), DetermineFinisherAmmo(m_MeleeCombat.GetFinisherType()), m_MeleeCombat.GetHitPos(), ProcessDirectDamageFlags.NO_ATTACHMENT_TRANSFER);
649 
650  return true;
651  }
652 
653  return false;
654  }
655 
656  protected void EvaluateHit_Common(InventoryItem weapon, Object target, bool forcedDummy=false, int forcedWeaponMode = -1)
657  {
658  int hitZoneIdx = m_MeleeCombat.GetHitZoneIdx();
659  int weaponMode = m_MeleeCombat.GetWeaponMode();
660  vector hitPosWS;
661  string ammo;
662 
663  if (forcedWeaponMode > -1)
664  weaponMode = forcedWeaponMode;
665 
666  EntityAI targetEntity = EntityAI.Cast(target);
667 
669  if (!DummyHitSelector(m_HitType, ammo) && !forcedDummy)
670  {
672  if (hitZoneIdx >= 0)
673  {
674  hitPosWS = targetEntity.ModelToWorld(targetEntity.GetDefaultHitPosition());
675 
676  if (WeaponDestroyedCheck(weapon, ammo))
677  {
678  DamageSystem.CloseCombatDamage(m_Player, target, hitZoneIdx, ammo, hitPosWS);
679  //Debug.MeleeLog(m_Player, string.Format("EvaluateHit_Common[a]::CloseCombatDamage:: target: %1, hitzone: %2, ammo: %3", target, hitZoneIdx, ammo));
680  }
681  else
682  {
683  m_Player.ProcessMeleeHit(weapon, weaponMode, target, hitZoneIdx, hitPosWS);
684  //Debug.MeleeLog(m_Player, string.Format("EvaluateHit_Common[b]::ProcessMeleeHit:: target: %1, hitzone: %2, meleeMode: %3, forcedWeaponMode:%4", target, hitZoneIdx, weaponMode));
685  }
686  }
687  }
688  else
689  {
691  if (GetGame().IsServer() && targetEntity)
692  {
694  hitPosWS = targetEntity.ModelToWorld(targetEntity.GetDefaultHitPosition());
695  DamageSystem.CloseCombatDamage(m_Player, target, hitZoneIdx, ammo, hitPosWS);
696  //Debug.MeleeLog(m_Player, string.Format("EvaluateHit_Common[c]::CloseCombatDamage:: target: %1, hitzone: %2, meleeMode: %3, ammo: %4", target, hitZoneIdx, weaponMode, ammo));
697  }
698  }
699  }
700 
701  protected void EvaluateHit_NonAlignableObjects(InventoryItem weapon, Object target)
702  {
703  int hitZoneIdx = m_MeleeCombat.GetHitZoneIdx();
704  vector hitPosWS;
705  string ammo;
706 
707  if (hitZoneIdx >= 0)
708  {
709  if (WeaponDestroyedCheck(weapon,ammo))
710  DamageSystem.CloseCombatDamage(m_Player, target, hitZoneIdx, ammo, m_MeleeCombat.GetHitPos());
711  else
712  m_Player.ProcessMeleeHit(weapon, m_MeleeCombat.GetWeaponMode(), target, hitZoneIdx, m_MeleeCombat.GetHitPos());
713  }
714 
715  return;
716  }
717 
718  bool WeaponDestroyedCheck(InventoryItem weapon, out string ammo)
719  {
720  if (!weapon)
721  return false;
722 
723  Weapon_Base firearm = Weapon_Base.Cast(weapon);
724  ItemBase bayonet = ItemBase.Cast(weapon.GetInventory().FindAttachment(weapon.GetBayonetAttachmentIdx()));
725 
726  if ( firearm && bayonet && bayonet.IsRuined() )
727  {
728  ammo = bayonet.GetRuinedMeleeAmmoType();
729  return true;
730  }
731  else if (weapon.IsRuined())
732  {
733  ammo = weapon.GetRuinedMeleeAmmoType();
734  return true;
735  }
736  else
737  {
738  return false;
739  }
740  }
741 
742  protected void GetTargetData(out EntityAI target, out EMeleeTargetType targetType)
743  {
744  target = m_MeleeCombat.GetTargetEntity();
745  targetType = EMeleeTargetType.ALIGNABLE;
746 
747  // If there is no hitzone defined, then we won't be able to hit the target anyways..
748  if (m_MeleeCombat.GetHitZoneIdx() < 0)
749  {
750  target = null;
751  }
752 
753  if ( target )
754  {
755  targetType = target.GetMeleeTargetType();
756  }
757 
759  if ( targetType == EMeleeTargetType.NONALIGNABLE )
760  {
761  target = null;
762  }
763  }
764 
766  protected bool DummyHitSelector(EMeleeHitType hitType, out string ammoType)
767  {
768  switch (hitType)
769  {
771  case EMeleeHitType.KICK:
772  ammoType = DUMMY_HEAVY_AMMO;
773  return true;
774  break;
775  }
776 
777  ammoType = DUMMY_LIGHT_AMMO;
778 
779  return false;
780  }
781 
783  protected bool IsBehindEntity(int angle, DayZPlayer source, Object target)
784  {
785  return false;
786  }
787 
788  protected void SetCooldown(float time, EFightLogicCooldownCategory cooldownCategory)
789  {
791  if ( m_CooldownTimers.Get(cooldownCategory).IsRunning() )
792  {
793  m_CooldownTimers.Get(cooldownCategory).Stop();
794  }
795 
797  Param1<int> param = new Param1<int>(cooldownCategory);
798  m_CooldownTimers.Get(cooldownCategory).Run(time, this, "ResetCooldown", param);
799  }
800 
801  protected void ResetCooldown(EFightLogicCooldownCategory cooldownCategory)
802  {
803  switch (cooldownCategory)
804  {
805  case EFightLogicCooldownCategory.EVADE:
806  m_IsEvading = false;
807  break;
808  }
809  }
810 
811  protected void EnableControls();
812  protected void DisableControls();
813 
814  protected void DamageHands(DayZPlayer DZPlayer, ClothingBase gloves, InventoryItem itemInHands)
815  {
816  EntityAI target = m_MeleeCombat.GetTargetEntity();
817 
818  //We did not hit anything
819  if (itemInHands || !target || !DZPlayer)
820  return;
821 
822  //Check if server side
823  if (GetGame().IsServer())
824  {
825  int randNum;
826 
827  //If gloves, damage gloves
828  if (gloves && gloves.GetHealthLevel() < GameConstants.STATE_RUINED)
829  {
830  gloves.DecreaseHealth("", "", 1);
831  }
832  else
833  {
834  //Do not add bleeding if hitting player, zombie or animal
835  if (PlayerBase.Cast(target) || DayZCreatureAI.Cast(target))
836  return;
837 
838  BleedingSourcesManagerServer bleedingManager;
839 
840  //We don't inflict bleeding to hands when kicking
841  if (m_HitType != EMeleeHitType.KICK)
842  {
843  //If no gloves, inflict hand damage and bleeding
844  //m_Player.DecreaseHealth("hands", "", 10); IN CASE WE WANT TO DO STUFF WITH HAND HEALTH
845 
846  //Random bleeding source
847  randNum = Math.RandomIntInclusive(1, 15);
848  switch (randNum)
849  {
850  case 1:
851  if (m_Player)
852  {
853  bleedingManager = m_Player.GetBleedingManagerServer();
854  if (bleedingManager)
855  bleedingManager.AttemptAddBleedingSourceBySelection("RightForeArmRoll");
856  }
857  break;
858 
859  case 2:
860  if (m_Player)
861  {
862  bleedingManager = m_Player.GetBleedingManagerServer();
863  if (bleedingManager)
864  bleedingManager.AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
865  }
866  break;
867  }
868  }
869  else
870  {
871  //Random bleeding source
872  randNum = Math.RandomIntInclusive(1, 15);
873  //We only add bleeding to left foot as character kicks with left foot
874  switch (randNum)
875  {
876  case 1:
877  if (m_Player)
878  {
879  bleedingManager = m_Player.GetBleedingManagerServer();
880  if (bleedingManager)
881  bleedingManager.AttemptAddBleedingSourceBySelection("LeftToeBase");
882  }
883  break;
884 
885  case 2:
886  if (m_Player)
887  {
888  bleedingManager = m_Player.GetBleedingManagerServer();
889  if (bleedingManager)
890  bleedingManager.AttemptAddBleedingSourceBySelection("LeftFoot");
891  }
892  break;
893  }
894  }
895  }
896  }
897  }
898 
901  {
902  return -1;
903  }
904 
906  bool IsHitTypeFinisher(int type)
907  {
908  return false;
909  }
910 
912  int DetermineFinisherAnimation(int finisher_type)
913  {
914  int animation = -1;
915 
916  switch (finisher_type)
917  {
918  case EMeleeHitType.FINISHER_LIVERSTAB:
919  animation = HumanCommandMelee2.HIT_TYPE_FINISHER;
920  break;
921 
922  case EMeleeHitType.FINISHER_NECKSTAB:
923  animation = HumanCommandMelee2.HIT_TYPE_FINISHER_NECK;
924  break;
925  }
926 
927  return animation;
928  }
929 
931  string DetermineFinisherAmmo(int finisher_type)
932  {
933  string ret = "";
934 
935  switch (finisher_type)
936  {
937  case EMeleeHitType.FINISHER_NECKSTAB:
938  ret = "FinisherHitNeck";
939  break;
940 
941  default:
942  ret = "FinisherHit";
943  break;
944  }
945 
946  return ret;
947  }
948 
951  {
952  return -1;
953  }
954 
955  protected bool IsShortDistance(EntityAI pTarget, float pDistanceSq)
956  {
957  return pTarget && vector.DistanceSq(m_Player.GetPosition(), m_MeleeCombat.GetHitPos()) <= pDistanceSq || vector.DistanceSq(m_Player.GetBonePositionWS(m_Player.GetBoneIndexByName("Head")), m_MeleeCombat.GetHitPos()) <= pDistanceSq)
958  }
959 
962  protected bool m_IsFinisher;
963 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
SetBlock
void SetBlock(bool block)
Definition: dayzplayermeleefightlogic_lightheavy.c:58
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
GetTargetData
protected void GetTargetData(out EntityAI target, out EMeleeTargetType targetType)
Definition: dayzplayermeleefightlogic_lightheavy.c:742
EvaluateHit_Common
protected void EvaluateHit_Common(InventoryItem weapon, Object target, bool forcedDummy=false, int forcedWeaponMode=-1)
Definition: dayzplayermeleefightlogic_lightheavy.c:656
HandleInitialFirearmMelee
protected bool HandleInitialFirearmMelee(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
NOTE: Only singular (or first) hits, combo attacks are handled in combo.
Definition: dayzplayermeleefightlogic_lightheavy.c:338
m_DZPlayer
protected DayZPlayerImplement m_DZPlayer
DEPRECATED.
Definition: dayzplayermeleefightlogic_lightheavy.c:961
Mission
Mission class.
Definition: gameplay.c:670
CLOSE_TARGET_DISTANCE
const float CLOSE_TARGET_DISTANCE
Definition: dayzplayermeleefightlogic_lightheavy.c:13
HandleFightLogic
bool HandleFightLogic(int pCurrentCommandID, HumanInputController pInputs, EntityAI pEntityInHands, HumanMovementState pMovementState, out bool pContinueAttack)
Definition: dayzplayermeleefightlogic_lightheavy.c:137
DayZPlayerUtils
private void DayZPlayerUtils()
cannot be instantiated
Definition: dayzplayerutils.c:461
m_IsInBlock
protected bool m_IsInBlock
Definition: dayzplayermeleefightlogic_lightheavy.c:25
EvaluateFinisherAttack
protected bool EvaluateFinisherAttack(InventoryItem weapon, Object target)
Check and evaluate stealth kill, if applicable.
Definition: dayzplayermeleefightlogic_lightheavy.c:641
IsInBlock
bool IsInBlock()
Definition: dayzplayermeleefightlogic_lightheavy.c:53
DetermineSpecificFinisherType
int DetermineSpecificFinisherType(ItemBase weapon, int component)
DEPRECATED.
Definition: dayzplayermeleefightlogic_lightheavy.c:950
EStaminaModifiers
EStaminaModifiers
Definition: estaminamodifiers.c:1
~DayZPlayerMeleeFightLogic_LightHeavy
void ~DayZPlayerMeleeFightLogic_LightHeavy()
Definition: dayzplayermeleefightlogic_lightheavy.c:51
HumanCommandMelee2
Definition: human.c:536
EvaluateHit_Player
protected void EvaluateHit_Player(InventoryItem weapon, Object target)
Definition: dayzplayermeleefightlogic_lightheavy.c:600
m_IsFinisher
protected bool m_IsFinisher
Definition: dayzplayermeleefightlogic_lightheavy.c:962
EFightLogicCooldownCategory
EFightLogicCooldownCategory
Light / Heavy punches.
Definition: dayzplayermeleefightlogic_lightheavy.c:2
ClothingBase
Definition: dallasmask.c:1
GetAttackTypeByWeaponAttachments
protected EMeleeHitType GetAttackTypeByWeaponAttachments(EntityAI pEntity)
Definition: dayzplayermeleefightlogic_lightheavy.c:100
DayZPlayerMeleeFightLogic_LightHeavy
void DayZPlayerMeleeFightLogic_LightHeavy(DayZPlayerImplement player)
Definition: dayzplayermeleefightlogic_lightheavy.c:31
DayZPlayerImplementMeleeCombat
void DayZPlayerImplementMeleeCombat(DayZPlayerImplement player)
Definition: dayzplayerimplementmeleecombat.c:90
CanFight
bool CanFight()
Definition: dayzplayermeleefightlogic_lightheavy.c:73
EnableControls
protected void EnableControls()
m_MeleeCombat
protected ref DayZPlayerImplementMeleeCombat m_MeleeCombat
Definition: dayzplayermeleefightlogic_lightheavy.c:20
DayZInfected
Definition: zombiebase.c:1
DummyHitSelector
protected bool DummyHitSelector(EMeleeHitType hitType, out string ammoType)
evaluation of hit player vs. player
Definition: dayzplayermeleefightlogic_lightheavy.c:766
DayZCreatureAI
do not process rotations !
Definition: dayzanimal.c:606
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
InventoryItem
Definition: itembase.c:13
HandleInitialMeleeErc
protected bool HandleInitialMeleeErc(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
First attack in raised erc (light or heavy if modifier is used). Also added support for finishers.
Definition: dayzplayermeleefightlogic_lightheavy.c:384
DayZPlayer
Definition: dayzplayerimplement.c:72
EVADE_COOLDOWN
enum EFightLogicCooldownCategory EVADE_COOLDOWN
cooldown timers settings
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
HumanMovementState
Definition: human.c:1125
HumanInventoryWithFSM
HumanInventory... with FSM (synchronous, no anims)
Definition: humaninventorywithfsm.c:5
GetFinisherType
int GetFinisherType(InventoryItem weapon, EntityAI target)
DEPRECATED.
Definition: dayzplayermeleefightlogic_lightheavy.c:900
HandleSprintAttack
protected bool HandleSprintAttack(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
sprint attack in erc stance
Definition: dayzplayermeleefightlogic_lightheavy.c:480
GetAttackTypeByDistanceToTarget
protected float GetAttackTypeByDistanceToTarget(EntityAI pTarget, EMeleeTargetType pTargetType=EMeleeTargetType.ALIGNABLE)
Definition: dayzplayermeleefightlogic_lightheavy.c:120
PlayerBase
Definition: playerbaseclient.c:1
m_IsEvading
protected bool m_IsEvading
Definition: dayzplayermeleefightlogic_lightheavy.c:26
map
map
Definition: controlsxboxnew.c:3
vector
Definition: enconvert.c:105
PlayerConstants
Definition: playerconstants.c:1
EStaminaConsumers
EStaminaConsumers
Definition: estaminaconsumers.c:1
m_Player
protected PlayerBase m_Player
Definition: dayzplayermeleefightlogic_lightheavy.c:19
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
m_Mission
protected Mission m_Mission
Definition: dayzplayermeleefightlogic_lightheavy.c:23
IsBehindEntity
protected bool IsBehindEntity(int angle, DayZPlayer source, Object target)
DEPRECATED - moved into DayZPlayerImplementMeleeCombat.
Definition: dayzplayermeleefightlogic_lightheavy.c:783
DisableControls
protected void DisableControls()
HumanCommandMove
Definition: human.c:433
IsHitTypeFinisher
bool IsHitTypeFinisher(int type)
DEPRECATED.
Definition: dayzplayermeleefightlogic_lightheavy.c:906
Object
Definition: objecttyped.c:1
SetCooldown
protected void SetCooldown(float time, EFightLogicCooldownCategory cooldownCategory)
Definition: dayzplayermeleefightlogic_lightheavy.c:788
EVADE
@ EVADE
Definition: dayzplayermeleefightlogic_lightheavy.c:4
DayZPlayerImplement
Definition: manbase.c:1
DetermineFinisherAnimation
int DetermineFinisherAnimation(int finisher_type)
Picks a specific finisher animation. Not used for mounted bayonet stabs.
Definition: dayzplayermeleefightlogic_lightheavy.c:912
DetermineFinisherAmmo
string DetermineFinisherAmmo(int finisher_type)
Picks a specific finisher ammo fot the hit type. This gets synchronized and guides further behaviour ...
Definition: dayzplayermeleefightlogic_lightheavy.c:931
HumanInputController
Definition: human.c:17
EMeleeHitType
EMeleeHitType
Definition: dayzplayerimplementmeleecombat.c:1
HandleHitEvent
protected bool HandleHitEvent(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
Handle the event that our melee hit something.
Definition: dayzplayermeleefightlogic_lightheavy.c:283
m_HitType
protected EMeleeHitType m_HitType
Definition: dayzplayermeleefightlogic_lightheavy.c:21
m_WasPreviousHitProcessed
protected bool m_WasPreviousHitProcessed
Definition: dayzplayermeleefightlogic_lightheavy.c:29
m_IsInComboRange
protected bool m_IsInComboRange
Definition: dayzplayermeleefightlogic_lightheavy.c:28
GetCurrentHitType
bool GetCurrentHitType()
Definition: dayzplayermeleefightlogic_lightheavy.c:68
RegisterCooldowns
protected void RegisterCooldowns()
Definition: dayzplayermeleefightlogic_lightheavy.c:84
DamageHands
protected void DamageHands(DayZPlayer DZPlayer, ClothingBase gloves, InventoryItem itemInHands)
Definition: dayzplayermeleefightlogic_lightheavy.c:814
HumanCommandWeapons
Definition: human.c:986
Init
void Init(DayZPlayerImplement player)
Definition: dayzplayermeleefightlogic_lightheavy.c:36
GameConstants
Definition: constants.c:612
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
DUMMY_LIGHT_AMMO
const string DUMMY_LIGHT_AMMO
dummy ammo types
Definition: dayzplayermeleefightlogic_lightheavy.c:16
IsEvading
bool IsEvading()
Definition: dayzplayermeleefightlogic_lightheavy.c:63
Timer
Definition: dayzplayerimplement.c:62
EvaluateHit_NonAlignableObjects
protected void EvaluateHit_NonAlignableObjects(InventoryItem weapon, Object target)
Definition: dayzplayermeleefightlogic_lightheavy.c:701
HandleProneKick
protected bool HandleProneKick(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
kick from raised pne
Definition: dayzplayermeleefightlogic_lightheavy.c:450
ProcessDirectDamageFlags
ProcessDirectDamageFlags
Definition: object.c:1
HandleComboHit
protected bool HandleComboHit(int pCurrentCommandID, HumanInputController pInputs, InventoryItem itemInHands, HumanMovementState pMovementState, out bool pContinueAttack)
combo hits - when we are already in Melee command and clicking UseButton
Definition: dayzplayermeleefightlogic_lightheavy.c:501
EvaluateHit
protected void EvaluateHit(InventoryItem weapon)
Definition: dayzplayermeleefightlogic_lightheavy.c:573
Math
Definition: enmath.c:6
EvaluateHit_Infected
protected void EvaluateHit_Infected(InventoryItem weapon, Object target)
Definition: dayzplayermeleefightlogic_lightheavy.c:633
IsShortDistance
protected bool IsShortDistance(EntityAI pTarget, float pDistanceSq)
Definition: dayzplayermeleefightlogic_lightheavy.c:955
GetAttackTypeFromInputs
protected EMeleeHitType GetAttackTypeFromInputs(HumanInputController pInputs)
Definition: dayzplayermeleefightlogic_lightheavy.c:90
EntityAI
Definition: building.c:5
ResetCooldown
protected void ResetCooldown(EFightLogicCooldownCategory cooldownCategory)
Definition: dayzplayermeleefightlogic_lightheavy.c:801
Math3D
Definition: enmath3d.c:27
WeaponDestroyedCheck
bool WeaponDestroyedCheck(InventoryItem weapon, out string ammo)
Definition: dayzplayermeleefightlogic_lightheavy.c:718
DUMMY_HEAVY_AMMO
const string DUMMY_HEAVY_AMMO
Definition: dayzplayermeleefightlogic_lightheavy.c:17
EMeleeTargetType
EMeleeTargetType
Definition: emeleetargettype.c:1
m_CooldownTimers
protected ref map< int, ref Timer > m_CooldownTimers
Definition: dayzplayermeleefightlogic_lightheavy.c:22