mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-15 20:09:00 +00:00
Improve CRoadBlocks code
This commit is contained in:
parent
0d19036a42
commit
60898f39f2
1 changed files with 9 additions and 30 deletions
|
@ -44,7 +44,7 @@ CRoadBlocks::Init(void)
|
||||||
void
|
void
|
||||||
CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType, int16 roadBlockNode)
|
CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType, int16 roadBlockNode)
|
||||||
{
|
{
|
||||||
CVector vecRoadBlockOffets[6] = { {-1.5, 1.8f, 0.0f}, {-1.5f, -1.8f, 0.0f}, {1.5f, 1.8f, 0.0f},
|
static const CVector vecRoadBlockOffets[6] = { {-1.5, 1.8f, 0.0f}, {-1.5f, -1.8f, 0.0f}, {1.5f, 1.8f, 0.0f},
|
||||||
{1.5f, -1.8f, 0.0f}, {-1.5f, 0.0f, 0.0f}, {1.5, 0.0, 0.0} };
|
{1.5f, -1.8f, 0.0f}, {-1.5f, 0.0f, 0.0f}, {1.5, 0.0, 0.0} };
|
||||||
CEntity* pEntityToAttack = (CEntity*)FindPlayerVehicle();
|
CEntity* pEntityToAttack = (CEntity*)FindPlayerVehicle();
|
||||||
if (!pEntityToAttack)
|
if (!pEntityToAttack)
|
||||||
|
@ -54,7 +54,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
|
||||||
for (int32 i = 0; i < 2; i++) {
|
for (int32 i = 0; i < 2; i++) {
|
||||||
const int32 roadBlockIndex = i + 2 * roadBlockType;
|
const int32 roadBlockIndex = i + 2 * roadBlockType;
|
||||||
CVector posForZ = pVehicle->m_matrix * (fRadius * vecRoadBlockOffets[roadBlockIndex]);
|
CVector posForZ = pVehicle->m_matrix * (fRadius * vecRoadBlockOffets[roadBlockIndex]);
|
||||||
int32 modelInfoId = 0;
|
int32 modelInfoId = MI_COP;
|
||||||
eCopType copType = COP_STREET;
|
eCopType copType = COP_STREET;
|
||||||
switch (pVehicle->GetModelIndex())
|
switch (pVehicle->GetModelIndex())
|
||||||
{
|
{
|
||||||
|
@ -62,23 +62,6 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
|
||||||
modelInfoId = MI_FBI;
|
modelInfoId = MI_FBI;
|
||||||
copType = COP_FBI;
|
copType = COP_FBI;
|
||||||
break;
|
break;
|
||||||
case MI_MOONBEAM:
|
|
||||||
case MI_ESPERANT:
|
|
||||||
case MI_TAXI:
|
|
||||||
case MI_KURUMA:
|
|
||||||
case MI_BOBCAT:
|
|
||||||
case MI_MRWHOOP:
|
|
||||||
case MI_BFINJECT:
|
|
||||||
case MI_CORPSE:
|
|
||||||
case MI_POLICE:
|
|
||||||
case MI_SECURICA:
|
|
||||||
case MI_BANSHEE:
|
|
||||||
case MI_PREDATOR:
|
|
||||||
case MI_BUS:
|
|
||||||
case MI_RHINO:
|
|
||||||
copType = COP_STREET;
|
|
||||||
modelInfoId = MI_COP;
|
|
||||||
break;
|
|
||||||
case MI_ENFORCER:
|
case MI_ENFORCER:
|
||||||
modelInfoId = MI_SWAT;
|
modelInfoId = MI_SWAT;
|
||||||
copType = COP_SWAT;
|
copType = COP_SWAT;
|
||||||
|
@ -121,7 +104,7 @@ void
|
||||||
CRoadBlocks::GenerateRoadBlocks(void)
|
CRoadBlocks::GenerateRoadBlocks(void)
|
||||||
{
|
{
|
||||||
CMatrix offsetMatrix;
|
CMatrix offsetMatrix;
|
||||||
unsigned int frame = CTimer::GetFrameCounter() & 0xF;
|
uint32 frame = CTimer::GetFrameCounter() & 0xF;
|
||||||
int16 nRoadblockNode = (int16)(600 * frame) / 16;
|
int16 nRoadblockNode = (int16)(600 * frame) / 16;
|
||||||
const int16 maxRoadBlocks = (int16)(600 * (frame + 1)) / 16;
|
const int16 maxRoadBlocks = (int16)(600 * (frame + 1)) / 16;
|
||||||
int16 numRoadBlocks = CRoadBlocks::NumRoadBlocks;
|
int16 numRoadBlocks = CRoadBlocks::NumRoadBlocks;
|
||||||
|
@ -137,11 +120,9 @@ CRoadBlocks::GenerateRoadBlocks(void)
|
||||||
if (direction.Magnitude() < 80.0f) {
|
if (direction.Magnitude() < 80.0f) {
|
||||||
CRoadBlocks::InOrOut[nRoadblockNode] = false;
|
CRoadBlocks::InOrOut[nRoadblockNode] = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (!CRoadBlocks::InOrOut[nRoadblockNode]) {
|
||||||
else if (!CRoadBlocks::InOrOut[nRoadblockNode]) {
|
|
||||||
CRoadBlocks::InOrOut[nRoadblockNode] = true;
|
CRoadBlocks::InOrOut[nRoadblockNode] = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!FindPlayerVehicle())
|
if (!FindPlayerVehicle())
|
||||||
|
@ -173,8 +154,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
|
||||||
uint8 nRoadblockType = fDotProduct >= 0.0f;
|
uint8 nRoadblockType = fDotProduct >= 0.0f;
|
||||||
if (CGeneral::GetRandomNumber() & 1) {
|
if (CGeneral::GetRandomNumber() & 1) {
|
||||||
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI);
|
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
nRoadblockType = fDotProduct < 0.0f;
|
nRoadblockType = fDotProduct < 0.0f;
|
||||||
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI);
|
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI);
|
||||||
}
|
}
|
||||||
|
@ -208,15 +188,14 @@ CRoadBlocks::GenerateRoadBlocks(void)
|
||||||
pVehicle->bExtendedRange = true;
|
pVehicle->bExtendedRange = true;
|
||||||
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1)
|
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1)
|
||||||
pVehicle->m_bSirenOrAlarm = true;
|
pVehicle->m_bSirenOrAlarm = true;
|
||||||
if (pVehicle->m_matrix.GetForward().z <= 0.94f) {
|
if (pVehicle->m_matrix.GetForward().z > 0.94f) {
|
||||||
delete pVehicle;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
|
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
|
||||||
CWorld::Add(pVehicle);
|
CWorld::Add(pVehicle);
|
||||||
pVehicle->bCreateRoadBlockPeds = true;
|
pVehicle->bCreateRoadBlockPeds = true;
|
||||||
pVehicle->m_nRoadblockType = nRoadblockType;
|
pVehicle->m_nRoadblockType = nRoadblockType;
|
||||||
pVehicle->m_nRoadblockNode = nRoadblockNode;
|
pVehicle->m_nRoadblockNode = nRoadblockNode;
|
||||||
|
} else {
|
||||||
|
delete pVehicle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue