1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-23 17:45:28 +00:00

more CRoadBlocks::GenerateRoadBlocks improvements

This commit is contained in:
saml1er 2020-04-13 15:21:39 +05:00
parent 28fb1bdde7
commit 68f8a6a9ed

View file

@ -112,84 +112,86 @@ CRoadBlocks::GenerateRoadBlocks(void)
numRoadBlocks = maxRoadBlocks; numRoadBlocks = maxRoadBlocks;
for (; nRoadblockNode < numRoadBlocks; nRoadblockNode++) { for (; nRoadblockNode < numRoadBlocks; nRoadblockNode++) {
CTreadable *mapObject = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[nRoadblockNode]]; CTreadable *mapObject = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[nRoadblockNode]];
CVector2D direction = FindPlayerCoors() - mapObject->GetPosition(); CVector2D vecDistance = FindPlayerCoors() - mapObject->GetPosition();
if (!((direction.x > -80.0f && direction.x < 80.0f) && (direction.y > -80.0f && direction.y < 80.0f))) { if (vecDistance.x > -80.0f && vecDistance.x < 80.0f &&
CRoadBlocks::InOrOut[nRoadblockNode] = false; vecDistance.y > -80.0f && vecDistance.y < 80.0f &&
} vecDistance.Magnitude() < 80.0f) {
else if (direction.Magnitude() >= 80.0f) { if (!CRoadBlocks::InOrOut[nRoadblockNode]) {
CRoadBlocks::InOrOut[nRoadblockNode] = false; CRoadBlocks::InOrOut[nRoadblockNode] = true;
} if (FindPlayerVehicle() && (CGeneral::GetRandomNumber() & 0x7F) < FindPlayerPed()->m_pWanted->m_RoadblockDensity) {
else if (!CRoadBlocks::InOrOut[nRoadblockNode]) { CWanted *pPlayerWanted = FindPlayerPed()->m_pWanted;
CRoadBlocks::InOrOut[nRoadblockNode] = true; float fMapObjectRadius = 2.0f * mapObject->GetColModel()->boundingBox.max.x;
if (FindPlayerVehicle() && (CGeneral::GetRandomNumber() & 0x7F) < FindPlayerPed()->m_pWanted->m_RoadblockDensity) { int32 vehicleId = MI_POLICE;
CWanted *pPlayerWanted = FindPlayerPed()->m_pWanted; if (pPlayerWanted->AreArmyRequired())
float fMapObjectRadius = 2.0f * mapObject->GetColModel()->boundingBox.max.x; vehicleId = MI_BARRACKS;
int32 vehicleId = MI_POLICE; else if (pPlayerWanted->AreFbiRequired())
if (pPlayerWanted->AreArmyRequired()) vehicleId = MI_FBICAR;
vehicleId = MI_BARRACKS; else if (pPlayerWanted->AreSwatRequired())
else if (pPlayerWanted->AreFbiRequired()) vehicleId = MI_ENFORCER;
vehicleId = MI_FBICAR; if (!CStreaming::HasModelLoaded(vehicleId))
else if (pPlayerWanted->AreSwatRequired()) vehicleId = MI_POLICE;
vehicleId = MI_ENFORCER; CColModel *pVehicleColModel = CModelInfo::GetModelInfo(vehicleId)->GetColModel();
if (!CStreaming::HasModelLoaded(vehicleId)) float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f;
vehicleId = MI_POLICE; int16 radius = (int16)(fMapObjectRadius / fModelRadius);
CColModel* pVehicleColModel = CModelInfo::GetModelInfo(vehicleId)->GetColModel(); if (radius > 0 && radius < 6) {
float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f; CVector2D vecDistanceToCamera = TheCamera.GetPosition() - mapObject->m_matrix.GetPosition();
int16 radius = (int16)(fMapObjectRadius / fModelRadius); float fDotProduct = DotProduct2D(vecDistanceToCamera, mapObject->m_matrix.GetUp());
if (radius > 0 && radius < 6) { float fOffset = 0.5f * fModelRadius * (float)(radius - 1);
CVector2D directionToCamera = TheCamera.m_matrix.GetPosition() - mapObject->m_matrix.GetPosition(); for (int16 i = 0; i < radius; i++) {
float fDotProduct = DotProduct2D(directionToCamera, mapObject->m_matrix.GetUp()); uint8 nRoadblockType = fDotProduct < 0.0f;
float fOffset = 0.5f * fModelRadius * (float)(radius - 1); if (CGeneral::GetRandomNumber() & 1) {
for (int16 i = 0; i < radius; i++) { offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI);
uint8 nRoadblockType = fDotProduct < 0.0f; }
if (CGeneral::GetRandomNumber() & 1) { else {
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI); nRoadblockType = !nRoadblockType;
} else { offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI);
nRoadblockType = !nRoadblockType; }
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI); if (ThePaths.m_objectFlags[CRoadBlocks::RoadBlockObjects[nRoadblockNode]] & ObjectEastWest)
} offsetMatrix.GetPosition() = CVector(0.0f, -fOffset, 0.6f);
if (ThePaths.m_objectFlags[CRoadBlocks::RoadBlockObjects[nRoadblockNode]] & ObjectEastWest) else
offsetMatrix.GetPosition() = CVector(0.0f, -fOffset, 0.6f); offsetMatrix.GetPosition() = CVector(-fOffset, 0.0f, 0.6f);
else CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix;
offsetMatrix.GetPosition() = CVector(-fOffset, 0.0f, 0.6f); float fModelRadius = CModelInfo::GetModelInfo(vehicleId)->GetColModel()->boundingSphere.radius - 0.25f;
CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix; int16 colliding = 0;
float fModelRadius = CModelInfo::GetModelInfo(vehicleId)->GetColModel()->boundingSphere.radius - 0.25f; CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false);
int16 colliding = 0; if (!colliding) {
CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false); CAutomobile *pVehicle = new CAutomobile(vehicleId, RANDOM_VEHICLE);
if (!colliding) { pVehicle->m_status = STATUS_ABANDONED;
CAutomobile* pVehicle = new CAutomobile(vehicleId, RANDOM_VEHICLE); // pVehicle->GetHeightAboveRoad(); // called but return value is ignored?
pVehicle->m_status = STATUS_ABANDONED; vehicleMatrix.GetPosition().z += fModelRadius - 0.6f;
// pVehicle->GetHeightAboveRoad(); // called but return value is ignored? pVehicle->m_matrix = vehicleMatrix;
vehicleMatrix.GetPosition().z += fModelRadius - 0.6f; pVehicle->PlaceOnRoadProperly();
pVehicle->m_matrix = vehicleMatrix; pVehicle->bIsStatic = false;
pVehicle->PlaceOnRoadProperly(); pVehicle->m_matrix.UpdateRW();
pVehicle->bIsStatic = false; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
pVehicle->m_matrix.UpdateRW(); CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; pVehicle->bIsLocked = false;
CCarCtrl::JoinCarWithRoadSystem(pVehicle); pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
pVehicle->bIsLocked = false; pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE; pVehicle->AutoPilot.m_nCurrentLane = 0;
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; pVehicle->AutoPilot.m_nNextLane = 0;
pVehicle->AutoPilot.m_nCurrentLane = 0; pVehicle->AutoPilot.m_fMaxTrafficSpeed = 0.0f;
pVehicle->AutoPilot.m_nNextLane = 0; pVehicle->AutoPilot.m_nCruiseSpeed = 0.0f;
pVehicle->AutoPilot.m_fMaxTrafficSpeed = 0.0f; pVehicle->bExtendedRange = true;
pVehicle->AutoPilot.m_nCruiseSpeed = 0.0f; if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1)
pVehicle->bExtendedRange = true; pVehicle->m_bSirenOrAlarm = true;
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1) if (pVehicle->m_matrix.GetForward().z > 0.94f) {
pVehicle->m_bSirenOrAlarm = true; CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
if (pVehicle->m_matrix.GetForward().z > 0.94f) { CWorld::Add(pVehicle);
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0); pVehicle->bCreateRoadBlockPeds = true;
CWorld::Add(pVehicle); pVehicle->m_nRoadblockType = nRoadblockType;
pVehicle->bCreateRoadBlockPeds = true; pVehicle->m_nRoadblockNode = nRoadblockNode;
pVehicle->m_nRoadblockType = nRoadblockType; }
pVehicle->m_nRoadblockNode = nRoadblockNode; else {
} else { delete pVehicle;
delete pVehicle; }
} }
} }
} }
} }
} }
} else {
CRoadBlocks::InOrOut[nRoadblockNode] = false;
} }
} }
} }