Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
dayzplayerimplementmeleecombat.c File Reference

Go to the source code of this file.

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

Variables

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

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 

Definition at line 1 of file dayzplayerimplementmeleecombat.c.

Function Documentation

◆ ~DayZPlayerImplementMeleeCombat()

void ~DayZPlayerImplementMeleeCombat ( )
private

Definition at line 135 of file dayzplayerimplementmeleecombat.c.

◆ CanObjectBeTargeted()

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

Definition at line 530 of file dayzplayerimplementmeleecombat.c.

References m_NonAlignableObjects, and m_TargetableObjects.

Referenced by TargetSelection().

◆ CheckMeleeItem()

void CheckMeleeItem ( )
private

Definition at line 248 of file dayzplayerimplementmeleecombat.c.

References GetWeaponMode(), and m_Weapon.

◆ DayZPlayerImplementMeleeCombat()

void DayZPlayerImplementMeleeCombat ( DayZPlayerImplement player)
private

◆ DetermineSpecificFinisherType()

int DetermineSpecificFinisherType ( ItemBase weapon)
protected

◆ GetAngle()

float GetAngle ( )
protected

◆ GetFinisherType()

int GetFinisherType ( )
private

Definition at line 177 of file dayzplayerimplementmeleecombat.c.

References m_FinisherType.

Referenced by TargetSelection().

◆ GetHitPos()

vector GetHitPos ( )
private

Definition at line 167 of file dayzplayerimplementmeleecombat.c.

References m_HitPositionWS.

◆ GetHitType()

EMeleeHitType GetHitType ( )
private

Definition at line 141 of file dayzplayerimplementmeleecombat.c.

References m_HitType.

◆ GetHitZoneIdx()

int GetHitZoneIdx ( )
private

component idx

Definition at line 162 of file dayzplayerimplementmeleecombat.c.

References m_HitZoneIdx.

◆ GetRange()

float GetRange ( )
protected

◆ GetTargetEntity()

EntityAI GetTargetEntity ( )
private

Definition at line 151 of file dayzplayerimplementmeleecombat.c.

References m_TargetObject.

Referenced by Update().

◆ GetWeaponMode()

int GetWeaponMode ( )
private

Definition at line 187 of file dayzplayerimplementmeleecombat.c.

References m_WeaponMode.

Referenced by CheckMeleeItem(), and HitZoneSelection().

◆ GetWeaponRange()

float GetWeaponRange ( InventoryItem weapon,
int weaponMode )
protected

Definition at line 313 of file dayzplayerimplementmeleecombat.c.

References m_DZPlayer.

Referenced by HitZoneSelection(), and Reset().

◆ HitZoneSelection()

void HitZoneSelection ( )
protected

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

Definition at line 602 of file dayzplayerimplementmeleecombat.c.

References DEFAULT_HIT_ZONE, vector::Distance(), g_Game, 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()

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

Prevents targeting of objects behind player

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

Definition at line 544 of file dayzplayerimplementmeleecombat.c.

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

Referenced by HitZoneSelectionRaycastHelper().

◆ HitZoneSelectionRaycastHelper()

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

Definition at line 535 of file dayzplayerimplementmeleecombat.c.

References HitZoneSelectionRaycast().

Referenced by TargetSelection().

◆ Init()

◆ InternalResetTarget()

void InternalResetTarget ( )
protected

◆ IsEntityBehindEntityInAngle()

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

◆ IsObstructed()

bool IsObstructed ( Object object)
protected

DEPRECATED - New function in MeleeTargeting.

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

Definition at line 668 of file dayzplayerimplementmeleecombat.c.

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

◆ Reset()

void Reset ( InventoryItem weapon,
EMeleeHitType hitMask,
bool wasHitEvent = false )
private

◆ ResetTarget()

void ResetTarget ( )
private

◆ SelectWeaponMode()

int SelectWeaponMode ( InventoryItem weapon)
protected

melee with firearm

melee weapon attacks - gets mode from the item

bare hand melee mode selection

default bare-hand light attack

Definition at line 269 of file dayzplayerimplementmeleecombat.c.

References m_HitType.

Referenced by Reset().

◆ SetFinisherType()

void SetFinisherType ( int pFinisherType)
private

Definition at line 182 of file dayzplayerimplementmeleecombat.c.

References m_FinisherType.

Referenced by InternalResetTarget(), and Update().

◆ SetHitPos()

void SetHitPos ( vector pHitPos)
private

Definition at line 172 of file dayzplayerimplementmeleecombat.c.

References m_HitPositionWS.

◆ SetHitZoneIdx()

void SetHitZoneIdx ( int pHitZone)
private

Definition at line 146 of file dayzplayerimplementmeleecombat.c.

References m_HitZoneIdx.

◆ SetTarget()

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

◆ SetTargetObject()

void SetTargetObject ( Object pTarget)
private

Definition at line 156 of file dayzplayerimplementmeleecombat.c.

References m_TargetObject.

◆ TargetSelection()

◆ TrySelectFinisherType()

int TrySelectFinisherType ( InventoryItem weapon,
EntityAI target )
protected

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

Definition at line 417 of file dayzplayerimplementmeleecombat.c.

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

Referenced by Update().

◆ Update()

Variable Documentation

◆ DEFAULT_HIT_ZONE

const string DEFAULT_HIT_ZONE = "Torso"
protected

DEPRECATED: "HitZoneSelection".

Definition at line 34 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelection().

◆ m_AllTargetObjects

ref array<Object> m_AllTargetObjects
protected

All potential targets found during most recent TargetSelection.

Definition at line 42 of file dayzplayerimplementmeleecombat.c.

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

◆ m_BlacklistedDamageZones

ref array<string> m_BlacklistedDamageZones
protected

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

Definition at line 51 of file dayzplayerimplementmeleecombat.c.

Referenced by Init(), and TargetSelection().

◆ m_DebugForcedFinisherType

int m_DebugForcedFinisherType
private

◆ m_DZPlayer

◆ m_FinisherType

int m_FinisherType
protected

Definition at line 74 of file dayzplayerimplementmeleecombat.c.

Referenced by GetFinisherType(), Init(), SetFinisherType(), and Update().

◆ m_ForceUntargetable

bool m_ForceUntargetable
protected

Misc - cache.

Forcing current target as untargetable

Definition at line 62 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelectionRaycast(), and TargetSelection().

◆ m_HitPositionWS

vector m_HitPositionWS
protected

Most recent target position.

Definition at line 76 of file dayzplayerimplementmeleecombat.c.

Referenced by GetHitPos(), HitZoneSelection(), Init(), InternalResetTarget(), ResetTarget(), SetHitPos(), SetTarget(), and Update().

◆ m_HitType

◆ m_HitZoneIdx

int m_HitZoneIdx
protected

Hit result - cache.

Most recent target HitZone index

Definition at line 73 of file dayzplayerimplementmeleecombat.c.

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

◆ m_HitZoneName

string m_HitZoneName
protected

Most recent target HitZone name.

Definition at line 75 of file dayzplayerimplementmeleecombat.c.

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

◆ m_MeleeTargeting

ref MeleeTargeting m_MeleeTargeting
protected

Target selecting "component".

Contains logic for Second Pass

Definition at line 37 of file dayzplayerimplementmeleecombat.c.

Referenced by Init(), and TargetSelection().

◆ m_NonAlignableObjects

ref array<typename> m_NonAlignableObjects
protected

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

Definition at line 50 of file dayzplayerimplementmeleecombat.c.

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

◆ m_RayEnd

vector m_RayEnd
protected

End position of most recent HitZoneSelectionRaycast.

Definition at line 67 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelection(), HitZoneSelectionRaycast(), and Remove().

◆ m_RayEndShort

vector m_RayEndShort
protected

DEPRECATED: "HitZoneSelection".

Definition at line 68 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelection().

◆ m_RayStart

vector m_RayStart
protected

Start position of most recent HitZoneSelectionRaycast.

Definition at line 66 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelection(), HitZoneSelectionRaycast(), Remove(), and Remove().

◆ m_SprintAttack

bool m_SprintAttack
protected

If most recent attack was a sprint attack.

Definition at line 63 of file dayzplayerimplementmeleecombat.c.

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

◆ m_TargetableObjects

ref array<typename> m_TargetableObjects
protected

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

Definition at line 49 of file dayzplayerimplementmeleecombat.c.

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

◆ m_TargetObject

Object m_TargetObject
protected

Targets - types.

Main target found during most recent TargetSelection

Definition at line 40 of file dayzplayerimplementmeleecombat.c.

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

◆ m_TargetType

EMeleeTargetType m_TargetType
protected

DEPRECATED: Was added but never used..?

Definition at line 41 of file dayzplayerimplementmeleecombat.c.

Referenced by Init(), and Reset().

◆ m_WasHit

bool m_WasHit
protected

If most recent attack was.

Definition at line 64 of file dayzplayerimplementmeleecombat.c.

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

◆ m_Weapon

InventoryItem m_Weapon
protected

Weapons - cache.

Weapon used during most recent Update

Definition at line 57 of file dayzplayerimplementmeleecombat.c.

Referenced by CheckMeleeItem(), HitZoneSelection(), and Reset().

◆ m_WeaponMode

int m_WeaponMode
protected

WeaponMode used during most recent Update.

Definition at line 58 of file dayzplayerimplementmeleecombat.c.

Referenced by GetWeaponMode(), and Reset().

◆ m_WeaponRange

float m_WeaponRange
protected

WeaponRange used during most recent Update.

Definition at line 59 of file dayzplayerimplementmeleecombat.c.

Referenced by GetRange(), and Reset().

◆ RANGE_EXTENDER_NORMAL

const float RANGE_EXTENDER_NORMAL = 0.65
protected

General range extension.

Definition at line 31 of file dayzplayerimplementmeleecombat.c.

Referenced by GetRange().

◆ RANGE_EXTENDER_SPRINT

const float RANGE_EXTENDER_SPRINT = 1.35
protected

General range extension while in sprint.

Definition at line 32 of file dayzplayerimplementmeleecombat.c.

◆ 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

const float TARGETING_ANGLE_SPRINT = 15.0
protected

Second Pass: Half angle of cone during sprint.

Definition at line 23 of file dayzplayerimplementmeleecombat.c.

Referenced by GetAngle().

◆ TARGETING_MAX_HEIGHT

const float TARGETING_MAX_HEIGHT = 2.0
protected

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

Definition at line 25 of file dayzplayerimplementmeleecombat.c.

Referenced by TargetSelection().

◆ TARGETING_MIN_HEIGHT

const float TARGETING_MIN_HEIGHT = -2.0
protected

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

Definition at line 24 of file dayzplayerimplementmeleecombat.c.

Referenced by TargetSelection().

◆ TARGETING_RAY_DIST

const float TARGETING_RAY_DIST = 5.0
protected

DEPRECATED: "HitZoneSelection".

Definition at line 28 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelection().

◆ TARGETING_RAY_DIST_SHORT

const float TARGETING_RAY_DIST_SHORT = 2.0
protected

DEPRECATED: "HitZoneSelection".

Definition at line 29 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelection().

◆ TARGETING_RAY_RADIUS

const float TARGETING_RAY_RADIUS = 0.25
protected

DEPRECATED: "HitZoneSelection".

Definition at line 27 of file dayzplayerimplementmeleecombat.c.

Referenced by HitZoneSelection().

◆ TARGETING_RAY_RADIUS_EX

const float TARGETING_RAY_RADIUS_EX = 0.5
protected

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

Definition at line 26 of file dayzplayerimplementmeleecombat.c.

Referenced by TargetSelection().