| 724 | } |
| 725 | |
| 726 | void SArtefactDetectorsSupport::UpdateOnFrame() |
| 727 | { |
| 728 | if (m_currPatrolPath && !m_parent->getVisible()) |
| 729 | { |
| 730 | if (m_parent->Position().distance_to(m_destPoint) < 2.0f) |
| 731 | { |
| 732 | CPatrolPath::const_iterator b, e; |
| 733 | m_currPatrolPath->begin(m_currPatrolVertex, b, e); |
| 734 | if (b != e) |
| 735 | { |
| 736 | std::advance(b, ::Random.randI(s32(e - b))); |
| 737 | m_currPatrolVertex = m_currPatrolPath->vertex((*b).vertex_id()); |
| 738 | m_destPoint = m_currPatrolVertex->data().position(); |
| 739 | } |
| 740 | } |
| 741 | float cos_et = _cos(deg2rad(45.f)); |
| 742 | Fvector dir; |
| 743 | dir.sub(m_destPoint, m_parent->Position()).normalize_safe(); |
| 744 | |
| 745 | Fvector v; |
| 746 | m_parent->PHGetLinearVell(v); |
| 747 | float cosa = v.dotproduct(dir); |
| 748 | if (v.square_magnitude() < (0.7f * 0.7f) || (cosa < cos_et)) |
| 749 | { |
| 750 | Fvector power = dir; |
| 751 | power.y += 1.0f; |
| 752 | power.mul(m_path_moving_force); |
| 753 | m_parent->m_pPhysicsShell->applyGravityAccel(power); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | if (m_parent->getVisible() && m_parent->GetAfRank() != 0 && m_switchVisTime + 5000 < Device.dwTimeGlobal) |
| 758 | SetVisible(false); |
| 759 | |
| 760 | u32 dwDt = 2 * 3600 * 1000 / 10; // 2 hour of game time |
| 761 | if (!m_parent->getVisible() && m_switchVisTime + dwDt < Device.dwTimeGlobal) |
| 762 | { |
| 763 | m_switchVisTime = Device.dwTimeGlobal; |
| 764 | if (m_parent->Position().distance_to(Device.vCameraPosition) > 40.0f) |
| 765 | Blink(); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | void SArtefactDetectorsSupport::FollowByPath(LPCSTR path_name, int start_idx, Fvector force) |
| 770 | { |
no test coverage detected