DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ 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

См. определение в файле DayZPlayerImplementMeleeCombat.c строка 544

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 }
DayZGame g_Game
Определения DayZGame.c:4074
bool m_ForceUntargetable
Misc - cache.
float GetRange()
DayZPlayerImplement m_DZPlayer
Parent.
vector m_RayStart
Start position of most recent HitZoneSelectionRaycast.
vector m_RayEnd
End position of most recent HitZoneSelectionRaycast.
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.
Определения DayZPhysics.c:124
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
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
Определения EnConvert.c:119
static proto float SqrFloat(float f)
Returns squared value.

Перекрестные ссылки vector::DistanceSq(), vector::Dot(), g_Game, GetRange(), m_DZPlayer, m_ForceUntargetable, m_RayEnd, m_RayStart, DayZPhysics::RaycastRV(), Math::SqrFloat() и vector::Zero.

Используется в HitZoneSelectionRaycastHelper().