mirror of
https://github.com/halpz/re3.git
synced 2025-06-29 06:26:22 +00:00
@ -6,6 +6,7 @@
|
||||
#include "Curves.h"
|
||||
#include "PathFind.h"
|
||||
|
||||
//--MIAMI: done
|
||||
void CAutoPilot::ModifySpeed(float speed)
|
||||
{
|
||||
m_fMaxTrafficSpeed = Max(0.01f, speed);
|
||||
@ -39,6 +40,7 @@ void CAutoPilot::ModifySpeed(float speed)
|
||||
#endif
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
void CAutoPilot::RemoveOnePathNode()
|
||||
{
|
||||
--m_nPathFindNodesCount;
|
||||
@ -47,6 +49,7 @@ void CAutoPilot::RemoveOnePathNode()
|
||||
}
|
||||
|
||||
#ifdef COMPATIBLE_SAVES
|
||||
//--MIAMI: TODO
|
||||
void CAutoPilot::Save(uint8*& buf)
|
||||
{
|
||||
WriteSaveBuf<int32>(buf, m_nCurrentRouteNode);
|
||||
@ -86,6 +89,7 @@ void CAutoPilot::Save(uint8*& buf)
|
||||
SkipSaveBuf(buf, 6);
|
||||
}
|
||||
|
||||
//--MIAMI: TODO
|
||||
void CAutoPilot::Load(uint8*& buf)
|
||||
{
|
||||
m_nCurrentRouteNode = ReadSaveBuf<int32>(buf);
|
||||
|
@ -26,6 +26,15 @@ enum eCarMission : uint8
|
||||
MISSION_BLOCKCAR_FARAWAY,
|
||||
MISSION_BLOCKCAR_CLOSE,
|
||||
MISSION_BLOCKCAR_HANDBRAKESTOP,
|
||||
#ifdef MIAMI
|
||||
MISSION_HELI_FLYTOCOORS,
|
||||
MISSION_ATTACKPLAYER,
|
||||
MISSION_PLANE_FLYTOCOORS,
|
||||
MISSION_HELI_LAND,
|
||||
MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1,
|
||||
MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_2,
|
||||
MISSION_BLOCKPLAYER_FORWARDANDBACK
|
||||
#endif
|
||||
};
|
||||
|
||||
enum eCarTempAction : uint8
|
||||
@ -75,11 +84,18 @@ public:
|
||||
uint32 m_nTimeTempAction;
|
||||
float m_fMaxTrafficSpeed;
|
||||
uint8 m_nCruiseSpeed;
|
||||
#ifdef MIAMI
|
||||
uint8 m_nCruiseSpeedMultiplierType;
|
||||
float m_fCruiseSpeedMultiplier;
|
||||
#endif
|
||||
uint8 m_bSlowedDownBecauseOfCars : 1;
|
||||
uint8 m_bSlowedDownBecauseOfPeds : 1;
|
||||
uint8 m_bStayInCurrentLevel : 1;
|
||||
uint8 m_bStayInFastLane : 1;
|
||||
uint8 m_bIgnorePathfinding : 1;
|
||||
#ifdef MIAMI
|
||||
uint8 m_nSwitchDistance;
|
||||
#endif
|
||||
CVector m_vecDestinationCoors;
|
||||
CPathNode *m_aPathFindNodesInfo[NUM_PATH_NODES_IN_AUTOPILOT];
|
||||
int16 m_nPathFindNodesCount;
|
||||
@ -109,6 +125,10 @@ public:
|
||||
m_nTimeToStartMission = CTimer::GetTimeInMilliseconds();
|
||||
m_nAntiReverseTimer = m_nTimeToStartMission;
|
||||
m_bStayInFastLane = false;
|
||||
#ifdef MIAMI
|
||||
m_nCruiseSpeedMultiplierType = 0;
|
||||
m_fCruiseSpeedMultiplier = 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ModifySpeed(float);
|
||||
@ -119,4 +139,3 @@ public:
|
||||
#endif
|
||||
|
||||
};
|
||||
static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error");
|
@ -21,16 +21,23 @@
|
||||
|
||||
#define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f
|
||||
|
||||
//--MIAMI: done
|
||||
float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle)
|
||||
{
|
||||
#ifndef MIAMI
|
||||
return 30.0f;
|
||||
#else
|
||||
return pVehicle->AutoPilot.m_nSwitchDistance;
|
||||
#endif
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
float CCarAI::FindSwitchDistanceFarNormalVehicle(CVehicle* pVehicle)
|
||||
{
|
||||
return FindSwitchDistanceClose(pVehicle) + 5.0f;
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle)
|
||||
{
|
||||
if (pVehicle->bIsLawEnforcer)
|
||||
@ -38,6 +45,23 @@ float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle)
|
||||
return FindSwitchDistanceFarNormalVehicle(pVehicle);
|
||||
}
|
||||
|
||||
#ifdef MIAMI
|
||||
//--MIAMI: done
|
||||
void CCarAI::BackToCruisingIfNoWantedLevel(CVehicle* pVehicle)
|
||||
{
|
||||
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
|
||||
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
|
||||
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
|
||||
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
|
||||
pVehicle->m_bSirenOrAlarm = false;
|
||||
if (CCullZones::NoPolice())
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
{
|
||||
if (pVehicle->bIsLawEnforcer){
|
||||
@ -67,6 +91,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()))
|
||||
pVehicle->m_bSirenOrAlarm = true;
|
||||
}
|
||||
#ifndef MIAMI
|
||||
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
|
||||
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
|
||||
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
|
||||
@ -76,6 +101,9 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (CCullZones::NoPolice())
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
}
|
||||
#else
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
#endif
|
||||
break;
|
||||
case MISSION_RAMPLAYER_CLOSE:
|
||||
if (FindSwitchDistanceFar(pVehicle) >= (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
||||
@ -120,6 +148,11 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
pVehicle->m_bSirenOrAlarm = false;
|
||||
pVehicle->m_nCarHornTimer = 0;
|
||||
}
|
||||
#ifdef MIAMI
|
||||
if (pVehicle->bIsLawEnforcer)
|
||||
MellowOutChaseSpeed(pVehicle);
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
#else
|
||||
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
|
||||
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())){
|
||||
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
|
||||
@ -132,6 +165,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
|
||||
else if (pVehicle->bIsLawEnforcer)
|
||||
MellowOutChaseSpeed(pVehicle);
|
||||
#endif
|
||||
break;
|
||||
case MISSION_BLOCKPLAYER_FARAWAY:
|
||||
if (FindSwitchDistanceClose(pVehicle) > (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
||||
@ -140,6 +174,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()))
|
||||
pVehicle->m_bSirenOrAlarm = true;
|
||||
}
|
||||
#ifndef MIAMI
|
||||
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
|
||||
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
|
||||
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
|
||||
@ -149,6 +184,9 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (CCullZones::NoPolice())
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
}
|
||||
#else
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
#endif
|
||||
break;
|
||||
case MISSION_BLOCKPLAYER_CLOSE:
|
||||
if (FindSwitchDistanceFar(pVehicle) >= (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
||||
@ -178,6 +216,11 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
pVehicle->m_bSirenOrAlarm = false;
|
||||
pVehicle->m_nCarHornTimer = 0;
|
||||
}
|
||||
#ifdef MIAMI
|
||||
if (pVehicle->bIsLawEnforcer)
|
||||
MellowOutChaseSpeed(pVehicle);
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
#else
|
||||
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
|
||||
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
|
||||
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
|
||||
@ -192,7 +235,11 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
#endif
|
||||
break;
|
||||
case MISSION_GOTOCOORDS:
|
||||
#ifdef MIAMI
|
||||
if ((pVehicle->AutoPilot.m_vecDestinationCoors - pVehicle->GetPosition()).Magnitude2D() < FindSwitchDistanceClose(pVehicle) ||
|
||||
#else
|
||||
if ((pVehicle->AutoPilot.m_vecDestinationCoors - pVehicle->GetPosition()).Magnitude2D() < DISTANCE_TO_SWITCH_DISTANCE_GOTO ||
|
||||
#endif
|
||||
pVehicle->AutoPilot.m_bIgnorePathfinding)
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
|
||||
break;
|
||||
@ -204,6 +251,12 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (distance < 5.0f){
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
||||
#ifdef MIAMI
|
||||
if (pVehicle->bParking) {
|
||||
TellOccupantsToLeaveCar(pVehicle);
|
||||
pVehicle->bParking = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (distance > FindSwitchDistanceFarNormalVehicle(pVehicle) && !pVehicle->AutoPilot.m_bIgnorePathfinding && (CTimer::GetFrameCounter() & 7) == 0){
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
||||
@ -260,6 +313,12 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (distance < 1.0f) {
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
||||
#ifdef MIAMI
|
||||
if (pVehicle->bParking) {
|
||||
TellOccupantsToLeaveCar(pVehicle);
|
||||
pVehicle->bParking = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (distance > FindSwitchDistanceFarNormalVehicle(pVehicle) && !pVehicle->AutoPilot.m_bIgnorePathfinding && (CTimer::GetFrameCounter() & 7) == 0) {
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
||||
@ -279,6 +338,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
break;
|
||||
case MISSION_RAMCAR_CLOSE:
|
||||
if (pVehicle->AutoPilot.m_pTargetCar){
|
||||
#ifndef MIAMI
|
||||
if
|
||||
#ifdef FIX_BUGS
|
||||
(FindPlayerVehicle() == pVehicle->AutoPilot.m_pTargetCar &&
|
||||
@ -296,6 +356,12 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (CCullZones::NoPolice())
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
}
|
||||
#else
|
||||
#ifdef FIX_BUGS // btw fixed in SA
|
||||
if (FindPlayerVehicle() == pVehicle->AutoPilot.m_pTargetCar)
|
||||
#endif
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
#endif
|
||||
if ((pVehicle->AutoPilot.m_pTargetCar->GetPosition() - pVehicle->GetPosition()).Magnitude2D() <= FindSwitchDistanceFar(pVehicle) ||
|
||||
pVehicle->AutoPilot.m_bIgnorePathfinding){
|
||||
if (pVehicle->GetHasCollidedWith(pVehicle->AutoPilot.m_pTargetCar)){
|
||||
@ -337,6 +403,42 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
}
|
||||
break;
|
||||
#ifdef MIAMI
|
||||
case MISSION_ATTACKPLAYER:
|
||||
if (pVehicle->bIsLawEnforcer)
|
||||
MellowOutChaseSpeedBoat(pVehicle);
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
break;
|
||||
case MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1:
|
||||
if (((CVector2D)(pVehicle->AutoPilot.m_vecDestinationCoors) - pVehicle->GetPosition()).Magnitude() < 1.5f)
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_2;
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
break;
|
||||
case MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_2:
|
||||
{
|
||||
float distance = ((CVector2D)FindPlayerCoors() - pVehicle->GetPosition()).Magnitude();
|
||||
if (distance < 13.0f) {
|
||||
TellOccupantsToLeaveCar(pVehicle);
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_STOP_FOREVER;
|
||||
}
|
||||
if (distance > 70.0f || FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone ||
|
||||
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
|
||||
TellOccupantsToLeaveCar(pVehicle);
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_STOP_FOREVER;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MISSION_BLOCKPLAYER_FORWARDANDBACK:
|
||||
{
|
||||
CVector2D diff = (CVector2D)FindPlayerCoors() - pVehicle->GetPosition();
|
||||
float distance = Max(0.001f, diff.Magnitude());
|
||||
if (!FindPlayerVehicle() || DotProduct2D(CVector2D(diff.x / distance, diff.y / distance), FindPlayerSpeed()) > 0.05f)
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_CLOSE;
|
||||
BackToCruisingIfNoWantedLevel(pVehicle);
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && !CCullZones::NoPolice()){
|
||||
if (ABS(FindPlayerCoors().x - pVehicle->GetPosition().x) > 10.0f ||
|
||||
@ -344,6 +446,9 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = FindPoliceCarSpeedForWantedLevel(pVehicle);
|
||||
pVehicle->SetStatus(STATUS_PHYSICS);
|
||||
pVehicle->AutoPilot.m_nCarMission =
|
||||
#ifdef MIAMI
|
||||
pVehicle->GetVehicleAppearance() == VEHICLE_BOAT ? FindPoliceBoatMissionForWantedLevel() :
|
||||
#endif
|
||||
FindPoliceCarMissionForWantedLevel();
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
||||
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
|
||||
@ -365,6 +470,13 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
|
||||
break;
|
||||
}
|
||||
#ifdef MIAMI
|
||||
if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel >= 1 && CCullZones::PoliceAbandonCars()) {
|
||||
TellOccupantsToLeaveCar(pVehicle);
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||
}
|
||||
#endif
|
||||
float flatSpeed = pVehicle->GetMoveSpeed().MagnitudeSqr2D();
|
||||
if (flatSpeed > SQR(0.018f)){
|
||||
pVehicle->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds();
|
||||
@ -373,9 +485,16 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (pVehicle->GetStatus() == STATUS_PHYSICS && pVehicle->AutoPilot.m_nTempAction == TEMPACT_NONE){
|
||||
if (pVehicle->AutoPilot.m_nCarMission != MISSION_NONE){
|
||||
if (pVehicle->AutoPilot.m_nCarMission != MISSION_STOP_FOREVER &&
|
||||
#ifdef MIAMI
|
||||
pVehicle->AutoPilot.m_nCarMission != MISSION_BLOCKPLAYER_HANDBRAKESTOP &&
|
||||
#endif
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed != 0 &&
|
||||
(pVehicle->VehicleCreatedBy != RANDOM_VEHICLE || pVehicle->AutoPilot.m_nCarMission != MISSION_CRUISE)){
|
||||
if (pVehicle->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_STOP_FOR_CARS
|
||||
#ifdef MIAMI
|
||||
&& pVehicle->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_STOP_FOR_CARS_IGNORE_LIGHTS ||
|
||||
pVehicle->VehicleCreatedBy == MISSION_VEHICLE
|
||||
#endif
|
||||
) {
|
||||
if (CTimer::GetTimeInMilliseconds() - pVehicle->m_nLastTimeCollided > 500)
|
||||
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
|
||||
@ -407,6 +526,15 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 400;
|
||||
}
|
||||
}
|
||||
#ifdef MIAMI
|
||||
if (pVehicle->bIsLawEnforcer) {
|
||||
if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY ||
|
||||
pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE) {
|
||||
if (FindPlayerVehicle() && FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_BIKE)
|
||||
pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FARAWAY;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (pVehicle->GetUp().z < 0.7f){
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000;
|
||||
@ -446,13 +574,45 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if ((uint8)(pVehicle->m_randomSeed ^ CGeneral::GetRandomNumber()) == 0xAD)
|
||||
pVehicle->m_nCarHornTimer = 45;
|
||||
}
|
||||
#ifdef MIAMI
|
||||
float target = 1.0f;
|
||||
if (pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE)
|
||||
target = CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(pVehicle->AutoPilot.m_nCruiseSpeedMultiplierType);
|
||||
float change = CTimer::GetTimeStep() * 0.01f;
|
||||
if (Abs(pVehicle->AutoPilot.m_fCruiseSpeedMultiplier - target) < change)
|
||||
pVehicle->AutoPilot.m_fCruiseSpeedMultiplier = target;
|
||||
else if (pVehicle->AutoPilot.m_fCruiseSpeedMultiplier > target)
|
||||
pVehicle->AutoPilot.m_fCruiseSpeedMultiplier -= change;
|
||||
else
|
||||
pVehicle->AutoPilot.m_fCruiseSpeedMultiplier += change;
|
||||
|
||||
if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0) {
|
||||
if (!FindPlayerVehicle() ||
|
||||
FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_CAR ||
|
||||
FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_BIKE) {
|
||||
if (pVehicle->GetVehicleAppearance() == VEHICLE_BOAT) {
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000;
|
||||
}
|
||||
}
|
||||
else if (FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_BOAT) {
|
||||
if (pVehicle->GetVehicleAppearance() == VEHICLE_CAR ||
|
||||
pVehicle->GetVehicleAppearance() == VEHICLE_BIKE) {
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::CarHasReasonToStop(CVehicle* pVehicle)
|
||||
{
|
||||
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget)
|
||||
{
|
||||
if (pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS && pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS_STRAIGHT){
|
||||
@ -470,6 +630,18 @@ float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget)
|
||||
return (pVehicle->GetPosition() - *pTarget).Magnitude2D();
|
||||
}
|
||||
|
||||
#ifdef MIAMI
|
||||
//--MIAMI: done
|
||||
float CCarAI::GetCarToParkAtCoors(CVehicle* pVehicle, CVector* pTarget)
|
||||
{
|
||||
GetCarToGoToCoors(pVehicle, pTarget);
|
||||
pVehicle->bParking = true;
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = 10;
|
||||
return (pVehicle->GetPosition() - *pTarget).Magnitude2D();
|
||||
}
|
||||
#endif
|
||||
|
||||
//--MIAMI: TODO: MI_VICECHEE
|
||||
void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle)
|
||||
{
|
||||
if (pVehicle->bOccupantsHaveBeenGenerated)
|
||||
@ -489,23 +661,43 @@ void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle)
|
||||
if (FindPlayerPed()->m_pWanted->m_nWantedLevel > 1)
|
||||
pVehicle->SetupPassenger(0);
|
||||
return;
|
||||
#ifdef MIAMI
|
||||
case MI_PREDATOR:
|
||||
pVehicle->SetUpDriver();
|
||||
return;
|
||||
//TODO(MIAMI) uncomment this when we have MI_VICECHEE
|
||||
/*
|
||||
case MI_VICECHEE:
|
||||
{
|
||||
pVehicle->SetUpDriver()->bIsMiamiViceCop = true;
|
||||
pVehicle->SetUpPassenger(0)->bIsMiamiViceCop = true;
|
||||
CPopulation::NumMiamiViceCops += 2;
|
||||
CCarCtrl::MiamiViceCycle = (CCarCtrl::MiamiViceCycle + 1) % 4;
|
||||
CCarCtrl::LastTimeMiamiViceGenerated = CTimer::GetTimeInMilliseconds();
|
||||
return;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::AddAmbulanceOccupants(CVehicle* pVehicle)
|
||||
{
|
||||
pVehicle->SetUpDriver();
|
||||
pVehicle->SetupPassenger(1);
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::AddFiretruckOccupants(CVehicle* pVehicle)
|
||||
{
|
||||
pVehicle->SetUpDriver();
|
||||
pVehicle->SetupPassenger(0);
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle)
|
||||
{
|
||||
if (pVehicle->pDriver){
|
||||
@ -516,11 +708,38 @@ void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle)
|
||||
int timer = 100;
|
||||
for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++){
|
||||
if (pVehicle->pPassengers[i]) {
|
||||
#ifdef MIAMI
|
||||
pVehicle->pPassengers[i]->m_leaveCarTimer = timer;
|
||||
pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle);
|
||||
timer += CGeneral::GetRandomNumberInRange(200, 400);
|
||||
#else
|
||||
pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MIAMI
|
||||
//--MIAMI: done
|
||||
void CCarAI::TellOccupantsToFleeCar(CVehicle* pVehicle)
|
||||
{
|
||||
if (pVehicle->pDriver && !pVehicle->pDriver->IsPlayer()) {
|
||||
pVehicle->pDriver->SetObjective(OBJECTIVE_FLEE_TILL_SAFE);
|
||||
if (pVehicle->GetModelIndex() != MI_FIRETRUCK && pVehicle->GetModelIndex() == MI_AMBULAN)
|
||||
pVehicle->pDriver->Say(SOUND_PED_LEAVE_VEHICLE);
|
||||
}
|
||||
int timer = 100;
|
||||
for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) {
|
||||
if (pVehicle->pPassengers[i]) {
|
||||
pVehicle->pPassengers[i]->m_leaveCarTimer = timer;
|
||||
pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_FLEE_TILL_SAFE);
|
||||
timer += CGeneral::GetRandomNumberInRange(200, 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::TellCarToRamOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
|
||||
{
|
||||
pVehicle->AutoPilot.m_pTargetCar = pTarget;
|
||||
@ -530,6 +749,7 @@ void CCarAI::TellCarToRamOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
|
||||
{
|
||||
pVehicle->AutoPilot.m_pTargetCar = pTarget;
|
||||
@ -539,6 +759,7 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
|
||||
{
|
||||
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){
|
||||
@ -553,6 +774,24 @@ eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MIAMI
|
||||
//--MIAMI: done
|
||||
eCarMission CCarAI::FindPoliceBoatMissionForWantedLevel()
|
||||
{
|
||||
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
|
||||
case 0:
|
||||
case 1: return MISSION_BLOCKPLAYER_FARAWAY;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6: return MISSION_ATTACKPLAYER;
|
||||
default: return MISSION_BLOCKPLAYER_FARAWAY;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//--MIAMI: done
|
||||
int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle)
|
||||
{
|
||||
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
|
||||
@ -567,6 +806,7 @@ int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle)
|
||||
}
|
||||
}
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle)
|
||||
{
|
||||
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 1){
|
||||
@ -605,8 +845,31 @@ void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle)
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = 34;
|
||||
}
|
||||
}
|
||||
#ifdef MIAMI
|
||||
if (!FindPlayerVehicle() && FindPlayerPed()->GetMoveSpeed().Magnitude() < 0.07f) {
|
||||
if ((FindPlayerCoors() - pVehicle->GetPosition()).Magnitude() < 30.0f)
|
||||
pVehicle->AutoPilot.m_nCruiseSpeed = Min(10, pVehicle->AutoPilot.m_nCruiseSpeed);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MIAMI
|
||||
//--MIAMI: done
|
||||
void CCarAI::MellowOutChaseSpeedBoat(CVehicle* pVehicle)
|
||||
{
|
||||
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
|
||||
case 0: pVehicle->AutoPilot.m_nCruiseSpeed = 8; break;
|
||||
case 1: pVehicle->AutoPilot.m_nCruiseSpeed = 10; break;
|
||||
case 2: pVehicle->AutoPilot.m_nCruiseSpeed = 15; break;
|
||||
case 3: pVehicle->AutoPilot.m_nCruiseSpeed = 20; break;
|
||||
case 4: pVehicle->AutoPilot.m_nCruiseSpeed = 25; break;
|
||||
case 5: pVehicle->AutoPilot.m_nCruiseSpeed = 30; break;
|
||||
case 6: pVehicle->AutoPilot.m_nCruiseSpeed = 40; break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//--MIAMI: done
|
||||
void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle)
|
||||
{
|
||||
float flatSpeed = pVehicle->GetMoveSpeed().Magnitude2D();
|
||||
@ -629,6 +892,10 @@ void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle)
|
||||
continue;
|
||||
if (vehicle == pVehicle)
|
||||
continue;
|
||||
#ifdef MIAMI
|
||||
if (vehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
|
||||
return;
|
||||
#endif
|
||||
if (Abs(pVehicle->GetPosition().z - vehicle->GetPosition().z) >= 5.0f)
|
||||
continue;
|
||||
CVector2D distance = vehicle->GetPosition() - pVehicle->GetPosition();
|
||||
|
@ -10,17 +10,32 @@ public:
|
||||
static float FindSwitchDistanceClose(CVehicle*);
|
||||
static float FindSwitchDistanceFarNormalVehicle(CVehicle*);
|
||||
static float FindSwitchDistanceFar(CVehicle*);
|
||||
#ifdef MIAMI
|
||||
static void BackToCruisingIfNoWantedLevel(CVehicle*);
|
||||
#endif
|
||||
static void UpdateCarAI(CVehicle*);
|
||||
static void CarHasReasonToStop(CVehicle*);
|
||||
static float GetCarToGoToCoors(CVehicle*, CVector*);
|
||||
#ifdef MIAMI
|
||||
static float GetCarToParkAtCoors(CVehicle*, CVector*);
|
||||
#endif
|
||||
static void AddPoliceCarOccupants(CVehicle*);
|
||||
static void AddAmbulanceOccupants(CVehicle*);
|
||||
static void AddFiretruckOccupants(CVehicle*);
|
||||
static void TellOccupantsToLeaveCar(CVehicle*);
|
||||
#ifdef MIAMI
|
||||
static void TellOccupantsToFleeCar(CVehicle*);
|
||||
#endif
|
||||
static void TellCarToRamOtherCar(CVehicle*, CVehicle*);
|
||||
static void TellCarToBlockOtherCar(CVehicle*, CVehicle*);
|
||||
static eCarMission FindPoliceCarMissionForWantedLevel();
|
||||
#ifdef MIAMI
|
||||
static eCarMission FindPoliceBoatMissionForWantedLevel();
|
||||
#endif
|
||||
static int32 FindPoliceCarSpeedForWantedLevel(CVehicle*);
|
||||
static void MellowOutChaseSpeed(CVehicle*);
|
||||
#ifdef MIAMI
|
||||
static void MellowOutChaseSpeedBoat(CVehicle*);
|
||||
#endif
|
||||
static void MakeWayForCarWithSiren(CVehicle *veh);
|
||||
};
|
||||
|
@ -1641,6 +1641,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
|
||||
CPathNode* pTargetNode;
|
||||
int16 numNodes;
|
||||
float distanceToTargetNode;
|
||||
#ifndef MIAMI
|
||||
if (pTarget && pTarget->m_pCurGroundEntity &&
|
||||
pTarget->m_pCurGroundEntity->IsBuilding() &&
|
||||
((CBuilding*)pTarget->m_pCurGroundEntity)->GetIsATreadable() &&
|
||||
@ -1666,6 +1667,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
|
||||
#endif
|
||||
&pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, closestNode);
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
|
||||
ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode,
|
||||
@ -2749,3 +2751,15 @@ bool CCarCtrl::MapCouldMoveInThisArea(float x, float y)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MIAMI
|
||||
float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 1: return 1.5f;
|
||||
case 2: return 2.0f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
#endif
|
||||
|
@ -104,6 +104,9 @@ public:
|
||||
static void ClearInterestingVehicleList();
|
||||
static void FindLinksToGoWithTheseNodes(CVehicle*);
|
||||
static bool GenerateOneEmergencyServicesCar(uint32, CVector);
|
||||
#ifdef MIAMI
|
||||
static float FindSpeedMultiplierWithSpeedFromNodes(int8);
|
||||
#endif
|
||||
|
||||
static float GetPositionAlongCurrentCurve(CVehicle* pVehicle)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -55,6 +55,7 @@ public:
|
||||
|
||||
struct CPathNode
|
||||
{
|
||||
#ifndef MIAMI
|
||||
CVector pos;
|
||||
CPathNode *prev;
|
||||
CPathNode *next;
|
||||
@ -80,6 +81,44 @@ struct CPathNode
|
||||
CPathNode *GetNext(void) { return next; }
|
||||
void SetPrev(CPathNode *node) { prev = node; }
|
||||
void SetNext(CPathNode *node) { next = node; }
|
||||
#else
|
||||
int16 prevIndex;
|
||||
int16 nextIndex;
|
||||
int16 x;
|
||||
int16 y;
|
||||
int16 z;
|
||||
int16 distance; // in path search
|
||||
int16 firstLink;
|
||||
int8 width;
|
||||
int8 group;
|
||||
|
||||
uint8 numLinks : 4;
|
||||
uint8 bDeadEnd : 1;
|
||||
uint8 bDisabled : 1;
|
||||
uint8 bBetweenLevels : 1;
|
||||
uint8 bUseInRoadBlock : 1;
|
||||
|
||||
uint8 bWaterPath : 1;
|
||||
uint8 flagB2 : 1; // flag 2 in node info, always zero
|
||||
uint8 flagB4 : 1; // where is this set?
|
||||
uint8 speedLimit : 2;
|
||||
//uint8 flagB20 : 1;
|
||||
//uint8 flagB40 : 1;
|
||||
//uint8 flagB80 : 1;
|
||||
|
||||
uint8 spawnRate : 4;
|
||||
uint8 flagsC : 4;
|
||||
|
||||
CVector GetPosition(void) { return CVector(x/8.0f, y/8.0f, z/8.0f); }
|
||||
void SetPosition(const CVector &p) { x = p.x*8.0f; y = p.y*8.0f; z = p.z*8.0f; }
|
||||
float GetX(void) { return x/8.0f; }
|
||||
float GetY(void) { return y/8.0f; }
|
||||
float GetZ(void) { return z/8.0f; }
|
||||
CPathNode *GetPrev(void);
|
||||
CPathNode *GetNext(void);
|
||||
void SetPrev(CPathNode *node);
|
||||
void SetNext(CPathNode *node);
|
||||
#endif
|
||||
};
|
||||
|
||||
union CConnectionFlags
|
||||
@ -93,6 +132,7 @@ union CConnectionFlags
|
||||
|
||||
struct CCarPathLink
|
||||
{
|
||||
#ifndef MIAMI
|
||||
CVector2D pos;
|
||||
CVector2D dir;
|
||||
int16 pathNodeIndex;
|
||||
@ -109,6 +149,26 @@ struct CCarPathLink
|
||||
float GetY(void) { return pos.y; }
|
||||
float GetDirX(void) { return dir.x; }
|
||||
float GetDirY(void) { return dir.y; }
|
||||
#else
|
||||
int16 x;
|
||||
int16 y;
|
||||
int16 pathNodeIndex;
|
||||
int8 dirX;
|
||||
int8 dirY;
|
||||
int8 numLeftLanes : 3;
|
||||
int8 numRightLanes : 3;
|
||||
uint8 flag1 : 1;
|
||||
uint8 trafficLightType : 2;
|
||||
uint8 bBridgeLights : 1; // at least in LCS...
|
||||
int8 width;
|
||||
|
||||
CVector2D GetPosition(void) { return CVector2D(x/8.0f, y/8.0f); }
|
||||
CVector2D GetDirection(void) { return CVector2D(dirX/100.0f, dirY/100.0f); }
|
||||
float GetX(void) { return x/8.0f; }
|
||||
float GetY(void) { return y/8.0f; }
|
||||
float GetDirX(void) { return dirX/100.0f; }
|
||||
float GetDirY(void) { return dirY/100.0f; }
|
||||
#endif
|
||||
|
||||
float OneWayLaneOffset()
|
||||
{
|
||||
@ -123,6 +183,7 @@ struct CCarPathLink
|
||||
// This is what we're reading from the files, only temporary
|
||||
struct CPathInfoForObject
|
||||
{
|
||||
#ifndef MIAMI
|
||||
int16 x;
|
||||
int16 y;
|
||||
int16 z;
|
||||
@ -131,6 +192,28 @@ struct CPathInfoForObject
|
||||
int8 numLeftLanes;
|
||||
int8 numRightLanes;
|
||||
uint8 crossing : 1;
|
||||
#else
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
int8 type;
|
||||
int8 next;
|
||||
int8 numLeftLanes;
|
||||
int8 numRightLanes;
|
||||
int8 speedLimit;
|
||||
int8 width;
|
||||
|
||||
uint8 crossing : 1;
|
||||
uint8 flag02 : 1; // always zero
|
||||
uint8 roadBlock : 1;
|
||||
uint8 disabled : 1;
|
||||
uint8 waterPath : 1;
|
||||
uint8 betweenLevels : 1;
|
||||
|
||||
uint8 spawnRate : 4;
|
||||
|
||||
void SwapConnectionsToBeRightWayRound(void);
|
||||
#endif
|
||||
};
|
||||
extern CPathInfoForObject *InfoForTileCars;
|
||||
extern CPathInfoForObject *InfoForTilePeds;
|
||||
@ -138,6 +221,7 @@ extern CPathInfoForObject *InfoForTilePeds;
|
||||
struct CTempNode
|
||||
{
|
||||
CVector pos;
|
||||
#ifndef MIAMI
|
||||
float dirX;
|
||||
float dirY;
|
||||
int16 link1;
|
||||
@ -145,12 +229,37 @@ struct CTempNode
|
||||
int8 numLeftLanes;
|
||||
int8 numRightLanes;
|
||||
int8 linkState;
|
||||
#else
|
||||
int8 dirX; // *100
|
||||
int8 dirY;
|
||||
int16 link1;
|
||||
int16 link2;
|
||||
int8 numLeftLanes;
|
||||
int8 numRightLanes;
|
||||
int8 width;
|
||||
bool isCross;
|
||||
int8 linkState;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef MIAMI
|
||||
struct CTempNodeExternal // made up name
|
||||
{
|
||||
CVector pos;
|
||||
int16 next;
|
||||
int8 numLeftLanes;
|
||||
int8 numRightLanes;
|
||||
int8 width;
|
||||
bool isCross;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef MIAMI
|
||||
struct CTempDetachedNode // unused
|
||||
{
|
||||
uint8 foo[20];
|
||||
};
|
||||
#endif
|
||||
|
||||
class CPathFind
|
||||
{
|
||||
@ -158,10 +267,15 @@ public:
|
||||
CPathNode m_pathNodes[NUM_PATHNODES];
|
||||
CCarPathLink m_carPathLinks[NUM_CARPATHLINKS];
|
||||
CTreadable *m_mapObjects[NUM_MAPOBJECTS];
|
||||
#ifndef MIAMI
|
||||
uint8 m_objectFlags[NUM_MAPOBJECTS];
|
||||
int16 m_connections[NUM_PATHCONNECTIONS];
|
||||
int16 m_distances[NUM_PATHCONNECTIONS];
|
||||
CConnectionFlags m_connectionFlags[NUM_PATHCONNECTIONS];
|
||||
#else
|
||||
uint16 m_connections[NUM_PATHCONNECTIONS]; // and flags
|
||||
uint8 m_distances[NUM_PATHCONNECTIONS];
|
||||
#endif
|
||||
int16 m_carPathConnections[NUM_PATHCONNECTIONS];
|
||||
|
||||
int32 m_numPathNodes;
|
||||
@ -179,12 +293,20 @@ public:
|
||||
void RegisterMapObject(CTreadable *mapObject);
|
||||
void StoreNodeInfoPed(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, bool crossing);
|
||||
void StoreNodeInfoCar(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, int8 numLeft, int8 numRight);
|
||||
#ifndef MIAMI
|
||||
void CalcNodeCoors(int16 x, int16 y, int16 z, int32 id, CVector *out);
|
||||
#else
|
||||
void CalcNodeCoors(float x, float y, float z, int32 id, CVector *out);
|
||||
#endif
|
||||
bool LoadPathFindData(void);
|
||||
void PreparePathData(void);
|
||||
void CountFloodFillGroups(uint8 type);
|
||||
void PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoForObject *objectpathinfo,
|
||||
#ifndef MIAMI
|
||||
float maxdist, CTempDetachedNode *detachednodes, int32 numDetached);
|
||||
#else
|
||||
float maxdist, CPathInfoForObject *detachednodes, int32 numDetached);
|
||||
#endif
|
||||
|
||||
bool IsPathObject(int id) { return id < PATHNODESIZE && (InfoForTileCars[id*12].type != 0 || InfoForTilePeds[id*12].type != 0); }
|
||||
|
||||
@ -202,29 +324,56 @@ public:
|
||||
void MarkRoadsBetweenLevelsNodeAndNeighbours(int32 nodeId);
|
||||
void MarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y2, float z1, float z2);
|
||||
void PedMarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y2, float z1, float z2);
|
||||
#ifndef MIAMI
|
||||
int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled = false, bool ignoreBetweenLevels = false);
|
||||
#else
|
||||
//--MIAMI: TODO: check callers for new arguments
|
||||
int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled = false, bool ignoreBetweenLevels = false, bool ignoreFlagB4 = false, bool bWaterPath = false);
|
||||
#endif
|
||||
int32 FindNodeClosestToCoorsFavourDirection(CVector coors, uint8 type, float dirX, float dirY);
|
||||
float FindNodeOrientationForCarPlacement(int32 nodeId);
|
||||
float FindNodeOrientationForCarPlacementFacingDestination(int32 nodeId, float x, float y, bool towards);
|
||||
bool NewGenerateCarCreationCoors(float x, float y, float dirX, float dirY, float spawnDist, float angleLimit, bool forward, CVector *pPosition, int32 *pNode1, int32 *pNode2, float *pPositionBetweenNodes, bool ignoreDisabled = false);
|
||||
bool GeneratePedCreationCoors(float x, float y, float minDist, float maxDist, float minDistOffScreen, float maxDistOffScreen, CVector *pPosition, int32 *pNode1, int32 *pNode2, float *pPositionBetweenNodes, CMatrix *camMatrix);
|
||||
#ifndef MIAMI
|
||||
CTreadable *FindRoadObjectClosestToCoors(CVector coors, uint8 type);
|
||||
#endif
|
||||
void FindNextNodeWandering(uint8, CVector, CPathNode**, CPathNode**, uint8, uint8*);
|
||||
void DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, CPathNode **nodes, int16 *numNodes, int16 maxNumNodes, CVehicle *vehicle, float *dist, float distLimit, int32 forcedTargetNode);
|
||||
bool TestCoorsCloseness(CVector target, uint8 type, CVector start);
|
||||
void Save(uint8 *buf, uint32 *size);
|
||||
void Load(uint8 *buf, uint32 size);
|
||||
|
||||
#ifdef MIAMI
|
||||
CPathNode *GetNode(int16 index);
|
||||
int16 GetIndex(CPathNode *node);
|
||||
|
||||
uint16 ConnectedNode(int id) { return m_connections[id] & 0x3FFF; }
|
||||
bool ConnectionCrossesRoad(int id) { return !!(m_connections[id] & 0x8000); }
|
||||
bool ConnectionHasTrafficLight(int id) { return !!(m_connections[id] & 0x4000); }
|
||||
void ConnectionSetTrafficLight(int id) { m_connections[id] |= 0x4000; }
|
||||
#else
|
||||
uint16 ConnectedNode(int id) { return m_connections[id]; }
|
||||
bool ConnectionCrossesRoad(int id) { return m_connectionFlags[id].bCrossesRoad; }
|
||||
bool ConnectionHasTrafficLight(int id) { return m_connectionFlags[id].bTrafficLight; }
|
||||
void ConnectionSetTrafficLight(int id) { m_connectionFlags[id].bTrafficLight = true; }
|
||||
#endif
|
||||
|
||||
void DisplayPathData(void);
|
||||
};
|
||||
#ifndef MIAMI
|
||||
static_assert(sizeof(CPathFind) == 0x49bf4, "CPathFind: error");
|
||||
#endif
|
||||
|
||||
extern CPathFind ThePaths;
|
||||
|
||||
#ifdef MIAMI
|
||||
inline CPathNode *CPathNode::GetPrev(void) { return ThePaths.GetNode(prevIndex); }
|
||||
inline CPathNode *CPathNode::GetNext(void) { return ThePaths.GetNode(nextIndex); }
|
||||
inline void CPathNode::SetPrev(CPathNode *node) { prevIndex = ThePaths.GetIndex(node); }
|
||||
inline void CPathNode::SetNext(CPathNode *node) { nextIndex = ThePaths.GetIndex(node); }
|
||||
#endif
|
||||
|
||||
extern bool gbShowPedPaths;
|
||||
extern bool gbShowCarPaths;
|
||||
extern bool gbShowCarPathsLinks;
|
||||
|
@ -417,8 +417,10 @@ void CRecordDataForChase::GiveUsACar(int32 mi, CVector pos, float angle, CAutomo
|
||||
*ppCar = pCar;
|
||||
}
|
||||
|
||||
//--MIAMI: unused
|
||||
void RemoveUnusedCollision(void)
|
||||
{
|
||||
#ifndef MIAMI
|
||||
static const char* dontDeleteArray[] = {
|
||||
"rd_SrRoad2A50", "rd_SrRoad2A20", "rd_CrossRda1w22", "rd_CrossRda1rw22",
|
||||
"road_broadway02", "road_broadway01", "com_21way5", "com_21way50",
|
||||
@ -430,6 +432,7 @@ void RemoveUnusedCollision(void)
|
||||
CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_NONE);
|
||||
for (int i = 0; i < ARRAY_SIZE(dontDeleteArray); i++)
|
||||
CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_COMMERCIAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CRecordDataForChase::StartChaseScene(float startTime)
|
||||
|
@ -15,22 +15,40 @@
|
||||
#include "CarCtrl.h"
|
||||
#include "General.h"
|
||||
|
||||
#ifndef MIAMI
|
||||
#define ROADBLOCKDIST (80.0f)
|
||||
#else
|
||||
#define ROADBLOCKDIST (90.0f)
|
||||
#endif
|
||||
|
||||
int16 CRoadBlocks::NumRoadBlocks;
|
||||
#ifndef MIAMI
|
||||
int16 CRoadBlocks::RoadBlockObjects[NUMROADBLOCKS];
|
||||
#else
|
||||
int16 CRoadBlocks::RoadBlockNodes[NUMROADBLOCKS];
|
||||
#endif
|
||||
bool CRoadBlocks::InOrOut[NUMROADBLOCKS];
|
||||
|
||||
//--MIAMI: TODO: script roadblocks
|
||||
void
|
||||
CRoadBlocks::Init(void)
|
||||
{
|
||||
int i;
|
||||
NumRoadBlocks = 0;
|
||||
#ifndef MIAMI
|
||||
for (i = 0; i < ThePaths.m_numMapObjects; i++) {
|
||||
if (ThePaths.m_objectFlags[i] & UseInRoadBlock) {
|
||||
#else
|
||||
for(i = 0; i < ThePaths.m_numCarPathNodes; i++){
|
||||
if(ThePaths.m_pathNodes[i].bUseInRoadBlock && ThePaths.m_pathNodes[i].numLinks == 2){
|
||||
#endif
|
||||
if (NumRoadBlocks < NUMROADBLOCKS) {
|
||||
InOrOut[NumRoadBlocks] = true;
|
||||
#ifndef MIAMI
|
||||
RoadBlockObjects[NumRoadBlocks] = i;
|
||||
#else
|
||||
RoadBlockNodes[NumRoadBlocks] = i;
|
||||
#endif
|
||||
NumRoadBlocks++;
|
||||
} else {
|
||||
#ifndef MASTER
|
||||
@ -110,14 +128,19 @@ CRoadBlocks::GenerateRoadBlocks(void)
|
||||
int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16;
|
||||
const int16 maxRoadBlocks = (int16)(NUMROADBLOCKS * (frame + 1)) / 16;
|
||||
for (; nRoadblockNode < Min(NumRoadBlocks, maxRoadBlocks); nRoadblockNode++) {
|
||||
#ifndef MIAMI
|
||||
CTreadable *mapObject = ThePaths.m_mapObjects[RoadBlockObjects[nRoadblockNode]];
|
||||
CVector2D vecDistance = FindPlayerCoors() - mapObject->GetPosition();
|
||||
#else
|
||||
CVector2D vecDistance = FindPlayerCoors() - ThePaths.m_pathNodes[nRoadblockNode].GetPosition();
|
||||
#endif
|
||||
if (vecDistance.x > -ROADBLOCKDIST && vecDistance.x < ROADBLOCKDIST &&
|
||||
vecDistance.y > -ROADBLOCKDIST && vecDistance.y < ROADBLOCKDIST &&
|
||||
vecDistance.Magnitude() < ROADBLOCKDIST) {
|
||||
if (!InOrOut[nRoadblockNode]) {
|
||||
InOrOut[nRoadblockNode] = true;
|
||||
if (FindPlayerVehicle() && (CGeneral::GetRandomNumber() & 0x7F) < FindPlayerPed()->m_pWanted->m_RoadblockDensity) {
|
||||
#ifndef MIAMI
|
||||
CWanted *pPlayerWanted = FindPlayerPed()->m_pWanted;
|
||||
float fMapObjectRadius = 2.0f * mapObject->GetColModel()->boundingBox.max.x;
|
||||
int32 vehicleId = MI_POLICE;
|
||||
@ -187,10 +210,13 @@ CRoadBlocks::GenerateRoadBlocks(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InOrOut[nRoadblockNode] = false;
|
||||
}
|
||||
}
|
||||
|
||||
//--MIAMI: TODO script roadblocks
|
||||
}
|
||||
|
@ -7,7 +7,11 @@ class CRoadBlocks
|
||||
{
|
||||
public:
|
||||
static int16 NumRoadBlocks;
|
||||
#ifndef MIAMI
|
||||
static int16 RoadBlockObjects[NUMROADBLOCKS];
|
||||
#else
|
||||
static int16 RoadBlockNodes[NUMROADBLOCKS];
|
||||
#endif
|
||||
static bool InOrOut[NUMROADBLOCKS];
|
||||
|
||||
static void Init(void);
|
||||
|
@ -372,6 +372,9 @@ private:
|
||||
friend class CRunningScript;
|
||||
friend class CHud;
|
||||
friend void CMissionCleanup::Process();
|
||||
#ifdef MIAMI
|
||||
friend class CColStore;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user