diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2019-09-15 01:28:55 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2019-09-15 01:28:55 +0200 |
commit | 8355a6dccd8f1acce398b42e0e1963c96accac60 (patch) | |
tree | 6e3b9e8bb1f43b4952ed5f4910e3d7f05d47037f /src/control/AccidentManager.cpp | |
parent | Merge pull request #207 from Nick007J/master (diff) | |
parent | CCarCtrl (diff) | |
download | re3-8355a6dccd8f1acce398b42e0e1963c96accac60.tar re3-8355a6dccd8f1acce398b42e0e1963c96accac60.tar.gz re3-8355a6dccd8f1acce398b42e0e1963c96accac60.tar.bz2 re3-8355a6dccd8f1acce398b42e0e1963c96accac60.tar.lz re3-8355a6dccd8f1acce398b42e0e1963c96accac60.tar.xz re3-8355a6dccd8f1acce398b42e0e1963c96accac60.tar.zst re3-8355a6dccd8f1acce398b42e0e1963c96accac60.zip |
Diffstat (limited to 'src/control/AccidentManager.cpp')
-rw-r--r-- | src/control/AccidentManager.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/control/AccidentManager.cpp b/src/control/AccidentManager.cpp new file mode 100644 index 00000000..e2b1f6d0 --- /dev/null +++ b/src/control/AccidentManager.cpp @@ -0,0 +1,45 @@ +#include "common.h" +#include "patcher.h" +#include "AccidentManager.h" + +#include "Ped.h" + +CAccidentManager& gAccidentManager = *(CAccidentManager*)0x87FD10; + +uint16 CAccidentManager::CountActiveAccidents() +{ + uint16 accidents = 0; + for (int i = 0; i < NUM_ACCIDENTS; i++){ + if (m_aAccidents[i].m_pVictim) + accidents++; + } + return accidents; +} + +CAccident* CAccidentManager::FindNearestAccident(CVector vecPos, float* pDistance) +{ + for (int i = 0; i < MAX_MEDICS_TO_ATTEND_ACCIDENT; i++){ + int accidentId = -1; + float minDistance = 999999; + for (int j = 0; j < NUM_ACCIDENTS; j++){ + CPed* pVictim = m_aAccidents[j].m_pVictim; + if (!pVictim) + continue; + if (pVictim->CharCreatedBy == MISSION_CHAR) + continue; + if (pVictim->m_fHealth != 0.0f) + continue; + if (m_aAccidents[j].m_nMedicsPerformingCPR != i) + continue; + float distance = (pVictim->GetPosition() - vecPos).Magnitude2D(); + if (distance / 2 > pVictim->GetPosition().z - vecPos.z && distance < minDistance){ + minDistance = distance; + accidentId = j; + } + } + *pDistance = minDistance; + if (accidentId != -1) + return &m_aAccidents[accidentId]; + } + return nil; +}
\ No newline at end of file |