DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
DayZPlayerImplementMeleeCombat.c
См. документацию.
18
20{
22 protected const float TARGETING_ANGLE_NORMAL = 30.0;
23 protected const float TARGETING_ANGLE_SPRINT = 15.0;
24 protected const float TARGETING_MIN_HEIGHT = -2.0;
25 protected const float TARGETING_MAX_HEIGHT = 2.0;
26 protected const float TARGETING_RAY_RADIUS_EX = 0.5;
27 protected const float TARGETING_RAY_RADIUS = 0.25;
28 protected const float TARGETING_RAY_DIST = 5.0;
29 protected const float TARGETING_RAY_DIST_SHORT= 2.0;
30
31 protected const float RANGE_EXTENDER_NORMAL = 0.65;
32 protected const float RANGE_EXTENDER_SPRINT = 1.35;
33
34 protected const string DEFAULT_HIT_ZONE = "Torso";
35
37 protected ref MeleeTargeting m_MeleeTargeting;
38
43
44 #ifdef DIAG_DEVELOPER
45 protected Object m_PreviousTargetObject;
46 protected ref array<Object> m_AllPreviousTargetObjects;
47 #endif
48
52
55
58 protected int m_WeaponMode;
59 protected float m_WeaponRange;
60
62 protected bool m_ForceUntargetable;
63 protected bool m_SprintAttack;
64 protected bool m_WasHit;
65
66 protected vector m_RayStart;
67 protected vector m_RayEnd;
69
71
73 protected int m_HitZoneIdx;
74 protected int m_FinisherType;
75 protected string m_HitZoneName;
77
78 #ifdef DIAG_DEVELOPER
79 protected int m_PreviousHitZoneIdx;
80 protected string m_PreviousHitZoneName;
81 protected vector m_PreviousHitPositionWS;
82 #endif
83
85
86 // ------------------------------------------------------------
87 // CONSTRUCTOR
88 // ------------------------------------------------------------
89
91 {
92 Init(player);
93 }
94
96 {
97 m_DZPlayer = player;
98
99 m_MeleeTargeting = new MeleeTargeting;
100
101 m_HitZoneName = "";
102 m_HitZoneIdx = -1;
103 m_FinisherType = -1;
105
106 m_SprintAttack = false;
107 m_WasHit = false;
108
109 m_TargetObject = null;
110 m_TargetType = EMeleeTargetType.ALIGNABLE;
112 #ifdef DIAG_DEVELOPER
113 m_AllPreviousTargetObjects = new array<Object>;
114 #endif
115
117
118 m_TargetableObjects = new array<typename>; //checks against CONFIG hierarchy
122
130
132 m_BlacklistedDamageZones.Insert("Brain");
133 }
134
136
137 // ------------------------------------------------------------
138 // PUBLIC
139 // ------------------------------------------------------------
140
142 {
143 return m_HitType;
144 }
145
146 void SetHitZoneIdx(int pHitZone)
147 {
148 m_HitZoneIdx = pHitZone;
149 }
150
152 {
153 return EntityAI.Cast(m_TargetObject);
154 }
155
157 {
158 m_TargetObject = pTarget;
159 }
160
163 {
164 return m_HitZoneIdx;
165 }
166
168 {
169 return m_HitPositionWS;
170 }
171
172 void SetHitPos(vector pHitPos)
173 {
174 m_HitPositionWS = pHitPos;
175 }
176
178 {
179 return m_FinisherType;
180 }
181
182 void SetFinisherType(int pFinisherType)
183 {
184 m_FinisherType = pFinisherType;
185 }
186
188 {
189 return m_WeaponMode;
190 }
191
192 void Reset(InventoryItem weapon, EMeleeHitType hitMask, bool wasHitEvent = false)
193 {
194 m_Weapon = weapon;
195 m_HitType = hitMask;
196 m_TargetType = EMeleeTargetType.ALIGNABLE;
197 m_SprintAttack = hitMask == EMeleeHitType.SPRINT;
200 m_WasHit = wasHitEvent;
201
202 #ifdef DIAG_DEVELOPER
203 m_AllPreviousTargetObjects = m_AllTargetObjects;
204 #endif
205 m_AllTargetObjects.Clear();
206 }
207
209 {
210 #ifdef DIAG_DEVELOPER
211 m_PreviousTargetObject = m_TargetObject;
212 m_PreviousHitPositionWS = m_HitPositionWS;
213 m_PreviousHitZoneIdx = m_HitZoneIdx;
214 m_PreviousHitZoneName = m_HitZoneName;
215 #endif
216
218 }
219
220 void Update(InventoryItem weapon, EMeleeHitType hitMask, bool wasHitEvent = false)
221 {
222 Reset(weapon, hitMask, wasHitEvent);
223
224 #ifndef SERVER
226 {
227 //Error("DayZPlayerImplementMeleeCombat - ScriptInputUserData already posted");
228 return;
229 }
230
233
235 if (g_Game.IsMultiplayer())
236 {
241 ctx.Write(m_HitZoneIdx);
243 ctx.Send();
244 }
245 #endif
246 }
247
249 {
250 if (m_Weapon)
251 {
252 ItemBase item = ItemBase.Cast(m_Weapon.ProcessMeleeItemDamage(GetWeaponMode()));
253
254 if (item && item.GetHierarchyRootPlayer())
255 {
256 PlayerBase.Cast(item.GetHierarchyRootPlayer()).SetCheckMeleeItem(item);
257 }
258 else if (m_Weapon && m_Weapon.GetHierarchyRootPlayer())
259 {
260 PlayerBase.Cast(m_Weapon.GetHierarchyRootPlayer()).SetCheckMeleeItem(ItemBase.Cast(m_Weapon));
261 }
262 }
263 }
264
265 // ------------------------------------------------------------
266 // protected
267 // ------------------------------------------------------------
268
269 protected int SelectWeaponMode(InventoryItem weapon)
270 {
271 if (weapon)
272 {
274 if (weapon.IsInherited(Weapon))
275 {
276 switch (m_HitType)
277 {
278 case EMeleeHitType.WPN_HIT:
279 return 0;
280 case EMeleeHitType.WPN_HIT_BUTTSTOCK:
281 return 1;
282 case EMeleeHitType.WPN_STAB:
283 return 2;
284 }
285 }
286 else
287 {
289 switch (m_HitType)
290 {
291 case EMeleeHitType.LIGHT:
292 return weapon.GetMeleeMode();
293 case EMeleeHitType.HEAVY:
294 return weapon.GetMeleeHeavyMode();
295 case EMeleeHitType.SPRINT:
296 return weapon.GetMeleeSprintMode();
297 }
298 }
299 }
300
302 switch (m_HitType)
303 {
304 case EMeleeHitType.HEAVY:
305 return 1;
306 case EMeleeHitType.SPRINT:
307 return 2;
308 }
309
310 return 0;
311 }
312
313 protected float GetWeaponRange(InventoryItem weapon, int weaponMode)
314 {
315 if ( weapon )
316 return weapon.GetMeleeCombatData().GetModeRange(weaponMode);
317 else
318 return m_DZPlayer.GetMeleeCombatData().GetModeRange(weaponMode);
319 }
320
321 protected float GetRange()
322 {
324 }
325
326 protected float GetAngle()
327 {
328 if (m_SprintAttack)
330 else
332 }
333
334 protected void TargetSelection()
335 {
336 // Prepare common variables
337 PlayerBase player = PlayerBase.Cast(m_DZPlayer);
338 vector pos = m_DZPlayer.GetPosition();
339 vector rayStart = m_DZPlayer.GetBonePositionWS(m_DZPlayer.GetBoneIndexByName("Head"));
340
341 vector cameraPos, cameraRot, cameraDir;
342 m_DZPlayer.GetCurrentCameraTransform(cameraPos, cameraDir, cameraRot);
343 vector dir = MiscGameplayFunctions.GetHeadingVector(player);
344 dir[1] = cameraDir[1];
345
346 // Calculate max distances
347 float dist = GetRange();
348 float angle = GetAngle();
349 float dist2 = Math.SqrFloat(dist);
350
351 // There's generally 2 TargetSelection calls per animation
352 // First to obtain target to move towards during animation
353 // Second one is to see if that target is still in range before applying damage to it
354 // m_WasHit means the hit event occured, so this is the second call
355
356 if (m_WasHit && GetFinisherType() == -1)
357 {
358 // See if the component is still in range
359 if (CanObjectBeTargeted(m_TargetObject) && ( vector.DistanceSq(rayStart, m_TargetObject.GetDamageZonePos(m_HitZoneName)) <= dist2 ))
360 {
362 // This result should still be cached, so no need to fill it in again
363 return;
364 }
365 }
366
367 // Find a new target
369
370 Object target;
371 vector hitPos;
372 int hitZone;
373
374 // First pass - Prefer what the player is looking at (only aligneable ones, we will try for nonaligneable later)
375 if (HitZoneSelectionRaycastHelper(hitPos, hitZone, target))
376 {
378 {
379 SetTarget(target, hitPos, hitZone);
380 return;
381 }
382
383 if (CanObjectBeTargeted(target) && vector.DistanceSq(rayStart, hitPos) <= dist2)
384 {
385 m_AllTargetObjects.Insert(target);
386
387 SetTarget(target, hitPos, hitZone);
388 return;
389 }
390 }
391
392 // Second pass - Try to obtain something aligneable closeby the player watching direction
394
395 if (targetData)
396 {
397 SetTarget(targetData.Obj, targetData.HitPos, targetData.HitComponent);
398 return;
399 }
400
401 // Third pass - We found no aligneable target, check if the target that we are directly looking at is nonalignable (big)
402 if (CanObjectBeTargeted(target, true) && vector.DistanceSq(rayStart, hitPos) <= dist2)
403 {
404 m_AllTargetObjects.Insert(target);
405
406 SetTarget(target, hitPos, hitZone);
407 return;
408 }
409 }
410
417 protected int TrySelectFinisherType(InventoryItem weapon, EntityAI target)
418 {
419 if (m_WasHit)
420 return -1;
421
422 if (target)
423 {
424 vector dir = target.GetPosition() - m_DZPlayer.GetPosition();
425
426 IEntity hitEntity;
427 vector hitPos, hitNormal;
428
429 float moveFraction = m_DZPlayer.CollisionMoveTest(dir, vector.Zero, 1.0, target, hitEntity, hitPos, hitNormal);
430 if (moveFraction < 1.0)
431 return -1;
432 }
433
435 if (target && target.CanBeBackstabbed() && weapon && (weapon.IsMeleeFinisher() || m_HitType == EMeleeHitType.WPN_STAB) && !weapon.IsRuined() )
436 {
437 bool playGenericFinisherAnimation = false;
438 ZombieBase targetZombie = ZombieBase.Cast(target);
439 if (targetZombie && m_DebugForcedFinisherType == -1)
440 {
442 if (!IsEntityBehindEntityInAngle(m_DZPlayer, target, 60))
443 {
444 return -1;
445 }
446
447 int mindState = targetZombie.GetMindStateSynced();
449 if (mindState >= DayZInfectedConstants.MINDSTATE_DISTURBED)
450 {
451 return -1;
452 }
453 }
454
455 PlayerBase targetPlayer = PlayerBase.Cast(target);
457 if (targetZombie)
458 {
459 playGenericFinisherAnimation = targetZombie.IsCrawling();
460 }
461 else if (targetPlayer)
462 {
463 playGenericFinisherAnimation = targetPlayer.IsInProne();
464 }
465 else
466 {
467 playGenericFinisherAnimation = true;
468 }
469
471 if (weapon.IsWeapon())
472 {
473 return EMeleeHitType.WPN_STAB_FINISHER;
474 }
475 else if (playGenericFinisherAnimation)
476 {
477 return EMeleeHitType.FINISHER_GENERIC;
478 }
479 else //specific hit depending on the component hit (gotten from the target)
480 {
481 return DetermineSpecificFinisherType(ItemBase.Cast(weapon));
482 }
483 }
484
485 return -1;
486 }
487
489 {
491 {
492 array<int> finishers = {
493 EMeleeHitType.FINISHER_LIVERSTAB,
494 EMeleeHitType.FINISHER_NECKSTAB
495 };
496
497 return finishers[m_DebugForcedFinisherType];
498 }
499
500 if (!weapon || !weapon.GetValidFinishers() || weapon.GetValidFinishers().Count() == 0)
501 {
502 return EMeleeHitType.FINISHER_LIVERSTAB;
503 }
504
505 PlayerBase player = PlayerBase.Cast(m_DZPlayer);
506 int idx = Math.Round(Math.Lerp(0, weapon.GetValidFinishers().Count() - 1, player.GetRandomGeneratorSyncManager().GetRandom01(RandomGeneratorSyncUsage.RGSGeneric)));
507 return weapon.GetValidFinishers()[idx];
508 }
509
510 protected void InternalResetTarget()
511 {
512 m_TargetObject = null;
514 m_HitZoneIdx = -1;
515 m_HitZoneName = "";
516 SetFinisherType(-1);
517 }
518
519 protected void SetTarget(Object obj, vector hitPos, int hitZone)
520 {
521 if (obj)
522 {
523 m_TargetObject = obj;
524 m_HitPositionWS = hitPos;
525 m_HitZoneIdx = hitZone;
526 m_HitZoneName = m_TargetObject.GetDamageZoneNameByComponentIndex(m_HitZoneIdx);
527 }
528 }
529
530 protected bool CanObjectBeTargeted(Object obj, bool checkNonAligneAble = false)
531 {
532 return obj && obj.IsAlive() && ( obj.IsAnyInherited(m_TargetableObjects) || (checkNonAligneAble && obj.IsAnyInherited(m_NonAlignableObjects)) );
533 }
534
535 protected bool HitZoneSelectionRaycastHelper(out vector hitPos, out int hitZone, out Object target)
536 {
537 return HitZoneSelectionRaycast(hitPos, hitZone, target, false);
538 // Not sure if desired, as it can give some results that feel a little odd
539 // But it will depend entirely on the player and situation..
540 // I guess the crosshair is hidden while melee anyways though
541 // || ( m_DZPlayer.IsInThirdPerson() && HitZoneSelectionRaycast(hitPos, hitZone, target, true);
542 }
543
544 protected bool HitZoneSelectionRaycast(out vector hitPos, out int hitZone, out Object target, bool useCamera)
545 {
546 PlayerBase player = PlayerBase.Cast(m_DZPlayer);
547
548 vector pos;
549 vector dir;
550 vector playerDir;
551 if (useCamera)
552 { // What the player camera is looking at (crosshair)
553 vector cameraRotation;
554 player.GetCurrentCameraTransform(pos, dir, cameraRotation);
555 playerDir = dir;
556 }
557 else
558 { // What the player himself is looking at
559 playerDir = MiscGameplayFunctions.GetHeadingVector(player);
560 dir = g_Game.GetCurrentCameraDirection();
561 // get position of Head bone
562 pos = MiscGameplayFunctions.GetPlayerHeadPosition(player);
563 }
564
566 if (vector.Dot(dir, playerDir) < 0.5)
567 {
568 return false;
569 }
570
571 m_RayStart = pos;
572 m_RayEnd = m_RayStart + GetRange() * dir;
573
574 // raycast
575 set<Object> hitObjects = new set<Object>;
576 vector hitNormal;
577
578 if ( DayZPhysics.RaycastRV(m_RayStart, m_RayEnd, hitPos, hitNormal, hitZone, hitObjects, null, player, false, false, ObjIntersectIFire) && hitObjects.Count() > 0 )
579 {
580 target = hitObjects[0];
581 m_ForceUntargetable = false;
582
584 PlayerBase playerTarget = PlayerBase.Cast(target);
585 if (playerTarget && playerTarget.IsInVehicle())
586 {
587 if (vector.DistanceSq(pos, hitPos) > Math.SqrFloat(GetRange() * 0.5))
588 {
589 m_ForceUntargetable = true;
590 target = null;
591 hitPos = vector.Zero;
592 hitZone = -1;
593 }
594 }
595
596 return true;
597 }
598
599 return false;
600 }
601
603 [Obsolete("replaced by HitZoneSelectionRaycast")]
604 protected void HitZoneSelection()
605 {
606 Object cursorTarget = null;
607 PlayerBase player = PlayerBase.Cast(m_DZPlayer);
608
609 // ray properties
610 vector pos;
611 vector cameraDirection = g_Game.GetCurrentCameraDirection();
612
613 MiscGameplayFunctions.GetHeadBonePos(player, pos);
614 m_RayStart = pos;
615 m_RayEnd = pos + cameraDirection * TARGETING_RAY_DIST;
616 m_RayEndShort = pos + cameraDirection * TARGETING_RAY_DIST_SHORT;
617
618 // raycast
619 set<Object> hitObjects = new set<Object>;
620 int hitComponentIndex;
621 float hitFraction;
622 vector start, end, hitNormal, hitPosObstructed;
623 PhxInteractionLayers collisionLayerMask = PhxInteractionLayers.DEFAULT;
624
625 if ( !DayZPhysics.RaycastRV(m_RayStart, m_RayEndShort, m_HitPositionWS, hitNormal, m_HitZoneIdx, hitObjects, null, player, false, false, ObjIntersectIFire) && !DayZPhysics.RaycastRV(m_RayStart, m_RayEnd, m_HitPositionWS, hitNormal, m_HitZoneIdx, hitObjects, null, player, false, false, ObjIntersectIFire, TARGETING_RAY_RADIUS) )
626 {
627 m_HitZoneIdx = -1;
628 //Print("HitZoneSelection failed");
629 }
630 else if ( hitObjects.Count() > 0 )
631 {
632 cursorTarget = hitObjects.Get(0);
633
635 vector playerPos = m_DZPlayer.GetPosition();
636 vector hitPos = m_HitPositionWS;
638 playerPos[1] = 0;
639 hitPos[1] = 0;
640
642 if ( cursorTarget.IsAnyInherited(m_NonAlignableObjects) && vector.Distance(playerPos, hitPos) <= GetWeaponRange(m_Weapon, GetWeaponMode()))
643 {
645 if (m_TargetObject == null)
646 {
647 m_TargetObject = cursorTarget;
648 }
649 }
650
651 if (cursorTarget == m_TargetObject)
652 {
653 m_HitZoneName = cursorTarget.GetDamageZoneNameByComponentIndex(m_HitZoneIdx);
654 //Print("hit object: " + m_TargetObject + " | component idx: " + m_HitZoneIdx + " | hitzone name: " + m_HitZoneName);
655 }
656 else
657 {
659 m_HitZoneName = DEFAULT_HIT_ZONE; //Default to torso if no zone is targeted
660 }
661 }
662 else
663 {
664 m_HitZoneIdx = -1;
665 //Print("HitZoneSelection failed");
666 }
667 }
668
670 [Obsolete("replaced by MeleeTargeting.IsMeleeTargetObstructed")]
671 protected bool IsObstructed(Object object)
672 {
673 // check direct visibility of object (obstruction check)
675 int hitComponentIndex;
676 float hitFraction;
677 vector start, end, hitNormal, hitPosObstructed;
678 Object hitObject = null;
679 PlayerBase player = PlayerBase.Cast(m_DZPlayer);
680
681 if (object)
682 {
683 MiscGameplayFunctions.GetHeadBonePos(player, start);
684 end = start + MiscGameplayFunctions.GetHeadingVector(player) * vector.Distance(player.GetPosition(), object.GetPosition());
685
686 if ( end == start )
687 return true;
688
689 return DayZPhysics.RayCastBullet( start, end, collisionLayerMask, null, hitObject, hitPosObstructed, hitNormal, hitFraction);
690 }
691
692 return false;
693 }
694
695 private bool IsEntityBehindEntityInAngle(EntityAI source, EntityAI target, float angle)
696 {
697 vector targetDirection = target.GetDirection();
698 ZombieBase targetZombie;
699 if (Class.CastTo(targetZombie, target))
700 {
701 targetDirection = Vector(targetZombie.GetOrientationSynced(),0,0);
702 targetDirection = targetDirection.AnglesToVector();
703 }
704 vector toSourceDirection = (source.GetPosition() - target.GetPosition());
705
706 targetDirection[1] = 0;
707 toSourceDirection[1] = 0;
708
709 targetDirection.Normalize();
710 toSourceDirection.Normalize();
711
712 float cosFi = vector.Dot(targetDirection, toSourceDirection);
713 vector cross = targetDirection * toSourceDirection;
714
715 int hitDir = Math.Acos(cosFi) * Math.RAD2DEG;
716
717 if (cross[1] < 0)
718 hitDir = -hitDir;
719
720 return hitDir <= (-180 + angle) || hitDir >= (180 - angle);
721 }
722
723#ifdef DIAG_DEVELOPER
724 // ------------------------------------------------------------
725 // DEBUG
726 // ------------------------------------------------------------
727 protected ref array<Shape> dbgConeShapes = new array<Shape>();
728 protected ref array<Shape> dbgTargets = new array<Shape>();
729 protected ref array<Shape> hitPosShapes = new array<Shape>();
730
731 void Debug(InventoryItem weapon, EMeleeHitType hitType)
732 {
733 CleanAllDebugShapes();
734
735 if (!DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG))
736 return;
737
738 if (DiagMenu.GetBool(DiagMenuIDs.MELEE_CONTINUOUS) && (!g_Game.IsMultiplayer() || !g_Game.IsServer()))
739 Update(weapon, hitType);
740
741 if (DiagMenu.GetBool(DiagMenuIDs.MELEE_SHOW_TARGETS))
742 ShowDebugMeleeTarget();
743
744 if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DRAW_TARGETS))
745 DrawDebugTargets();
746
747 if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DRAW_RANGE))
748 {
749 DrawDebugMeleeHitPosition();
750 DrawDebugMeleeCone();
751 }
752
753 if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DRAW_BLOCK_RANGE_AI))
754 DrawDebugBlockCone(GameConstants.AI_MAX_BLOCKABLE_ANGLE, COLOR_GREEN);
755
756 if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DRAW_BLOCK_RANGE_PVP))
757 DrawDebugBlockCone(GameConstants.PVP_MAX_BLOCKABLE_ANGLE, COLOR_YELLOW);
758 }
759
760 int DebugGetForcedFinisherType()
761 {
763 }
764
765 void DebugSetForcedFinisherType(int pFinisherType)
766 {
767 m_DebugForcedFinisherType = pFinisherType;
768 }
769
771 protected void ShowDebugMeleeTarget()
772 {
773 int windowPosX = 0;
774 int windowPosY = 500;
775
776 DbgUI.Begin("Melee Target", windowPosX, windowPosY);
777 HumanCommandMelee2 hmc2 = m_DZPlayer.GetCommand_Melee2();
778 if (hmc2)
779 {
780 DbgUI.Text("Current combo: " + hmc2.GetComboCount());
781 }
782
783 if (m_PreviousTargetObject)
784 {
785 DbgUI.Text("Previous Character: " + m_PreviousTargetObject.GetDisplayName());
786 DbgUI.Text("Previous HitZone: " + m_PreviousHitZoneName + "(" + m_PreviousHitZoneIdx + ")");
787 DbgUI.Text("Previous HitPosWS:" + m_PreviousHitPositionWS);
788 DbgUI.Text("Previous Distance:" + vector.Distance(m_PreviousHitPositionWS, m_DZPlayer.GetPosition()));
789 }
790
791 if (m_TargetObject)
792 {
793 DbgUI.Text("Character: " + m_TargetObject.GetDisplayName());
794 DbgUI.Text("HitZone: " + m_HitZoneName + "(" + m_HitZoneIdx + ")");
795 DbgUI.Text("HitPosWS:" + m_HitPositionWS);
796 DbgUI.Text("Distance:" + vector.Distance(m_HitPositionWS, m_DZPlayer.GetPosition()));
797 }
798 DbgUI.End();
799 }
800
802 protected void DrawDebugTargets()
803 {
804 DrawDebugTargetsHelper(m_AllPreviousTargetObjects, m_PreviousTargetObject, COLOR_RED_A, COLOR_YELLOW_A);
805 DrawDebugTargetsHelper(m_AllTargetObjects, m_TargetObject, COLOR_RED, COLOR_YELLOW);
806 }
807
808 protected void DrawDebugTargetsHelper(array<Object> allTargets, Object target, int colorMainTarget, int colorTarget)
809 {
810 for (int i = 0; i < allTargets.Count(); ++i )
811 {
812 if ( m_TargetObject && allTargets.Count() )
813 {
814 Object obj = allTargets[i];
815 vector w_pos = obj.GetPosition();
816 // sphere pos tweaks
817 vector w_pos_sphr = w_pos;
818 w_pos_sphr[1] = w_pos_sphr[1] + 1.8;
819 // line pos tweaks
820 vector w_pos_lend = w_pos;
821 w_pos_lend[1] = w_pos_lend[1] + 1.8;
822
823 if ( obj == m_TargetObject )
824 {
825 dbgTargets.Insert( Debug.DrawSphere(w_pos_sphr, 0.05, colorMainTarget, ShapeFlags.NOOUTLINE) );
826 dbgTargets.Insert( Debug.DrawLine(w_pos, w_pos_lend, colorMainTarget) );
827 }
828 else
829 {
830 dbgTargets.Insert( Debug.DrawSphere(w_pos_sphr, 0.05, colorTarget, ShapeFlags.NOOUTLINE) );
831 dbgTargets.Insert( Debug.DrawLine(w_pos, w_pos_lend, colorTarget) );
832 }
833 }
834 }
835 }
836
837 protected void DrawDebugMeleeHitPosition()
838 {
839 if (m_PreviousTargetObject)
840 hitPosShapes.Insert( Debug.DrawSphere(m_PreviousHitPositionWS, 0.15, COLOR_YELLOW_A, ShapeFlags.NOOUTLINE|ShapeFlags.TRANSP) );
841
842 if (m_TargetObject)
843 hitPosShapes.Insert( Debug.DrawSphere(m_HitPositionWS, 0.15, COLOR_YELLOW, ShapeFlags.NOOUTLINE|ShapeFlags.TRANSP) );
844 }
845
846 protected void DrawDebugMeleeCone()
847 {
848 // cone settings
849 float dist = GetRange();
850 vector start = m_DZPlayer.GetPosition();
851
852 vector normDir = MiscGameplayFunctions.GetHeadingVector(PlayerBase.Cast(m_DZPlayer));
853 normDir[1] = 0;
854 normDir.Normalize();
855 float playerAngle = -Math.Atan2(normDir[0], normDir[2]);
856
857 dbgConeShapes.InsertArray(Debug.DrawCone(start, dist, GetAngle() * Math.DEG2RAD, playerAngle + Math.PI_HALF, COLOR_BLUE));
858 }
859
860 protected void DrawDebugBlockCone(float angle, int color)
861 {
862 // cone settings
863 float dist = 3;
864 vector start = m_DZPlayer.GetPosition();
865
866 vector dir = g_Game.GetCurrentCameraDirection();
867 dir[1] = 0;
868 dir.Normalize();
869 float playerAngle = -Math.Atan2(dir[0], dir[2]);
870
871 dbgConeShapes.InsertArray(Debug.DrawCone(start, dist, angle * Math.DEG2RAD, playerAngle + Math.PI_HALF, color));
872 }
873
874 protected void CleanAllDebugShapes()
875 {
876 CleanupDebugShapes(dbgTargets);
877 CleanupDebugShapes(dbgConeShapes);
878 CleanupDebugShapes(hitPosShapes);
879 }
880
881 protected void CleanupDebugShapes(array<Shape> shapes)
882 {
883 for ( int it = 0; it < shapes.Count(); ++it )
884 {
885 Shape shape = shapes[it];
886 Debug.RemoveShape( shape );
887 }
888
889 shapes.Clear();
890 }
891#endif
892}
const int INPUT_UDT_MELEE_TARGET
string Debug()
Определения CachedEquipmentStorageBase.c:26
@ KICK
Определения ClientKickedModule.c:12
DayZGame g_Game
Определения DayZGame.c:4074
override Widget Init()
Определения DayZGame.c:127
DayZInfectedConstants
Определения DayZInfected.c:2
PhxInteractionLayers
Определения DayZPhysics.c:2
float GetWeaponRange(InventoryItem weapon, int weaponMode)
bool m_SprintAttack
If most recent attack was a sprint attack.
void HitZoneSelection()
DEPRECATED.
vector m_RayEndShort
DEPRECATED: "HitZoneSelection".
int GetHitZoneIdx()
component idx
void SetTarget(Object obj, vector hitPos, int hitZone)
const float TARGETING_MIN_HEIGHT
Second Pass: How deep the cone goes in meters from player position.
vector GetHitPos()
const float TARGETING_RAY_DIST_SHORT
DEPRECATED: "HitZoneSelection".
bool IsEntityBehindEntityInAngle(EntityAI source, EntityAI target, float angle)
int m_FinisherType
int GetWeaponMode()
int m_WeaponMode
WeaponMode used during most recent Update.
bool m_WasHit
If most recent attack was.
ref array< string > m_BlacklistedDamageZones
List of blacklisted damage zone names (cannot use indices due to the possible changes when p3d compon...
bool HitZoneSelectionRaycast(out vector hitPos, out int hitZone, out Object target, bool useCamera)
const float RANGE_EXTENDER_SPRINT
General range extension while in sprint.
void InternalResetTarget()
void SetHitPos(vector pHitPos)
void CheckMeleeItem()
const float TARGETING_MAX_HEIGHT
Second Pass: How high the cone goes in meters from player position.
const float TARGETING_RAY_DIST
DEPRECATED: "HitZoneSelection".
EntityAI GetTargetEntity()
ref MeleeTargeting m_MeleeTargeting
Target selecting "component".
void TargetSelection()
bool m_ForceUntargetable
Misc - cache.
ref array< Object > m_AllTargetObjects
All potential targets found during most recent TargetSelection.
void ~DayZPlayerImplementMeleeCombat()
float GetRange()
DayZPlayerImplement m_DZPlayer
Parent.
ref array< typename > m_NonAlignableObjects
Typenames of objects that can be targeted, but are not a priority (3rd Pass)
float GetAngle()
vector m_RayStart
Start position of most recent HitZoneSelectionRaycast.
EMeleeHitType
Определения DayZPlayerImplementMeleeCombat.c:2
@ WPN_HIT_BUTTSTOCK
@ WPN_STAB
@ WPN_HIT
@ FINISHER_LIVERSTAB
Определения DayZPlayerImplementMeleeCombat.c:9
@ FINISHER_GENERIC
@ WPN_STAB_FINISHER
@ FINISHER_NECKSTAB
void DayZPlayerImplementMeleeCombat(DayZPlayerImplement player)
Object m_TargetObject
Targets - types.
EMeleeHitType GetHitType()
void SetHitZoneIdx(int pHitZone)
int SelectWeaponMode(InventoryItem weapon)
vector m_HitPositionWS
Most recent target position.
bool HitZoneSelectionRaycastHelper(out vector hitPos, out int hitZone, out Object target)
int m_DebugForcedFinisherType
float m_WeaponRange
WeaponRange used during most recent Update.
void SetTargetObject(Object pTarget)
const float RANGE_EXTENDER_NORMAL
General range extension.
const float TARGETING_ANGLE_SPRINT
Second Pass: Half angle of cone during sprint.
int GetFinisherType()
EMeleeHitType m_HitType
Hit type of the most recent attack.
const float TARGETING_RAY_RADIUS_EX
Second Pass: Max distance from ray projected from player looking direction.
ref array< typename > m_TargetableObjects
Typenames of all directly/preferred targetable objects (1st Pass + 2nd Pass)
const string DEFAULT_HIT_ZONE
DEPRECATED: "HitZoneSelection".
EMeleeTargetType m_TargetType
DEPRECATED: Was added but never used..?
int m_HitZoneIdx
Hit result - cache.
enum EMeleeHitType TARGETING_ANGLE_NORMAL
Target selection settings.
bool CanObjectBeTargeted(Object obj, bool checkNonAligneAble=false)
string m_HitZoneName
Most recent target HitZone name.
void SetFinisherType(int pFinisherType)
int DetermineSpecificFinisherType(ItemBase weapon)
int TrySelectFinisherType(InventoryItem weapon, EntityAI target)
General condition for finisher attacks.
bool IsObstructed(Object object)
DEPRECATED - New function in MeleeTargeting.
InventoryItem m_Weapon
Weapons - cache.
vector m_RayEnd
End position of most recent HitZoneSelectionRaycast.
const float TARGETING_RAY_RADIUS
DEPRECATED: "HitZoneSelection".
void ResetTarget()
float hitFraction
Определения DustKickupEffects.c:23
void CleanupDebugShapes(array< Shape > shapesArr)
DEPRECATED.
Определения DynamicMusicPlayer.c:1038
DiagMenuIDs
Определения EDiagMenuIDs.c:2
EMeleeTargetType
Определения EMeleeTargetType.c:2
@ SPRINT
Определения EStaminaConsumers.c:6
LIGHT
Определения InjurySoundHandler.c:16
HEAVY
Определения InjurySoundHandler.c:18
ref array< typename > TargetableObjects void MeleeTargetSettings(vector coneOrigin, float coneLength, float coneHalfAngle, float coneMinHeight, float coneMaxHeight, vector rayStart, vector dir, float maxDist, EntityAI pToIgnore, array< typename > targetableObjects)
Определения MeleeTargeting.c:36
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
const int windowPosY
Определения PluginPresenceNotifier.c:77
RandomGeneratorSyncUsage
Определения RandomGeneratorSyncManager.c:2
Определения Fence.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения AnimalBase.c:2
Определения ZombieBase.c:2
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
static proto bool RayCastBullet(vector begPos, vector endPos, PhxInteractionLayers layerMask, Object ignoreObj, out Object hitObject, out vector hitPosition, out vector hitNormal, out float hitFraction)
Определения DayZPhysics.c:124
Определения DayZPlayerImplement.c:87
Определения ManBase.c:2
proto native int GetComboCount()
Определения EnEntity.c:165
Определения Feet.c:1
Определения EnMath.c:7
vector HitPos
Определения MeleeTargeting.c:4
int HitComponent
Определения MeleeTargeting.c:5
Object Obj
Определения MeleeTargeting.c:3
Определения MeleeTargeting.c:2
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
proto native void Send()
proto static native bool CanStoreInputUserData()
Returns true when the channel is free, AND the InputBuffer is NOT full (same as '!...
Определения gameplay.c:121
proto bool Write(void value_out)
Определения CarTent.c:2
Native class for boats - handles physics simulation.
Определения Boat.c:29
script counterpart to engine's class Weapon
Определения ZombieFemaleBase.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Определения EnConvert.c:305
static const vector Zero
Определения EnConvert.c:123
proto float Normalize()
Normalizes vector. Returns length.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
Определения EnConvert.c:119
class LOD Object
const int COLOR_BLUE
Определения 1_Core/DayZ/constants.c:66
const int COLOR_RED_A
Определения 1_Core/DayZ/constants.c:71
const int COLOR_RED
Определения 1_Core/DayZ/constants.c:64
const int COLOR_GREEN
Определения 1_Core/DayZ/constants.c:65
const int COLOR_YELLOW_A
Определения 1_Core/DayZ/constants.c:74
const int COLOR_YELLOW
Определения 1_Core/DayZ/constants.c:67
ShapeFlags
Определения EnDebug.c:126
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
void Obsolete(string msg="")
Определения EnScript.c:371
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float SqrFloat(float f)
Returns squared value.
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Round(float f)
Returns mathematical round of value.
static const float RAD2DEG
Определения EnMath.c:16
@ NONE
body is not in simulation, nor in collision world
Определения SimulationState.c:15
proto native volatile void Update()
Определения PlayerSoundManager.c:125
void HumanCommandMelee2()
Определения human.c:595