mirror of
https://github.com/halpz/re3.git
synced 2025-06-29 22:06:23 +00:00
CCarCtrl::GenerateOneRandomCar
This commit is contained in:
@ -402,6 +402,10 @@ CPed::~CPed(void)
|
||||
}
|
||||
if (m_pFire)
|
||||
m_pFire->Extinguish();
|
||||
if (bCarPassenger)
|
||||
CPopulation::ms_nTotalCarPassengerPeds--;
|
||||
if (bMiamiViceCop)
|
||||
CPopulation::NumMiamiViceCops--;
|
||||
CPopulation::UpdatePedCount((ePedType)m_nPedType, true);
|
||||
DMAudio.DestroyEntity(m_audioEntityId);
|
||||
}
|
||||
@ -605,6 +609,10 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
|
||||
bSomeVCflag1 = false;
|
||||
#endif
|
||||
|
||||
bCarPassenger = false;
|
||||
bMiamiViceCop = false;
|
||||
bDeadPedInFrontOfCar = false;
|
||||
|
||||
if ((CGeneral::GetRandomNumber() & 3) == 0)
|
||||
bHasACamera = true;
|
||||
|
||||
|
@ -389,6 +389,10 @@ public:
|
||||
uint32 m_ped_flagI40 : 1; // bMakePedsRunToPhonesToReportCrimes makes use of this as runover by car indicator
|
||||
uint32 m_ped_flagI80 : 1; // KANGAROO_CHEAT define makes use of this as cheat toggle
|
||||
|
||||
uint32 bCarPassenger : 1;
|
||||
uint32 bMiamiViceCop : 1; //
|
||||
uint32 bDeadPedInFrontOfCar : 1;
|
||||
|
||||
uint8 CharCreatedBy;
|
||||
eObjective m_objective;
|
||||
eObjective m_prevObjective;
|
||||
@ -452,6 +456,9 @@ public:
|
||||
CVehicle *m_pMyVehicle;
|
||||
bool bInVehicle;
|
||||
float m_distanceToCountSeekDone;
|
||||
|
||||
CVehicle* m_vehicleInAccident;
|
||||
|
||||
bool bRunningToPhone;
|
||||
int16 m_phoneId;
|
||||
eCrimeType m_crimeToReportOnPhone;
|
||||
|
@ -43,9 +43,13 @@ CPedPlacement::IsPositionClearOfCars(Const CVector *pos)
|
||||
}
|
||||
|
||||
bool
|
||||
CPedPlacement::IsPositionClearForPed(CVector* pos)
|
||||
CPedPlacement::IsPositionClearForPed(const CVector& pos, float radius, int total, CEntity** entities)
|
||||
{
|
||||
int16 count;
|
||||
CWorld::FindObjectsKindaColliding(*pos, 0.75f, true, &count, 2, nil, false, true, true, false, false);
|
||||
if (radius == -1.0f)
|
||||
radius = 0.75f;
|
||||
if (total == -1)
|
||||
total = 2;
|
||||
CWorld::FindObjectsKindaColliding(pos, radius, true, &count, total, entities, false, true, true, false, false);
|
||||
return count == 0;
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ class CPedPlacement {
|
||||
public:
|
||||
static void FindZCoorForPed(CVector* pos);
|
||||
static CEntity* IsPositionClearOfCars(Const CVector*);
|
||||
static bool IsPositionClearForPed(CVector*);
|
||||
static bool IsPositionClearForPed(const CVector& pos, float radius = -1.0f, int total = -1, CEntity** entities = nil);
|
||||
};
|
@ -83,6 +83,9 @@ CVector CPopulation::RegenerationPoint_a;
|
||||
CVector CPopulation::RegenerationPoint_b;
|
||||
CVector CPopulation::RegenerationForward;
|
||||
|
||||
uint32 CPopulation::ms_nTotalCarPassengerPeds;
|
||||
uint32 CPopulation::NumMiamiViceCops;
|
||||
|
||||
void
|
||||
CPopulation::Initialise()
|
||||
{
|
||||
@ -103,6 +106,8 @@ CPopulation::Initialise()
|
||||
ms_nNumGang9 = 0;
|
||||
ms_nNumDummy = 0;
|
||||
|
||||
ms_nTotalCarPassengerPeds = 0;
|
||||
|
||||
m_AllRandomPedsThisType = -1;
|
||||
PedDensityMultiplier = 1.0f;
|
||||
bZoneChangeHasHappened = false;
|
||||
@ -398,6 +403,7 @@ CPopulation::Update()
|
||||
+ ms_nNumGang2 + ms_nNumGang1;
|
||||
ms_nTotalPeds = ms_nNumDummy + ms_nNumEmergency + ms_nNumCop
|
||||
+ ms_nTotalGangPeds + ms_nNumCivFemale + ms_nNumCivMale;
|
||||
ms_nTotalPeds -= ms_nTotalCarPassengerPeds;
|
||||
if (!CCutsceneMgr::IsRunning()) {
|
||||
float pcdm = PedCreationDistMultiplier();
|
||||
AddToPopulation(pcdm * (MIN_CREATION_DIST * TheCamera.GenerationDistMultiplier),
|
||||
@ -419,6 +425,7 @@ CPopulation::GeneratePedsAtStartOfGame()
|
||||
+ ms_nNumGang3 + ms_nNumGang2 + ms_nNumGang1;
|
||||
ms_nTotalPeds = ms_nNumDummy + ms_nNumEmergency + ms_nNumCop
|
||||
+ ms_nTotalGangPeds + ms_nNumCivFemale + ms_nNumCivMale;
|
||||
ms_nTotalPeds -= ms_nTotalCarPassengerPeds;
|
||||
|
||||
// Min dist is 10.0f only for start of the game (naturally)
|
||||
AddToPopulation(10.0f, PedCreationDistMultiplier() * (MIN_CREATION_DIST + CREATION_RANGE),
|
||||
@ -656,7 +663,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
|
||||
generatedCoors.y = yOffset + gangLeader->GetPosition().y;
|
||||
}
|
||||
}
|
||||
if (!CPedPlacement::IsPositionClearForPed(&generatedCoors))
|
||||
if (!CPedPlacement::IsPositionClearForPed(generatedCoors))
|
||||
break;
|
||||
|
||||
// Why no love for last gang member?!
|
||||
@ -733,6 +740,7 @@ CPopulation::AddPedInCar(CVehicle* car)
|
||||
break;
|
||||
case MI_POLICE:
|
||||
case MI_PREDATOR:
|
||||
case MI_VICECHEE: // TODO(MIAMI): proper model
|
||||
preferredModel = COP_STREET;
|
||||
pedType = PEDTYPE_COP;
|
||||
break;
|
||||
@ -1016,6 +1024,10 @@ CPopulation::ManagePopulation(void)
|
||||
}
|
||||
|
||||
float dist = (ped->GetPosition() - playerPos).Magnitude2D();
|
||||
|
||||
if (ped->IsGangMember() || (ped->bDeadPedInFrontOfCar && ped->m_vehicleInAccident))
|
||||
dist -= 30.0f;
|
||||
|
||||
bool pedIsFarAway = false;
|
||||
if (PedCreationDistMultiplier() * (PED_REMOVE_DIST_SPECIAL * TheCamera.GenerationDistMultiplier) < dist
|
||||
|| (!ped->bCullExtraFarAway && PedCreationDistMultiplier() * PED_REMOVE_DIST * TheCamera.GenerationDistMultiplier < dist)
|
||||
@ -1062,3 +1074,49 @@ CPopulation::ManagePopulation(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CPed*
|
||||
CPopulation::AddDeadPedInFrontOfCar(const CVector& pos, CVehicle* pCulprit)
|
||||
{
|
||||
if (TheCamera.IsSphereVisible(pos, 2.0f)) {
|
||||
float fDistanceToPlayer = (pos - FindPlayerPed()->GetPosition()).Magnitude2D();
|
||||
float fDistanceMultiplier;
|
||||
if (FindPlayerVehicle())
|
||||
fDistanceMultiplier = clamp(FindPlayerVehicle()->GetMoveSpeed().Magnitude2D() - 0.1f + 1.0f, 1.0f, 1.5f);
|
||||
else
|
||||
fDistanceMultiplier = 1.0f;
|
||||
if (40.0f * fDistanceMultiplier > fDistanceToPlayer)
|
||||
return nil;
|
||||
}
|
||||
bool found;
|
||||
float z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &found) + 1.0f;
|
||||
if (!found)
|
||||
return nil;
|
||||
z = Max(z, pos.z);
|
||||
if (!CModelInfo::GetModelInfo(MI_MALE01)->GetRwObject()) // strange way to check it
|
||||
return nil;
|
||||
CPed* pPed = CPopulation::AddPed(PEDTYPE_CIVMALE, MI_MALE01, pos); // TODO(MIAMI): 4th parameter
|
||||
pPed->SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
|
||||
//TODO(MIAMI): set money == 0
|
||||
pPed->bDeadPedInFrontOfCar = true;
|
||||
pPed->m_vehicleInAccident = pCulprit;
|
||||
pCulprit->RegisterReference((CEntity**)&pPed->m_vehicleInAccident);
|
||||
CEntity* pEntities[3] = { 0 };
|
||||
if (!CPedPlacement::IsPositionClearForPed(pos, 2.0f, 3, pEntities)) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (pEntities[i] && pEntities[i] != pCulprit && pEntities[i] != pPed) {
|
||||
CWorld::Remove(pPed);
|
||||
delete pPed;
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
CColPoint colpts[32];
|
||||
if (CCollision::ProcessColModels(pCulprit->GetMatrix(), *pCulprit->GetColModel(), pPed->GetMatrix(), *pPed->GetColModel(), colpts, nil, nil)) {
|
||||
CWorld::Remove(pPed);
|
||||
delete pPed;
|
||||
return nil;
|
||||
}
|
||||
CVisibilityPlugins::SetClumpAlpha(pPed->GetClump(), 0);
|
||||
return pPed;
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ public:
|
||||
static CVector RegenerationPoint_b;
|
||||
static CVector RegenerationForward;
|
||||
|
||||
static uint32 ms_nTotalCarPassengerPeds;
|
||||
static uint32 NumMiamiViceCops;
|
||||
|
||||
static void Initialise();
|
||||
static void Update(void);
|
||||
static void LoadPedGroups();
|
||||
@ -86,4 +89,6 @@ public:
|
||||
static void ConvertAllObjectsToDummyObjects(void);
|
||||
static bool TestRoomForDummyObject(CObject*);
|
||||
static bool TestSafeForRealObject(CDummyObject*);
|
||||
|
||||
static CPed* AddDeadPedInFrontOfCar(const CVector& pos, CVehicle* pCulprit);
|
||||
};
|
||||
|
Reference in New Issue
Block a user