45 protected Object m_PreviousTargetObject;
79 protected int m_PreviousHitZoneIdx;
80 protected string m_PreviousHitZoneName;
81 protected vector m_PreviousHitPositionWS;
112 #ifdef DIAG_DEVELOPER
202 #ifdef DIAG_DEVELOPER
210 #ifdef DIAG_DEVELOPER
222 Reset(weapon, hitMask, wasHitEvent);
235 if (
g_Game.IsMultiplayer())
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];
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);
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;
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)
500 if (!weapon || !weapon.GetValidFinishers() || weapon.GetValidFinishers().Count() == 0)
507 return weapon.GetValidFinishers()[idx];
554 player.GetCurrentCameraTransform(pos, dir, cameraRotation);
559 playerDir = MiscGameplayFunctions.GetHeadingVector(player);
560 dir =
g_Game.GetCurrentCameraDirection();
562 pos = MiscGameplayFunctions.GetPlayerHeadPosition(player);
575 set<Object> hitObjects =
new set<Object>;
578 if (
DayZPhysics.
RaycastRV(
m_RayStart,
m_RayEnd, hitPos, hitNormal, hitZone, hitObjects, null, player,
false,
false, ObjIntersectIFire) && hitObjects.Count() > 0 )
580 target = hitObjects[0];
585 if (playerTarget && playerTarget.IsInVehicle())
603 [
Obsolete(
"replaced by HitZoneSelectionRaycast")]
606 Object cursorTarget = null;
611 vector cameraDirection =
g_Game.GetCurrentCameraDirection();
613 MiscGameplayFunctions.GetHeadBonePos(player, pos);
619 set<Object> hitObjects =
new set<Object>;
620 int hitComponentIndex;
622 vector start, end, hitNormal, hitPosObstructed;
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) )
630 else if ( hitObjects.Count() > 0 )
632 cursorTarget = hitObjects.Get(0);
670 [
Obsolete(
"replaced by MeleeTargeting.IsMeleeTargetObstructed")]
675 int hitComponentIndex;
677 vector start, end, hitNormal, hitPosObstructed;
683 MiscGameplayFunctions.GetHeadBonePos(player, start);
684 end = start + MiscGameplayFunctions.GetHeadingVector(player) *
vector.
Distance(player.GetPosition(),
object.GetPosition());
697 vector targetDirection = target.GetDirection();
701 targetDirection =
Vector(targetZombie.GetOrientationSynced(),0,0);
704 vector toSourceDirection = (source.GetPosition() - target.GetPosition());
706 targetDirection[1] = 0;
707 toSourceDirection[1] = 0;
712 float cosFi =
vector.
Dot(targetDirection, toSourceDirection);
713 vector cross = targetDirection * toSourceDirection;
720 return hitDir <= (-180 + angle) || hitDir >= (180 - angle);
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>();
733 CleanAllDebugShapes();
741 if (DiagMenu.GetBool(
DiagMenuIDs.MELEE_SHOW_TARGETS))
742 ShowDebugMeleeTarget();
744 if (DiagMenu.GetBool(
DiagMenuIDs.MELEE_DRAW_TARGETS))
747 if (DiagMenu.GetBool(
DiagMenuIDs.MELEE_DRAW_RANGE))
749 DrawDebugMeleeHitPosition();
750 DrawDebugMeleeCone();
753 if (DiagMenu.GetBool(
DiagMenuIDs.MELEE_DRAW_BLOCK_RANGE_AI))
754 DrawDebugBlockCone(GameConstants.AI_MAX_BLOCKABLE_ANGLE,
COLOR_GREEN);
756 if (DiagMenu.GetBool(
DiagMenuIDs.MELEE_DRAW_BLOCK_RANGE_PVP))
757 DrawDebugBlockCone(GameConstants.PVP_MAX_BLOCKABLE_ANGLE,
COLOR_YELLOW);
760 int DebugGetForcedFinisherType()
765 void DebugSetForcedFinisherType(
int pFinisherType)
771 protected void ShowDebugMeleeTarget()
783 if (m_PreviousTargetObject)
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()));
802 protected void DrawDebugTargets()
808 protected void DrawDebugTargetsHelper(array<Object> allTargets,
Object target,
int colorMainTarget,
int colorTarget)
810 for (
int i = 0; i < allTargets.Count(); ++i )
814 Object obj = allTargets[i];
815 vector w_pos = obj.GetPosition();
817 vector w_pos_sphr = w_pos;
818 w_pos_sphr[1] = w_pos_sphr[1] + 1.8;
820 vector w_pos_lend = w_pos;
821 w_pos_lend[1] = w_pos_lend[1] + 1.8;
825 dbgTargets.Insert(
Debug.DrawSphere(w_pos_sphr, 0.05, colorMainTarget,
ShapeFlags.NOOUTLINE) );
826 dbgTargets.Insert(
Debug.DrawLine(w_pos, w_pos_lend, colorMainTarget) );
830 dbgTargets.Insert(
Debug.DrawSphere(w_pos_sphr, 0.05, colorTarget,
ShapeFlags.NOOUTLINE) );
831 dbgTargets.Insert(
Debug.DrawLine(w_pos, w_pos_lend, colorTarget) );
837 protected void DrawDebugMeleeHitPosition()
839 if (m_PreviousTargetObject)
846 protected void DrawDebugMeleeCone()
852 vector normDir = MiscGameplayFunctions.GetHeadingVector(PlayerBase.Cast(
m_DZPlayer));
855 float playerAngle = -Math.Atan2(normDir[0], normDir[2]);
857 dbgConeShapes.InsertArray(
Debug.DrawCone(start, dist,
GetAngle() * Math.DEG2RAD, playerAngle + Math.PI_HALF,
COLOR_BLUE));
860 protected void DrawDebugBlockCone(
float angle,
int color)
866 vector dir =
g_Game.GetCurrentCameraDirection();
869 float playerAngle = -Math.Atan2(dir[0], dir[2]);
871 dbgConeShapes.InsertArray(
Debug.DrawCone(start, dist, angle * Math.DEG2RAD, playerAngle + Math.PI_HALF, color));
874 protected void CleanAllDebugShapes()
883 for (
int it = 0; it < shapes.Count(); ++it )
885 Shape shape = shapes[it];
886 Debug.RemoveShape( shape );
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.
const float TARGETING_RAY_DIST_SHORT
DEPRECATED: "HitZoneSelection".
bool IsEntityBehindEntityInAngle(EntityAI source, EntityAI target, float angle)
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)
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".
bool m_ForceUntargetable
Misc - cache.
ref array< Object > m_AllTargetObjects
All potential targets found during most recent TargetSelection.
void ~DayZPlayerImplementMeleeCombat()
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.
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.
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 CleanupDebugShapes(array< Shape > shapesArr)
DEPRECATED.
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
Super root of all classes in Enforce script.
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)
proto native int GetComboCount()
proto bool Write(void value_out)
Native class for boats - handles physics simulation.
script counterpart to engine's class Weapon
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.
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.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
void Obsolete(string msg="")
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
@ NONE
body is not in simulation, nor in collision world
void HumanCommandMelee2()