19class DayZPlayerImplementMeleeCombat
45 protected Object m_PreviousTargetObject;
79 protected int m_PreviousHitZoneIdx;
80 protected string m_PreviousHitZoneName;
81 protected vector m_PreviousHitPositionWS;
84 private int m_DebugForcedFinisherType;
112 #ifdef DIAG_DEVELOPER
116 m_DebugForcedFinisherType = -1;
135 void ~DayZPlayerImplementMeleeCombat() {}
146 void SetHitZoneIdx(
int pHitZone)
156 void SetTargetObject(
Object pTarget)
172 void SetHitPos(
vector pHitPos)
177 int GetFinisherType()
182 void SetFinisherType(
int pFinisherType)
202 #ifdef DIAG_DEVELOPER
210 #ifdef DIAG_DEVELOPER
222 Reset(weapon, hitMask, wasHitEvent);
248 void CheckMeleeItem()
254 if (item && item.GetHierarchyRootPlayer())
256 PlayerBase.Cast(item.GetHierarchyRootPlayer()).SetCheckMeleeItem(item);
274 if (weapon.IsInherited(
Weapon))
292 return weapon.GetMeleeMode();
294 return weapon.GetMeleeHeavyMode();
296 return weapon.GetMeleeSprintMode();
316 return weapon.GetMeleeCombatData().GetModeRange(weaponMode);
318 return m_DZPlayer.GetMeleeCombatData().GetModeRange(weaponMode);
341 vector cameraPos, cameraRot, cameraDir;
342 m_DZPlayer.GetCurrentCameraTransform(cameraPos, cameraDir, cameraRot);
343 vector dir = MiscGameplayFunctions.GetHeadingVector(player);
344 dir[1] = cameraDir[1];
349 float dist2 =
Math.SqrFloat(dist);
356 if (
m_WasHit && GetFinisherType() == -1)
393 MeleeTargetData targetData =
m_MeleeTargeting.GetMeleeTargetEx(
new MeleeTargetSettings(pos, dist*0.75, angle,
TARGETING_MIN_HEIGHT,
TARGETING_MAX_HEIGHT, rayStart, dir,
TARGETING_RAY_RADIUS_EX,
m_DZPlayer,
m_TargetableObjects),
m_AllTargetObjects,
m_BlacklistedDamageZones);
397 SetTarget(targetData.Obj, targetData.HitPos, targetData.HitComponent);
429 float moveFraction =
m_DZPlayer.CollisionMoveTest(dir,
vector.Zero, 1.0, target, hitEntity, hitPos, hitNormal);
430 if (moveFraction < 1.0)
435 if (target && target.CanBeBackstabbed() && weapon && (weapon.IsMeleeFinisher() ||
m_HitType ==
EMeleeHitType.WPN_STAB) && !weapon.IsRuined() )
437 bool playGenericFinisherAnimation =
false;
439 if (targetZombie && m_DebugForcedFinisherType == -1)
442 if (!IsEntityBehindEntityInAngle(
m_DZPlayer, target, 60))
447 int mindState = targetZombie.GetMindStateSynced();
459 playGenericFinisherAnimation = targetZombie.IsCrawling();
461 else if (targetPlayer)
463 playGenericFinisherAnimation = targetPlayer.IsInProne();
467 playGenericFinisherAnimation =
true;
471 if (weapon.IsWeapon())
475 else if (playGenericFinisherAnimation)
490 if (m_DebugForcedFinisherType > -1)
497 return finishers[m_DebugForcedFinisherType];
500 if (!weapon || !weapon.GetValidFinishers() || weapon.GetValidFinishers().Count() == 0)
506 int idx =
Math.Round(
Math.Lerp(0, weapon.GetValidFinishers().Count() - 1, player.GetRandomGeneratorSyncManager().GetRandom01(
RandomGeneratorSyncUsage.RGSGeneric)));
507 return weapon.GetValidFinishers()[idx];
554 player.GetCurrentCameraTransform(pos, dir, cameraRotation);
559 playerDir = MiscGameplayFunctions.GetHeadingVector(player);
560 dir =
GetGame().GetCurrentCameraDirection();
561 MiscGameplayFunctions.GetHeadBonePos(player, pos);
565 if (
vector.Dot(dir, playerDir) < 0.5)
574 set<Object> hitObjects =
new set<Object>;
577 if (
DayZPhysics.RaycastRV(
m_RayStart,
m_RayEnd, hitPos, hitNormal, hitZone, hitObjects, null, player,
false,
false, ObjIntersectIFire) && hitObjects.Count() > 0 )
579 target = hitObjects[0];
584 if (playerTarget && playerTarget.IsInVehicle())
604 Object cursorTarget = null;
609 vector cameraDirection =
GetGame().GetCurrentCameraDirection();
611 MiscGameplayFunctions.GetHeadBonePos(player, pos);
617 set<Object> hitObjects =
new set<Object>;
618 int hitComponentIndex;
620 vector start, end, hitNormal, hitPosObstructed;
623 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) )
628 else if ( hitObjects.Count() > 0 )
630 cursorTarget = hitObjects.Get(0);
672 int hitComponentIndex;
674 vector start, end, hitNormal, hitPosObstructed;
680 MiscGameplayFunctions.GetHeadBonePos(player, start);
681 end = start + MiscGameplayFunctions.GetHeadingVector(player) *
vector.Distance(player.GetPosition(),
object.GetPosition());
686 return DayZPhysics.RayCastBullet( start, end, collisionLayerMask, null, hitObject, hitPosObstructed, hitNormal, hitFraction);
692 private bool IsEntityBehindEntityInAngle(
EntityAI source,
EntityAI target,
float angle)
694 vector targetDirection = target.GetDirection();
696 if (
Class.CastTo(targetZombie, target))
698 targetDirection =
Vector(targetZombie.GetOrientationSynced(),0,0);
699 targetDirection = targetDirection.AnglesToVector();
701 vector toSourceDirection = (source.GetPosition() - target.GetPosition());
703 targetDirection[1] = 0;
704 toSourceDirection[1] = 0;
706 targetDirection.Normalize();
707 toSourceDirection.Normalize();
709 float cosFi =
vector.Dot(targetDirection, toSourceDirection);
710 vector cross = targetDirection * toSourceDirection;
712 int hitDir =
Math.Acos(cosFi) *
Math.RAD2DEG;
717 return hitDir <= (-180 + angle) || hitDir >= (180 - angle);
730 CleanAllDebugShapes();
736 Update(weapon, hitType);
739 ShowDebugMeleeTarget();
746 DrawDebugMeleeHitPosition();
747 DrawDebugMeleeCone();
757 int DebugGetForcedFinisherType()
759 return m_DebugForcedFinisherType;
762 void DebugSetForcedFinisherType(
int pFinisherType)
764 m_DebugForcedFinisherType = pFinisherType;
768 protected void ShowDebugMeleeTarget()
774 HumanCommandMelee2 hmc2 =
m_DZPlayer.GetCommand_Melee2();
777 DbgUI.Text(
"Current combo: " + hmc2.GetComboCount());
780 if (m_PreviousTargetObject)
782 DbgUI.Text(
"Previous Character: " + m_PreviousTargetObject.GetDisplayName());
783 DbgUI.Text(
"Previous HitZone: " + m_PreviousHitZoneName +
"(" + m_PreviousHitZoneIdx +
")");
784 DbgUI.Text(
"Previous HitPosWS:" + m_PreviousHitPositionWS);
785 DbgUI.Text(
"Previous Distance:" +
vector.Distance(m_PreviousHitPositionWS,
m_DZPlayer.GetPosition()));
799 protected void DrawDebugTargets()
805 protected void DrawDebugTargetsHelper(
array<Object> allTargets,
Object target,
int colorMainTarget,
int colorTarget)
807 for (
int i = 0; i < allTargets.Count(); ++i )
811 Object obj = allTargets[i];
812 vector w_pos = obj.GetPosition();
814 vector w_pos_sphr = w_pos;
815 w_pos_sphr[1] = w_pos_sphr[1] + 1.8;
817 vector w_pos_lend = w_pos;
818 w_pos_lend[1] = w_pos_lend[1] + 1.8;
822 dbgTargets.Insert(
Debug.DrawSphere(w_pos_sphr, 0.05, colorMainTarget,
ShapeFlags.NOOUTLINE) );
823 dbgTargets.Insert(
Debug.DrawLine(w_pos, w_pos_lend, colorMainTarget) );
827 dbgTargets.Insert(
Debug.DrawSphere(w_pos_sphr, 0.05, colorTarget,
ShapeFlags.NOOUTLINE) );
828 dbgTargets.Insert(
Debug.DrawLine(w_pos, w_pos_lend, colorTarget) );
834 protected void DrawDebugMeleeHitPosition()
836 if (m_PreviousTargetObject)
843 protected void DrawDebugMeleeCone()
852 float playerAngle = -
Math.Atan2(normDir[0], normDir[2]);
857 protected void DrawDebugBlockCone(
float angle,
int color)
866 float playerAngle = -
Math.Atan2(dir[0], dir[2]);
868 dbgConeShapes.InsertArray(
Debug.DrawCone(start, dist, angle *
Math.DEG2RAD, playerAngle +
Math.PI_HALF, color));
871 protected void CleanAllDebugShapes()
873 CleanupDebugShapes(dbgTargets);
874 CleanupDebugShapes(dbgConeShapes);
875 CleanupDebugShapes(hitPosShapes);
880 for (
int it = 0; it < shapes.Count(); ++it )
881 Debug.RemoveShape( shapes[it] );
Super root of all classes in Enforce script.
Native class for boats - handles physics simulation.
script counterpart to engine's class Weapon
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
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".
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.
const float TARGETING_RAY_DIST_SHORT
DEPRECATED: "HitZoneSelection".
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()
const float TARGETING_MAX_HEIGHT
Second Pass: How high the cone goes in meters from player position.
const float TARGETING_RAY_DIST
DEPRECATED: "HitZoneSelection".
ref MeleeTargeting m_MeleeTargeting
Target selecting "component".
bool m_ForceUntargetable
Misc - cache.
ref array< Object > m_AllTargetObjects
All potential targets found during most recent TargetSelection.
DayZPlayerImplement m_DZPlayer
Parent.
ref array< typename > m_NonAlignableObjects
Typenames of objects that can be targeted, but are not a priority (3rd Pass)
vector m_RayStart
Start position of most recent HitZoneSelectionRaycast.
Object m_TargetObject
Targets - types.
int SelectWeaponMode(InventoryItem weapon)
vector m_HitPositionWS
Most recent target position.
bool HitZoneSelectionRaycastHelper(out vector hitPos, out int hitZone, out Object target)
float m_WeaponRange
WeaponRange used during most recent Update.
const float RANGE_EXTENDER_NORMAL
General range extension.
const float TARGETING_ANGLE_SPRINT
Second Pass: Half angle of cone during sprint.
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.
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".
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
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)
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings