PC Stable Documentation
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Loading...
Searching...
No Matches
DayZPlayerImplementMeleeCombat.c File Reference

Enumerations

enum  EMeleeHitType {
  NONE = -1 , LIGHT , HEAVY , SPRINT ,
  KICK , FINISHER_LIVERSTAB , FINISHER_NECKSTAB , FINISHER_GENERIC ,
  WPN_HIT , WPN_HIT_BUTTSTOCK , WPN_STAB , WPN_STAB_FINISHER
}
 

Functions

void DayZPlayerImplementMeleeCombat (DayZPlayerImplement player)
 
void Init (DayZPlayerImplement player)
 
void ~DayZPlayerImplementMeleeCombat ()
 
EMeleeHitType GetHitType ()
 
void SetHitZoneIdx (int pHitZone)
 
EntityAI GetTargetEntity ()
 
void SetTargetObject (Object pTarget)
 
int GetHitZoneIdx ()
 component idx
 
vector GetHitPos ()
 
void SetHitPos (vector pHitPos)
 
int GetFinisherType ()
 
void SetFinisherType (int pFinisherType)
 
int GetWeaponMode ()
 
void Reset (InventoryItem weapon, EMeleeHitType hitMask, bool wasHitEvent=false)
 
void ResetTarget ()
 
void Update (InventoryItem weapon, EMeleeHitType hitMask, bool wasHitEvent=false)
 
void CheckMeleeItem ()
 
protected int SelectWeaponMode (InventoryItem weapon)
 
protected float GetWeaponRange (InventoryItem weapon, int weaponMode)
 
protected float GetRange ()
 
protected float GetAngle ()
 
protected void TargetSelection ()
 
protected int TrySelectFinisherType (InventoryItem weapon, EntityAI target)
 General condition for finisher attacks.
 
protected int DetermineSpecificFinisherType (ItemBase weapon)
 
protected void InternalResetTarget ()
 
protected void SetTarget (Object obj, vector hitPos, int hitZone)
 
protected bool CanObjectBeTargeted (Object obj, bool checkNonAligneAble=false)
 
protected bool HitZoneSelectionRaycastHelper (out vector hitPos, out int hitZone, out Object target)
 
protected bool HitZoneSelectionRaycast (out vector hitPos, out int hitZone, out Object target, bool useCamera)
 
protected void HitZoneSelection ()
 DEPRECATED.
 
protected bool IsObstructed (Object object)
 DEPRECATED - New function in MeleeTargeting.
 
private bool IsEntityBehindEntityInAngle (EntityAI source, EntityAI target, float angle)
 

Variables

enum EMeleeHitType TARGETING_ANGLE_NORMAL = 30.0
 Target selection settings.
 
protected const float TARGETING_ANGLE_SPRINT = 15.0
 Second Pass: Half angle of cone during sprint.
 
protected const float TARGETING_MIN_HEIGHT = -2.0
 Second Pass: How deep the cone goes in meters from player position.
 
protected const float TARGETING_MAX_HEIGHT = 2.0
 Second Pass: How high the cone goes in meters from player position.
 
protected const float TARGETING_RAY_RADIUS_EX = 0.5
 Second Pass: Max distance from ray projected from player looking direction.
 
protected const float TARGETING_RAY_RADIUS = 0.25
 DEPRECATED: "HitZoneSelection".
 
protected const float TARGETING_RAY_DIST = 5.0
 DEPRECATED: "HitZoneSelection".
 
protected const float TARGETING_RAY_DIST_SHORT = 2.0
 DEPRECATED: "HitZoneSelection".
 
protected const float RANGE_EXTENDER_NORMAL = 0.65
 General range extension.
 
protected const float RANGE_EXTENDER_SPRINT = 1.35
 General range extension while in sprint.
 
protected const string DEFAULT_HIT_ZONE = "Torso"
 DEPRECATED: "HitZoneSelection".
 
protected ref MeleeTargeting m_MeleeTargeting
 Target selecting "component".
 
protected Object m_TargetObject
 Targets - types.
 
protected EMeleeTargetType m_TargetType
 DEPRECATED: Was added but never used..?
 
protected ref array< Objectm_AllTargetObjects
 All potential targets found during most recent TargetSelection.
 
protected ref array< typenamem_TargetableObjects
 Typenames of all directly/preferred targetable objects (1st Pass + 2nd Pass)
 
protected ref array< typenamem_NonAlignableObjects
 Typenames of objects that can be targeted, but are not a priority (3rd Pass)
 
protected ref array< stringm_BlacklistedDamageZones
 List of blacklisted damage zone names (cannot use indices due to the possible changes when p3d components are recalculated)
 
protected DayZPlayerImplement m_DZPlayer
 Parent.
 
protected InventoryItem m_Weapon
 Weapons - cache.
 
protected int m_WeaponMode
 WeaponMode used during most recent Update.
 
protected float m_WeaponRange
 WeaponRange used during most recent Update.
 
protected bool m_ForceUntargetable
 Misc - cache.
 
protected bool m_SprintAttack
 If most recent attack was a sprint attack.
 
protected bool m_WasHit
 If most recent attack was.
 
protected vector m_RayStart
 Start position of most recent HitZoneSelectionRaycast.
 
protected vector m_RayEnd
 End position of most recent HitZoneSelectionRaycast.
 
protected vector m_RayEndShort
 DEPRECATED: "HitZoneSelection".
 
protected EMeleeHitType m_HitType
 Hit type of the most recent attack.
 
protected int m_HitZoneIdx
 Hit result - cache.
 
protected int m_FinisherType
 
protected string m_HitZoneName
 Most recent target HitZone name.
 
protected vector m_HitPositionWS
 Most recent target position.
 
private int m_DebugForcedFinisherType
 

Enumeration Type Documentation

◆ EMeleeHitType

Enumerator
NONE 
LIGHT 
HEAVY 
SPRINT 
KICK 
FINISHER_LIVERSTAB 
FINISHER_NECKSTAB 
FINISHER_GENERIC 
WPN_HIT 
WPN_HIT_BUTTSTOCK 
WPN_STAB 
WPN_STAB_FINISHER 

Function Documentation

◆ CanObjectBeTargeted()

protected bool CanObjectBeTargeted ( Object  obj,
bool  checkNonAligneAble = false 
)

◆ CheckMeleeItem()

void CheckMeleeItem ( )

References GetWeaponMode(), and m_Weapon.

◆ DayZPlayerImplementMeleeCombat()

void DayZPlayerImplementMeleeCombat ( DayZPlayerImplement  player)

References Init().

Referenced by DayZPlayer::DayZPlayerImplement().

◆ DetermineSpecificFinisherType()

protected int DetermineSpecificFinisherType ( ItemBase  weapon)

◆ GetAngle()

protected float GetAngle ( )

◆ GetFinisherType()

int GetFinisherType ( )

References m_FinisherType.

Referenced by TargetSelection().

◆ GetHitPos()

vector GetHitPos ( )

References m_HitPositionWS.

◆ GetHitType()

EMeleeHitType GetHitType ( )

References m_HitType.

◆ GetHitZoneIdx()

int GetHitZoneIdx ( )

component idx

References m_HitZoneIdx.

◆ GetRange()

protected float GetRange ( )

◆ GetTargetEntity()

EntityAI GetTargetEntity ( )

References m_TargetObject.

Referenced by Update().

◆ GetWeaponMode()

int GetWeaponMode ( )

References m_WeaponMode.

Referenced by CheckMeleeItem(), and HitZoneSelection().

◆ GetWeaponRange()

protected float GetWeaponRange ( InventoryItem  weapon,
int  weaponMode 
)

References m_DZPlayer.

Referenced by HitZoneSelection(), and Reset().

◆ HitZoneSelection()

protected void HitZoneSelection ( )

DEPRECATED.

make sure we are in range of the current weapon;

2d only

just for building and transports (big objects)

if no object in cone, set this object from raycast for these special cases

References DEFAULT_HIT_ZONE, vector::Distance(), CGame::GetCurrentCameraDirection(), GetGame(), GetWeaponMode(), GetWeaponRange(), m_DZPlayer, m_HitPositionWS, m_HitZoneIdx, m_HitZoneName, m_NonAlignableObjects, m_RayEnd, m_RayEndShort, m_RayStart, m_TargetObject, m_Weapon, DayZPhysics::RaycastRV(), TARGETING_RAY_DIST, TARGETING_RAY_DIST_SHORT, and TARGETING_RAY_RADIUS.

◆ HitZoneSelectionRaycast()

protected bool HitZoneSelectionRaycast ( out vector  hitPos,
out int  hitZone,
out Object  target,
bool  useCamera 
)

Prevents targeting of objects behind player

Opponent is inside car - targeting range is shorter in that case

References vector::DistanceSq(), vector::Dot(), CGame::GetCurrentCameraDirection(), GetGame(), GetRange(), m_DZPlayer, m_ForceUntargetable, m_RayEnd, m_RayStart, DayZPhysics::RaycastRV(), Math::SqrFloat(), and vector::Zero.

Referenced by HitZoneSelectionRaycastHelper().

◆ HitZoneSelectionRaycastHelper()

protected bool HitZoneSelectionRaycastHelper ( out vector  hitPos,
out int  hitZone,
out Object  target 
)

References HitZoneSelectionRaycast().

Referenced by TargetSelection().

◆ Init()

◆ InternalResetTarget()

protected void InternalResetTarget ( )

◆ IsEntityBehindEntityInAngle()

private bool IsEntityBehindEntityInAngle ( EntityAI  source,
EntityAI  target,
float  angle 
)

◆ IsObstructed()

protected bool IsObstructed ( Object  object)

DEPRECATED - New function in MeleeTargeting.

not possible to trace when this happens (zero length raycast)

References vector::Distance(), m_DZPlayer, and DayZPhysics::RayCastBullet().

◆ Reset()

◆ ResetTarget()

◆ SelectWeaponMode()

protected int SelectWeaponMode ( InventoryItem  weapon)

melee with firearm

melee weapon attacks - gets mode from the item

bare hand melee mode selection

default bare-hand light attack

References m_HitType.

Referenced by Reset().

◆ SetFinisherType()

void SetFinisherType ( int  pFinisherType)

References m_FinisherType.

Referenced by InternalResetTarget(), and Update().

◆ SetHitPos()

void SetHitPos ( vector  pHitPos)

References m_HitPositionWS.

◆ SetHitZoneIdx()

void SetHitZoneIdx ( int  pHitZone)

References m_HitZoneIdx.

◆ SetTarget()

protected void SetTarget ( Object  obj,
vector  hitPos,
int  hitZone 
)

◆ SetTargetObject()

void SetTargetObject ( Object  pTarget)

References m_TargetObject.

◆ TargetSelection()

◆ TrySelectFinisherType()

protected int TrySelectFinisherType ( InventoryItem  weapon,
EntityAI  target 
)

General condition for finisher attacks.

Parameters
weaponWeapon used in the attack
targetTarget entity
Returns
int - type of finisher (-1 == no finisher)

perform only for finisher suitable weapons

check if attacker is in right pos and angle against victim

Check if the infected is aware of the player

prone checks

firearm

References DetermineSpecificFinisherType(), IsEntityBehindEntityInAngle(), m_DebugForcedFinisherType, m_DZPlayer, m_HitType, m_WasHit, and vector::Zero.

Referenced by Update().

◆ Update()

◆ ~DayZPlayerImplementMeleeCombat()

Variable Documentation

◆ DEFAULT_HIT_ZONE

protected const string DEFAULT_HIT_ZONE = "Torso"

DEPRECATED: "HitZoneSelection".

Referenced by HitZoneSelection().

◆ m_AllTargetObjects

protected ref array<Object> m_AllTargetObjects

All potential targets found during most recent TargetSelection.

Referenced by DayZInfected::ChaseAttackLogic(), DayZInfected::FightAttackLogic(), DayZInfected::Init(), Init(), Reset(), and TargetSelection().

◆ m_BlacklistedDamageZones

protected ref array<string> m_BlacklistedDamageZones

List of blacklisted damage zone names (cannot use indices due to the possible changes when p3d components are recalculated)

Referenced by Init(), and TargetSelection().

◆ m_DebugForcedFinisherType

private int m_DebugForcedFinisherType

◆ m_DZPlayer

◆ m_FinisherType

protected int m_FinisherType

◆ m_ForceUntargetable

protected bool m_ForceUntargetable

Misc - cache.

Forcing current target as untargetable

Referenced by HitZoneSelectionRaycast(), and TargetSelection().

◆ m_HitPositionWS

protected vector m_HitPositionWS

◆ m_HitType

◆ m_HitZoneIdx

protected int m_HitZoneIdx

Hit result - cache.

Most recent target HitZone index

Referenced by GetHitZoneIdx(), HitZoneSelection(), Init(), InternalResetTarget(), ResetTarget(), SetHitZoneIdx(), SetTarget(), and Update().

◆ m_HitZoneName

protected string m_HitZoneName

Most recent target HitZone name.

Referenced by HitZoneSelection(), Init(), InternalResetTarget(), ResetTarget(), SetTarget(), and TargetSelection().

◆ m_MeleeTargeting

protected ref MeleeTargeting m_MeleeTargeting

Target selecting "component".

Contains logic for Second Pass

Referenced by Init(), and TargetSelection().

◆ m_NonAlignableObjects

protected ref array<typename> m_NonAlignableObjects

Typenames of objects that can be targeted, but are not a priority (3rd Pass)

Referenced by CanObjectBeTargeted(), HitZoneSelection(), and Init().

◆ m_RayEnd

protected vector m_RayEnd

End position of most recent HitZoneSelectionRaycast.

Referenced by HitZoneSelection(), and HitZoneSelectionRaycast().

◆ m_RayEndShort

protected vector m_RayEndShort

DEPRECATED: "HitZoneSelection".

Referenced by HitZoneSelection().

◆ m_RayStart

protected vector m_RayStart

Start position of most recent HitZoneSelectionRaycast.

Referenced by HitZoneSelection(), and HitZoneSelectionRaycast().

◆ m_SprintAttack

protected bool m_SprintAttack

If most recent attack was a sprint attack.

Referenced by GetAngle(), Init(), and Reset().

◆ m_TargetableObjects

protected ref array<typename> m_TargetableObjects

Typenames of all directly/preferred targetable objects (1st Pass + 2nd Pass)

Referenced by CanObjectBeTargeted(), DayZInfected::ChaseAttackLogic(), DayZInfected::FightAttackLogic(), DayZInfected::Init(), Init(), and TargetSelection().

◆ m_TargetObject

◆ m_TargetType

protected EMeleeTargetType m_TargetType

DEPRECATED: Was added but never used..?

Referenced by Init(), and Reset().

◆ m_WasHit

protected bool m_WasHit

If most recent attack was.

Referenced by Init(), Reset(), TargetSelection(), and TrySelectFinisherType().

◆ m_Weapon

◆ m_WeaponMode

protected int m_WeaponMode

WeaponMode used during most recent Update.

Referenced by GetWeaponMode(), and Reset().

◆ m_WeaponRange

protected float m_WeaponRange

WeaponRange used during most recent Update.

Referenced by GetRange(), and Reset().

◆ RANGE_EXTENDER_NORMAL

protected const float RANGE_EXTENDER_NORMAL = 0.65

General range extension.

Referenced by GetRange().

◆ RANGE_EXTENDER_SPRINT

protected const float RANGE_EXTENDER_SPRINT = 1.35

General range extension while in sprint.

◆ TARGETING_ANGLE_NORMAL

enum EMeleeHitType TARGETING_ANGLE_NORMAL = 30.0

Target selection settings.

Second Pass: Half angle of cone

Referenced by GetAngle().

◆ TARGETING_ANGLE_SPRINT

protected const float TARGETING_ANGLE_SPRINT = 15.0

Second Pass: Half angle of cone during sprint.

Referenced by GetAngle().

◆ TARGETING_MAX_HEIGHT

protected const float TARGETING_MAX_HEIGHT = 2.0

Second Pass: How high the cone goes in meters from player position.

Referenced by TargetSelection().

◆ TARGETING_MIN_HEIGHT

protected const float TARGETING_MIN_HEIGHT = -2.0

Second Pass: How deep the cone goes in meters from player position.

Referenced by TargetSelection().

◆ TARGETING_RAY_DIST

protected const float TARGETING_RAY_DIST = 5.0

DEPRECATED: "HitZoneSelection".

Referenced by HitZoneSelection().

◆ TARGETING_RAY_DIST_SHORT

protected const float TARGETING_RAY_DIST_SHORT = 2.0

DEPRECATED: "HitZoneSelection".

Referenced by HitZoneSelection().

◆ TARGETING_RAY_RADIUS

protected const float TARGETING_RAY_RADIUS = 0.25

DEPRECATED: "HitZoneSelection".

Referenced by HitZoneSelection().

◆ TARGETING_RAY_RADIUS_EX

protected const float TARGETING_RAY_RADIUS_EX = 0.5

Second Pass: Max distance from ray projected from player looking direction.

Referenced by TargetSelection().