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

Закрытые члены

void ActionTargets (PlayerBase player)
 
void Clear ()
 
void Update ()
 
bool IsObstructed (Object object)
 
bool IsObstructedEx (Object object, IsObjectObstructedCache cache)
 
int GetTargetsCount ()
 returns count of founded targets
 
ActionTarget GetTarget (int index)
 returns action target at index
 
void StoreTarget (ActionTarget pActionTarget)
 inserts action into sorted array based on utility
 
int FindIndexForStoring (float value)
 binary search algorithm
 
float ComputeUtility (Object pTarget, vector pRayStart, vector pRayEnd, Object cursorTarget, vector hitPos)
 computes utility of target
 
float DistSqrPoint2Line (vector pPoint, vector pL1, vector pL2)
 distance between point and line
 
void FilterObstructedObjectsEx (Object cursor_target, array< Object > vicinityObjects)
 
void FilterObstructedObjects (Object cursor_target)
 
vector CalculateRayStart ()
 DEPRECATED.
 

Закрытые статические члены

static array< ObjectGetVicinityObjects ()
 

Закрытые данные

PlayerBase m_Player
 player owner
 
ref array< ref ActionTargetm_Targets
 selected & sorted targets by utility function
 
vector m_RayEnd
 
vector m_HitPos
 
const float c_RayDistance = 5.0
 searching properties
 
const float c_MaxTargetDistance = 3.0
 
const float c_MaxActionDistance = UAMaxDistances.DEFAULT
 
const float c_ConeAngle = 30.0
 
const float c_ConeHeightMin = -0.5
 
const float c_ConeHeightMax = 2.0
 
const float c_DistanceDelta = 0.3
 
const float c_UtilityMaxValue = 10000
 utility constants
 
const float c_UtilityMaxDistFromRaySqr = 0.8 * 0.8
 
const string CE_CENTER = "ce_center"
 p3d
 
const float HEIGHT_OFFSET = 0.2
 
const int OBSTRUCTED_COUNT_THRESHOLD = 3
 misc
 
const int GROUPING_COUNT_THRESHOLD = 10
 

Закрытые статические данные

vector m_RayStart
 objects in vicinity
 

Подробное описание

Конструктор(ы)

◆ ActionTargets()

void ActionTargets ( PlayerBase player)
inlineprivate
176 {
180
181 m_Debug = false;
182 }
void VicinityObjects()
Definition ActionTargets.c:116
ref map< Object, Object > m_VicinityObjects
Definition ActionTargets.c:114
PlayerBase m_Player
player owner
Definition ActionTargets.c:708
ref array< ref ActionTarget > m_Targets
selected & sorted targets by utility function
Definition ActionTargets.c:711
Definition EntityAI.c:95

Перекрестные ссылки m_Player, m_VicinityObjects и VicinityObjects().

Методы

◆ CalculateRayStart()

vector CalculateRayStart ( )
private

DEPRECATED.

◆ Clear()

void Clear ( )
inlineprivate
190 {
191 m_Targets.Clear();
192 }

◆ ComputeUtility()

float ComputeUtility ( Object pTarget,
vector pRayStart,
vector pRayEnd,
Object cursorTarget,
vector hitPos )
inlineprivate

computes utility of target

out of reach

ground and static objects

basebuilding objects

407 {
410 return -1;
411
412 if (pTarget)
413 {
414 if ( pTarget == cursorTarget )
415 {
417 if ( pTarget.GetType() == string.Empty )
418 return 0.01;
419
420 if ( pTarget.IsBuilding() )
421 return 0.25;
422
423 if ( pTarget.IsTransport() )
424 return 0.25;
425
427 if (pTarget.CanUseConstruction())
428 return 0.85;
429
430 if ( pTarget.IsWell() )
431 return 0.9;
432
433 vector playerPosXZ = m_Player.GetPosition();
435 playerPosXZ[1] = 0;
436 hitPosXZ[1] = 0;
438 return c_UtilityMaxValue;
439 }
440
441 float distSqr = DistSqrPoint2Line(pTarget.GetPosition(), pRayStart, pRayEnd);
443 }
444
445 return -1;
446 }
const float c_MaxTargetDistance
Definition ActionTargets.c:727
float DistSqrPoint2Line(vector pPoint, vector pL1, vector pL2)
distance between point and line
Definition ActionTargets.c:449
const float c_UtilityMaxDistFromRaySqr
Definition ActionTargets.c:736
const float c_UtilityMaxValue
utility constants
Definition ActionTargets.c:735
Definition EnConvert.c:106
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.

Перекрестные ссылки c_MaxTargetDistance, c_UtilityMaxDistFromRaySqr, c_UtilityMaxValue, vector::DistanceSq(), DistSqrPoint2Line() и m_Player.

◆ DistSqrPoint2Line()

float DistSqrPoint2Line ( vector pPoint,
vector pL1,
vector pL2 )
inlineprivate

distance between point and line

450 {
451 vector v = pL2 - pL1;
452 vector w = pPoint - pL1;
453
454 float c1 = vector.Dot(w,v);
455 float c2 = vector.Dot(v,v);
456
457 if ( c1 <= 0 || c2 == 0 )
458 return vector.DistanceSq(pPoint, pL1);
459
460 float b = c1 / c2;
461 vector nearestPoint = pL1 + (v * b);
463 }
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271

Перекрестные ссылки vector::DistanceSq() и vector::Dot().

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

◆ FilterObstructedObjects()

void FilterObstructedObjects ( Object cursor_target)
inlineprivate

check if targets are not obstructed (eg.: wall)

check for object obstruction(if the object is not a proxy - has no parent)

when the number of obstructed items is higher than OBSTRUCTED_COUNT_THRESHOLD remove do no run obstruction check and skip these items

obstruction check

497 {
498 int numObstructed = 0;
499 int mCount = m_VicinityObjects.Count();
501 mCount--;
502
504 for ( int i = mCount; i >= 0; --i )
505 {
506 Object object = m_VicinityObjects.GetObject(i);
507 Object parent = m_VicinityObjects.GetParent(i);
508
510 if (object && !parent)
511 {
515 {
516 m_VicinityObjects.Remove(object);
517 continue;
518 }
519
521 if (object != cursor_target && IsObstructedEx(object, cache))
522 {
523 m_VicinityObjects.Remove(object);
525 }
526
527 cache.ClearCache();
528 }
529 }
530 }
void IsObjectObstructedCache(vector rayCastStart, int totalObjects)
Definition MiscGameplayFunctions.c:1843
bool IsObstructedEx(Object object, IsObjectObstructedCache cache)
Definition ActionTargets.c:363
const int OBSTRUCTED_COUNT_THRESHOLD
misc
Definition ActionTargets.c:743
vector m_RayStart
objects in vicinity
Definition ActionTargets.c:718
Definition ObjectTyped.c:2

Перекрестные ссылки IsObjectObstructedCache(), IsObstructedEx(), m_RayStart, m_VicinityObjects и OBSTRUCTED_COUNT_THRESHOLD.

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

◆ FilterObstructedObjectsEx()

void FilterObstructedObjectsEx ( Object cursor_target,
array< Object > vicinityObjects )
inlineprivate
466 {
467 #ifdef DIAG_DEVELOPER
468 if (DiagMenu.GetBool(DiagMenuIDs.MISC_ACTION_TARGETS_DEBUG))
469 CleanupDebugShapes(obstruction);
470 #endif
471
474
475 if ( obstructingObjects.Count() > 0 )
476 {
477 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
478
479 int numObstructed = 0;
480 int mCount = m_VicinityObjects.Count();
481
483 {
485 MiscGameplayFunctions.FilterObstructedObjectsByGrouping(m_RayStart, c_MaxTargetDistance, c_DistanceDelta, m_VicinityObjects.GetRawVicinityObjects(), vicinityObjects, filteredObjects);
486 m_VicinityObjects.ClearVicinityObjects();
487 m_VicinityObjects.TransformToVicinityObjects(filteredObjects);
488 }
489 else
490 {
492 }
493 }
494 }
DayZGame g_Game
Definition DayZGame.c:3815
DiagMenuIDs
Definition EDiagMenuIDs.c:2
const int GROUPING_COUNT_THRESHOLD
Definition ActionTargets.c:744
const float c_DistanceDelta
Definition ActionTargets.c:732
void FilterObstructedObjects(Object cursor_target)
Definition ActionTargets.c:496
Definition EnDebug.c:233
Definition PlayerBaseClient.c:2
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.

Перекрестные ссылки c_DistanceDelta, c_MaxTargetDistance, FilterObstructedObjects(), g_Game, DiagMenu::GetBool(), GROUPING_COUNT_THRESHOLD, m_RayStart и m_VicinityObjects.

◆ FindIndexForStoring()

int FindIndexForStoring ( float value)
inlineprivate

binary search algorithm

386 {
387 int left = 0;
388 int right = m_Targets.Count() - 1;
389 while ( left <= right )
390 {
391 int middle = (left + right) / 2;
392 float middleValue = m_Targets.Get(middle).GetUtility();
393
394 if ( middleValue == value )
395 return middle;
396 else if ( middleValue < value )
397 right = middle - 1;
398 else
399 left = middle + 1;
400 }
401
402 return left;
403 }

Перекрестные ссылки m_Targets.

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

◆ GetTarget()

ActionTarget GetTarget ( int index)
inlineprivate

returns action target at index

374 { return m_Targets.Get(index); }

Перекрестные ссылки m_Targets.

◆ GetTargetsCount()

int GetTargetsCount ( )
inlineprivate

returns count of founded targets

370 { return m_Targets.Count(); }

Перекрестные ссылки m_Targets.

◆ GetVicinityObjects()

static array< Object > GetVicinityObjects ( )
inlinestaticprivate
185 {
186 return m_VicinityObjects.GetVicinityObjects();
187 }

Перекрестные ссылки m_VicinityObjects.

◆ IsObstructed()

bool IsObstructed ( Object object)
inlineprivate
358 {
360 return IsObstructedEx(object, cache);
361 }

Перекрестные ссылки IsObjectObstructedCache(), IsObstructedEx() и m_RayStart.

◆ IsObstructedEx()

bool IsObstructedEx ( Object object,
IsObjectObstructedCache cache )
inlineprivate
364 {
365 return MiscGameplayFunctions.IsObjectObstructedEx(object, cache);
366 }

Используется в FilterObstructedObjects() и IsObstructed().

◆ StoreTarget()

void StoreTarget ( ActionTarget pActionTarget)
inlineprivate

inserts action into sorted array based on utility

378 {
379 int index = FindIndexForStoring(pActionTarget.GetUtility());
380 m_Targets.InsertAt(pActionTarget, index);
381 //Print("StoreTarget; object: " + pActionTarget.GetObject() + " | parent: " + pActionTarget.GetParent() + " | idx: " + index);
382 }
int FindIndexForStoring(float value)
binary search algorithm
Definition ActionTargets.c:385

Перекрестные ссылки FindIndexForStoring() и m_Targets.

◆ Update()

void Update ( )
inlineprivate

clear state

camera & ray properties

if the cursor target is a proxy

ignores attachments on player

spacial search

removes player from the vicinity

transformation of array of Objects to hashmap (VicinityObjects)

removes Vicinity objects that are not directly visible from player position

select & sort targets based on utility function

action target for surface actions (lowest utility)

195 {
196 int i;
197
199 m_VicinityObjects.ClearVicinityObjects();
200 Clear();
201
205
208 vector playerPos = m_Player.GetPosition();
210
211 m_RayStart = GetGame().GetCurrentCameraPosition();
212 m_RayEnd = m_RayStart + GetGame().GetCurrentCameraDirection() * c_RayDistance;
213
215 rayInput.flags = CollisionFlags.ALLOBJECTS;
216 //rayInput.sorted = true;
218
220 {
221 if ( results.Count() > 0 )
222 {
225 float distance;
226
227 for (i = 0; i < results.Count(); i++)
228 {
231 //Print("#" + i + " " + results.Get(i).obj);
232 }
233 //Print("--------------");
235 distance_helper.Sort();
236
238
239
240 for ( i = 0; i < results.Count(); i++)
241 {
242 res = results.Get(distance_helper_unsorted.Find(distance_helper[i])); //closest object
243
244 cursorTarget = res.obj;
246 if (cursorTarget && !cursorTarget.CanBeActionTarget())
247 continue;
249 if ( res.hierLevel > 0 )
250 {
252 if ( !res.parent.IsMan() )
253 {
254 m_VicinityObjects.StoreVicinityObject(res.obj, res.parent);
255 //Print("storing, 1st pass (hier > 0): " + res.obj);
256 }
257 else
258 continue;
259 }
260 else
261 {
262 m_VicinityObjects.StoreVicinityObject(res.obj, null);
263 //Print("storing, 1st pass: " + res.obj);
264 }
265
266 m_HitPos = res.pos;
267 hitComponentIndex = res.component;
268 break;
269 }
270 }
271 //else
272 //Print("NO RESULTS FOUND!");
273 }
274 else
275 {
276 //Print("CAST UNSUCCESFUL");
280 }
281
282 //Print(cursorTarget);
283
285 DayZPlayerCamera camera = m_Player.GetCurrentCamera();
286 if (camera && camera.GetCurrentPitch() <= -45) // Spatial search is a contributor to very heavy searching, limit it to when we are at least looking down
288
290 vicinityObjects.RemoveItem(m_Player);
291
293 //Print("m_VicinityObjects before" + m_VicinityObjects.Count());
294 m_VicinityObjects.TransformToVicinityObjects(vicinityObjects);
295 //Print("m_VicinityObjects after" + m_VicinityObjects.Count());
296
299
301 for ( i = 0; i < m_VicinityObjects.Count(); i++ )
302 {
303 Object object = m_VicinityObjects.GetObject(i);
304 Object parent = m_VicinityObjects.GetParent(i);
305
307 if ( utility > 0 )
308 {
309 int targetComponent = -1;
311
312 ActionTarget at = new ActionTarget(object, parent, targetComponent, m_HitPos, utility);
314 }
315 /*else
316 Print("utility < 0; object: " + object + " | parent: " + parent);*/
317 }
318
320 if (m_HitPos == vector.Zero)
321 {
324 float hitFraction;
326
327 m_RayEnd = m_RayStart + GetGame().GetCurrentCameraDirection() * c_RayDistance * 3;
328
332 }
333
334 m_Targets.Insert(new ActionTarget(null, null, -1, m_HitPos, 0));
335
336#ifdef DIAG_DEVELOPER
337 if (DiagMenu.GetBool(DiagMenuIDs.MISC_ACTION_TARGETS_DEBUG))
338 {
341 DrawDebugCone(true);
342 DrawDebugRay(true);
343 DrawSelectionPos(DiagMenu.GetBool(DiagMenuIDs.MISC_ACTION_TARGETS_SELPOS_DEBUG));
344 }
345 else
346 {
349 DrawDebugCone(false);
350 DrawDebugRay(false);
351 DrawSelectionPos(false);
352 }
353#endif
354 //Print("--------------");
355 }
class ActionTargets ActionTarget
PhxInteractionLayers
Definition DayZPhysics.c:2
void DayZPlayerUtils()
cannot be instantiated
Definition DayZPlayerUtils.c:465
const float c_ConeHeightMin
Definition ActionTargets.c:730
vector m_HitPos
Definition ActionTargets.c:720
void Clear()
Definition ActionTargets.c:189
float ComputeUtility(Object pTarget, vector pRayStart, vector pRayEnd, Object cursorTarget, vector hitPos)
computes utility of target
Definition ActionTargets.c:406
const float c_ConeAngle
Definition ActionTargets.c:729
const float c_RayDistance
searching properties
Definition ActionTargets.c:726
const float c_ConeHeightMax
Definition ActionTargets.c:731
void FilterObstructedObjectsEx(Object cursor_target, array< Object > vicinityObjects)
Definition ActionTargets.c:465
void StoreTarget(ActionTarget pActionTarget)
inserts action into sorted array based on utility
Definition ActionTargets.c:377
vector m_RayEnd
Definition ActionTargets.c:719
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition DayZPhysics.c:124
static proto bool RayCastBullet(vector begPos, vector endPos, PhxInteractionLayers layerMask, Object ignoreObj, out Object hitObject, out vector hitPosition, out vector hitNormal, out float hitFraction)
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
Definition Building.c:6
Definition DayZPhysics.c:50
Definition DayZPhysics.c:99
static const vector Zero
Definition EnConvert.c:110
class DayZPlayerCameraResult DayZPlayerCamera(DayZPlayer pPlayer, HumanInputController pInput)
Definition dayzplayer.c:56
proto native CGame GetGame()
CollisionFlags
Definition EnDebug.c:141
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

Поля

◆ c_ConeAngle

const float c_ConeAngle = 30.0
private

◆ c_ConeHeightMax

const float c_ConeHeightMax = 2.0
private

◆ c_ConeHeightMin

const float c_ConeHeightMin = -0.5
private

◆ c_DistanceDelta

const float c_DistanceDelta = 0.3
private

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

◆ c_MaxActionDistance

const float c_MaxActionDistance = UAMaxDistances.DEFAULT
private

◆ c_MaxTargetDistance

const float c_MaxTargetDistance = 3.0
private

Используется в ComputeUtility() и FilterObstructedObjectsEx().

◆ c_RayDistance

const float c_RayDistance = 5.0
private

searching properties

◆ c_UtilityMaxDistFromRaySqr

const float c_UtilityMaxDistFromRaySqr = 0.8 * 0.8
private

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

◆ c_UtilityMaxValue

const float c_UtilityMaxValue = 10000
private

utility constants

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

◆ CE_CENTER

const string CE_CENTER = "ce_center"
private

p3d

◆ GROUPING_COUNT_THRESHOLD

const int GROUPING_COUNT_THRESHOLD = 10
private

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

◆ HEIGHT_OFFSET

const float HEIGHT_OFFSET = 0.2
private

◆ m_HitPos

vector m_HitPos
private

◆ m_Player

PlayerBase m_Player
private

player owner

Используется в ActionTargets() и ComputeUtility().

◆ m_RayEnd

vector m_RayEnd
private

◆ m_RayStart

vector m_RayStart
staticprivate

objects in vicinity

Используется в FilterObstructedObjects(), FilterObstructedObjectsEx() и IsObstructed().

◆ m_Targets

ref array<ref ActionTarget> m_Targets
private

selected & sorted targets by utility function

Используется в FindIndexForStoring(), GetTarget(), GetTargetsCount() и StoreTarget().

◆ OBSTRUCTED_COUNT_THRESHOLD

const int OBSTRUCTED_COUNT_THRESHOLD = 3
private

misc

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


Объявления и описания членов класса находятся в файле: