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

◆ IsFacingPlayer() [3/3]

override bool BaseBuildingBase::IsFacingPlayer ( PlayerBase player,
string selection )
inlineprivate

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

435 {
436 vector ref_pos;
437 vector ref_dir;
438 vector player_dir;
439 float dot;
440 bool has_memory_point = MemoryPointExists( selection );
441
442 if ( has_memory_point )
443 {
444 ref_pos = ModelToWorld( GetMemoryPointPos( selection ) );
445 ref_dir = ref_pos - GetPosition();
446 }
447 else
448 {
449 ref_pos = GetPosition();
450 ref_dir = ref_pos - player.GetPosition();
451 }
452
453 ref_dir.Normalize();
454 ref_dir[1] = 0; //ignore height
455
456 player_dir = player.GetDirection();
457 player_dir.Normalize();
458 player_dir[1] = 0; //ignore height
459
460 if ( ref_dir.Length() != 0 )
461 {
462 dot = vector.Dot( player_dir, ref_dir );
463 }
464
465 if ( has_memory_point )
466 {
467 if ( dot < 0 && Math.AbsFloat( dot ) > MIN_ACTION_DETECTION_ANGLE_RAD )
468 {
469 return true;
470 }
471 }
472 else
473 {
474 if ( dot > 0 && Math.AbsFloat( dot ) > MIN_ACTION_DETECTION_ANGLE_RAD )
475 {
476 return true;
477 }
478 }
479
480 return false;
481 }
const float MIN_ACTION_DETECTION_ANGLE_RAD
Определения Watchtower.c:8
proto native float Length()
Returns length of vector (magnitude)
proto float Normalize()
Normalizes vector. Returns length.
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473

Перекрестные ссылки Math::AbsFloat(), vector::Dot(), GetPosition(), vector::Length(), MIN_ACTION_DETECTION_ANGLE_RAD и vector::Normalize().