2019-09-14 23:28:07 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "patcher.h"
|
|
|
|
#include "AccidentManager.h"
|
|
|
|
|
|
|
|
#include "Ped.h"
|
|
|
|
|
|
|
|
CAccidentManager& gAccidentManager = *(CAccidentManager*)0x87FD10;
|
|
|
|
|
2019-10-18 22:23:40 +00:00
|
|
|
WRAPPER void CAccidentManager::Update(void) { EAXJMP(0x456710); }
|
|
|
|
|
2019-12-22 15:28:16 +00:00
|
|
|
uint16
|
|
|
|
CAccidentManager::CountActiveAccidents()
|
2019-09-14 23:28:07 +00:00
|
|
|
{
|
|
|
|
uint16 accidents = 0;
|
|
|
|
for (int i = 0; i < NUM_ACCIDENTS; i++){
|
|
|
|
if (m_aAccidents[i].m_pVictim)
|
|
|
|
accidents++;
|
|
|
|
}
|
|
|
|
return accidents;
|
|
|
|
}
|
|
|
|
|
2019-12-22 15:28:16 +00:00
|
|
|
CAccident*
|
|
|
|
CAccidentManager::FindNearestAccident(CVector vecPos, float* pDistance)
|
2019-09-14 23:28:07 +00:00
|
|
|
{
|
|
|
|
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;
|
2019-12-22 15:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CAccidentManager::UnattendedAccidents(void)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < NUM_ACCIDENTS; i++) {
|
|
|
|
if (m_aAccidents[i].m_pVictim && m_aAccidents[i].m_nMedicsAttending == 0)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2019-09-14 23:28:07 +00:00
|
|
|
}
|