mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-27 03:24:15 +01:00
Fix CRoadBlocks::GenerateRoadBlocks bugs
This commit is contained in:
parent
60898f39f2
commit
28fb1bdde7
@ -113,89 +113,82 @@ CRoadBlocks::GenerateRoadBlocks(void)
|
|||||||
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 direction = FindPlayerCoors() - mapObject->GetPosition();
|
||||||
if ((direction.x <= -80.0f || direction.x < 80.0f) || (direction.y <= -80.0f || direction.y < 80.0f)) {
|
if (!((direction.x > -80.0f && direction.x < 80.0f) && (direction.y > -80.0f && direction.y < 80.0f))) {
|
||||||
CRoadBlocks::InOrOut[nRoadblockNode] = false;
|
CRoadBlocks::InOrOut[nRoadblockNode] = false;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (direction.Magnitude() < 80.0f) {
|
else if (direction.Magnitude() >= 80.0f) {
|
||||||
CRoadBlocks::InOrOut[nRoadblockNode] = false;
|
CRoadBlocks::InOrOut[nRoadblockNode] = false;
|
||||||
continue;
|
}
|
||||||
} else if (!CRoadBlocks::InOrOut[nRoadblockNode]) {
|
else if (!CRoadBlocks::InOrOut[nRoadblockNode]) {
|
||||||
CRoadBlocks::InOrOut[nRoadblockNode] = true;
|
CRoadBlocks::InOrOut[nRoadblockNode] = true;
|
||||||
} else {
|
if (FindPlayerVehicle() && (CGeneral::GetRandomNumber() & 0x7F) < FindPlayerPed()->m_pWanted->m_RoadblockDensity) {
|
||||||
continue;
|
CWanted *pPlayerWanted = FindPlayerPed()->m_pWanted;
|
||||||
}
|
float fMapObjectRadius = 2.0f * mapObject->GetColModel()->boundingBox.max.x;
|
||||||
if (!FindPlayerVehicle())
|
int32 vehicleId = MI_POLICE;
|
||||||
continue;
|
if (pPlayerWanted->AreArmyRequired())
|
||||||
CWanted *pPlayerWanted = FindPlayerPed()->m_pWanted;
|
vehicleId = MI_BARRACKS;
|
||||||
if ((CGeneral::GetRandomNumber() & 0x7F) >= pPlayerWanted->m_RoadblockDensity)
|
else if (pPlayerWanted->AreFbiRequired())
|
||||||
continue;
|
vehicleId = MI_FBICAR;
|
||||||
float fMapObjectRadius = 2.0f * mapObject->GetColModel()->boundingBox.max.x;
|
else if (pPlayerWanted->AreSwatRequired())
|
||||||
int32 vehicleId = MI_POLICE;
|
vehicleId = MI_ENFORCER;
|
||||||
if (pPlayerWanted->AreArmyRequired())
|
if (!CStreaming::HasModelLoaded(vehicleId))
|
||||||
vehicleId = MI_BARRACKS;
|
vehicleId = MI_POLICE;
|
||||||
else if (pPlayerWanted->AreFbiRequired())
|
CColModel* pVehicleColModel = CModelInfo::GetModelInfo(vehicleId)->GetColModel();
|
||||||
vehicleId = MI_FBICAR;
|
float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f;
|
||||||
else if (pPlayerWanted->AreSwatRequired())
|
int16 radius = (int16)(fMapObjectRadius / fModelRadius);
|
||||||
vehicleId = MI_ENFORCER;
|
if (radius > 0 && radius < 6) {
|
||||||
if (!CStreaming::HasModelLoaded(vehicleId))
|
CVector2D directionToCamera = TheCamera.m_matrix.GetPosition() - mapObject->m_matrix.GetPosition();
|
||||||
vehicleId = MI_POLICE;
|
float fDotProduct = DotProduct2D(directionToCamera, mapObject->m_matrix.GetUp());
|
||||||
CColModel *pVehicleColModel = CModelInfo::GetModelInfo(vehicleId)->GetColModel();
|
float fOffset = 0.5f * fModelRadius * (float)(radius - 1);
|
||||||
float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f;
|
for (int16 i = 0; i < radius; i++) {
|
||||||
int16 radius = (int16)(fMapObjectRadius / fModelRadius);
|
uint8 nRoadblockType = fDotProduct < 0.0f;
|
||||||
if (radius >= 6)
|
if (CGeneral::GetRandomNumber() & 1) {
|
||||||
continue;
|
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI);
|
||||||
CVector2D directionToCamera = TheCamera.m_matrix.GetPosition() - mapObject->m_matrix.GetPosition();
|
} else {
|
||||||
float fDotProduct = DotProduct2D(directionToCamera, mapObject->m_matrix.GetUp());
|
nRoadblockType = !nRoadblockType;
|
||||||
if (radius <= 0)
|
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI);
|
||||||
continue;
|
}
|
||||||
float fOffset = 0.5f * fModelRadius * (float)(radius - 1);
|
if (ThePaths.m_objectFlags[CRoadBlocks::RoadBlockObjects[nRoadblockNode]] & ObjectEastWest)
|
||||||
for (int16 modelId = vehicleId; modelId < nRoadblockNode ; modelId++) {
|
offsetMatrix.GetPosition() = CVector(0.0f, -fOffset, 0.6f);
|
||||||
uint8 nRoadblockType = fDotProduct >= 0.0f;
|
else
|
||||||
if (CGeneral::GetRandomNumber() & 1) {
|
offsetMatrix.GetPosition() = CVector(-fOffset, 0.0f, 0.6f);
|
||||||
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI);
|
CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix;
|
||||||
} else {
|
float fModelRadius = CModelInfo::GetModelInfo(vehicleId)->GetColModel()->boundingSphere.radius - 0.25f;
|
||||||
nRoadblockType = fDotProduct < 0.0f;
|
int16 colliding = 0;
|
||||||
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI);
|
CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false);
|
||||||
}
|
if (!colliding) {
|
||||||
if (ThePaths.m_objectFlags[CRoadBlocks::RoadBlockObjects[nRoadblockNode]] & ObjectEastWest)
|
CAutomobile* pVehicle = new CAutomobile(vehicleId, RANDOM_VEHICLE);
|
||||||
offsetMatrix.GetPosition() = CVector(0.0f, -fOffset, 0.6f);
|
pVehicle->m_status = STATUS_ABANDONED;
|
||||||
else
|
// pVehicle->GetHeightAboveRoad(); // called but return value is ignored?
|
||||||
offsetMatrix.GetPosition() = CVector(-fOffset, 0.0f, 0.6f);
|
vehicleMatrix.GetPosition().z += fModelRadius - 0.6f;
|
||||||
CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix;
|
pVehicle->m_matrix = vehicleMatrix;
|
||||||
float fModelRadius = CModelInfo::GetModelInfo(modelId)->GetColModel()->boundingSphere.radius - 0.25f;
|
pVehicle->PlaceOnRoadProperly();
|
||||||
int16 colliding = 0;
|
pVehicle->bIsStatic = false;
|
||||||
CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false);
|
pVehicle->m_matrix.UpdateRW();
|
||||||
if (colliding)
|
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
|
||||||
continue;
|
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
|
||||||
CAutomobile *pVehicle = new CAutomobile(vehicleId, RANDOM_VEHICLE);
|
pVehicle->bIsLocked = false;
|
||||||
pVehicle->m_status = STATUS_ABANDONED;
|
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||||
// pVehicle->GetHeightAboveRoad(); // called but return value is ignored?
|
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
||||||
vehicleMatrix.GetPosition().z += fModelRadius - 0.6f;
|
pVehicle->AutoPilot.m_nCurrentLane = 0;
|
||||||
pVehicle->m_matrix = vehicleMatrix;
|
pVehicle->AutoPilot.m_nNextLane = 0;
|
||||||
pVehicle->PlaceOnRoadProperly();
|
pVehicle->AutoPilot.m_fMaxTrafficSpeed = 0.0f;
|
||||||
pVehicle->bIsStatic = false;
|
pVehicle->AutoPilot.m_nCruiseSpeed = 0.0f;
|
||||||
pVehicle->m_matrix.UpdateRW();
|
pVehicle->bExtendedRange = true;
|
||||||
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
|
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1)
|
||||||
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
|
pVehicle->m_bSirenOrAlarm = true;
|
||||||
pVehicle->bIsLocked = false;
|
if (pVehicle->m_matrix.GetForward().z > 0.94f) {
|
||||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
|
||||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
CWorld::Add(pVehicle);
|
||||||
pVehicle->AutoPilot.m_nCurrentLane = 0;
|
pVehicle->bCreateRoadBlockPeds = true;
|
||||||
pVehicle->AutoPilot.m_nNextLane = 0;
|
pVehicle->m_nRoadblockType = nRoadblockType;
|
||||||
pVehicle->AutoPilot.m_fMaxTrafficSpeed = 0.0f;
|
pVehicle->m_nRoadblockNode = nRoadblockNode;
|
||||||
pVehicle->AutoPilot.m_nCruiseSpeed = 0.0f;
|
} else {
|
||||||
pVehicle->bExtendedRange = true;
|
delete pVehicle;
|
||||||
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1)
|
}
|
||||||
pVehicle->m_bSirenOrAlarm = true;
|
}
|
||||||
if (pVehicle->m_matrix.GetForward().z > 0.94f) {
|
}
|
||||||
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
|
}
|
||||||
CWorld::Add(pVehicle);
|
|
||||||
pVehicle->bCreateRoadBlockPeds = true;
|
|
||||||
pVehicle->m_nRoadblockType = nRoadblockType;
|
|
||||||
pVehicle->m_nRoadblockNode = nRoadblockNode;
|
|
||||||
} else {
|
|
||||||
delete pVehicle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user