diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2021-08-16 00:03:08 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2021-08-16 00:03:08 +0200 |
commit | 8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e (patch) | |
tree | 42811fabbb52e7fd5afdbde4143a6e34c581eecc | |
parent | fix (diff) | |
download | re3-8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e.tar re3-8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e.tar.gz re3-8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e.tar.bz2 re3-8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e.tar.lz re3-8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e.tar.xz re3-8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e.tar.zst re3-8e2ed40f66bfe8a97ab07bf5f5f653d700abea3e.zip |
-rw-r--r-- | src/control/CarCtrl.cpp | 129 | ||||
-rw-r--r-- | src/core/IniFile.cpp | 7 | ||||
-rw-r--r-- | src/modelinfo/ModelIndices.h | 21 | ||||
-rw-r--r-- | src/vehicles/Automobile.cpp | 2 | ||||
-rw-r--r-- | src/vehicles/Vehicle.cpp | 3 | ||||
-rw-r--r-- | src/vehicles/Vehicle.h | 2 |
6 files changed, 115 insertions, 49 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 2bedaec2..927ee148 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -41,7 +41,7 @@ //--LCS: file done except TODO -#define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS (51.0f) +#define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS (51.0f) // apparently POPULATION_CULL_RANGE? TODO: unite with CPopulation #define DISTANCE_TO_SCAN_FOR_DANGER (14.0f) #define DISTANCE_TO_SCAN_FOR_PED_DANGER (11.0f) #define SAFE_DISTANCE_TO_PED (3.0f) @@ -81,8 +81,16 @@ #define DISTANCE_BETWEEN_CAR_AND_DEAD_PED (6.0f) #define PROBABILITY_OF_PASSENGER_IN_VEHICLE (0.125f) +#ifdef GTA_PSP +#define ONSCREEN_DESPAWN_RANGE (160.0f) +#define MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN (100.0f) +#define MAX_DISTANCE_FROM_CAMERA_TO_SPAWN_ONSCREEN (82.5f) +#else #define ONSCREEN_DESPAWN_RANGE (190.0f) #define MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN (130.0f) +#define MAX_DISTANCE_FROM_CAMERA_TO_SPAWN_ONSCREEN (105.0f) +#endif + #define REQUEST_ONSCREEN_DISTANCE (140.0f) #define OFFSCREEN_DESPAWN_RANGE (60.0f) #define MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN (40.0f) @@ -148,33 +156,53 @@ CCarCtrl::GenerateOneRandomCar() CZoneInfo zone; CTheZones::GetZoneInfoForTimeOfDay(&vecTargetPos, &zone); pPlayer->m_nTrafficMultiplier = pPlayer->m_fRoadDensity * zone.carDensity; - if (NumRandomCars >= pPlayer->m_nTrafficMultiplier * CarDensityMultiplier * CIniFile::CarNumberMultiplier) - return; - if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars + NumLawEnforcerCars + NumRandomCars >= MaxNumberOfCarsInUse) - return; +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + // TODO + } + else +#endif + { + if (NumRandomCars >= pPlayer->m_nTrafficMultiplier * CarDensityMultiplier * CIniFile::CarNumberMultiplier) + return; + if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars + NumLawEnforcerCars + NumRandomCars >= MaxNumberOfCarsInUse) + return; + } CWanted* pWanted = pPlayer->m_pPed->m_pWanted; int carClass; int carModel; - if (pWanted->GetWantedLevel() > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles && - pWanted->m_CurrentCops < pWanted->m_MaxCops && !CGame::IsInInterior() && ( - pWanted->GetWantedLevel() > 3 || - pWanted->GetWantedLevel() > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 || - pWanted->GetWantedLevel() > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) { - /* Last pWanted->GetWantedLevel() > 1 is unnecessary but I added it for better readability. */ - /* Wouldn't be surprised it was there originally but was optimized out. */ - carClass = COPS; - carModel = ChoosePoliceCarModel(); - }else{ - for (int i = 0; i < 5; i++) { - carModel = ChooseModel(&zone, &carClass); - if (carModel == -1) - return; - if (!(carClass == COPS && pWanted->GetWantedLevel() >= 1)) - /* All cop spawns with wanted level are handled by condition above. */ - /* In particular it means that cop cars never spawn if player has wanted level of 1. */ - break; +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + carModel = ChooseModel(&zone, &carClass); + if (carModel == -1) + return; + } + else +#else + { + if (pWanted->GetWantedLevel() > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles && + pWanted->m_CurrentCops < pWanted->m_MaxCops && !CGame::IsInInterior() && ( + pWanted->GetWantedLevel() > 3 || + pWanted->GetWantedLevel() > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 || + pWanted->GetWantedLevel() > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) { + /* Last pWanted->GetWantedLevel() > 1 is unnecessary but I added it for better readability. */ + /* Wouldn't be surprised it was there originally but was optimized out. */ + carClass = COPS; + carModel = ChoosePoliceCarModel(); + } + else { + for (int i = 0; i < 5; i++) { + carModel = ChooseModel(&zone, &carClass); + if (carModel == -1) + return; + if (!(carClass == COPS && pWanted->GetWantedLevel() >= 1)) + /* All cop spawns with wanted level are handled by condition above. */ + /* In particular it means that cop cars never spawn if player has wanted level of 1. */ + break; + } } } +#endif float frontX, frontY; float preferredDistance, angleLimit; float requestMultiplier = 1.0f; @@ -373,10 +401,16 @@ CCarCtrl::GenerateOneRandomCar() CVehicle* pVehicle; if (CModelInfo::IsBoatModel(carModel)) pVehicle = new CBoat(carModel, RANDOM_VEHICLE); - else if (CModelInfo::IsBikeModel(carModel)) - pVehicle = new CBike(carModel, RANDOM_VEHICLE); else - pVehicle = new CAutomobile(carModel, RANDOM_VEHICLE); + { + if (CModelInfo::IsBikeModel(carModel)) + pVehicle = new CBike(carModel, RANDOM_VEHICLE); + else + pVehicle = new CAutomobile(carModel, RANDOM_VEHICLE); +#ifdef GTA_NETWORK + // TODO +#endif + } pVehicle->AutoPilot.m_nPrevRouteNode = 0; pVehicle->AutoPilot.m_nCurrentRouteNode = curNodeId; pVehicle->AutoPilot.m_nNextRouteNode = nextNodeId; @@ -394,7 +428,7 @@ CCarCtrl::GenerateOneRandomCar() pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE; } - if (carModel == MI_FBIRANCH){ + if (carModel == MI_FBICAR){ pVehicle->m_currentColour1 = 0; pVehicle->m_currentColour2 = 0; } @@ -616,6 +650,9 @@ CCarCtrl::GenerateOneRandomCar() break; } CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0); +#ifdef GTA_MOBILE + //CVisibilityPlugins::SetObjectDistanceAlpha(pVehicle->GetClump(), 0) // TODO(LCS) +#endif if (!pVehicle->GetIsOnScreen()){ if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > OFFSCREEN_DESPAWN_RANGE * (pVehicle->bExtendedRange ? EXTENDED_RANGE_DESPAWN_MULTIPLIER : 1.0f)) { /* Too far away cars that are not visible aren't needed. */ @@ -628,7 +665,7 @@ CCarCtrl::GenerateOneRandomCar() delete pVehicle; return; } - if ((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < 105.0f * requestMultiplier * TheCamera.GenerationDistMultiplier || bTopDownCamera) { + if ((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < MAX_DISTANCE_FROM_CAMERA_TO_SPAWN_ONSCREEN * requestMultiplier * TheCamera.GenerationDistMultiplier || bTopDownCamera) { delete pVehicle; return; } @@ -662,16 +699,21 @@ CCarCtrl::GenerateOneRandomCar() CCarAI::AddPoliceCarOccupants(pVehicle); else { pVehicle->SetUpDriver(); - int32 passengers = 0; - for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) - passengers += (CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < PROBABILITY_OF_PASSENGER_IN_VEHICLE) ? 1 : 0; - if (CModelInfo::IsCarModel(carModel) && (CModelInfo::GetModelInfo(carModel)->GetAnimFileIndex() == CAnimManager::GetAnimationBlockIndex("van") && passengers >= 1)) - passengers = 1; - for (int i = 0; i < passengers; i++) { - CPed* pPassenger = pVehicle->SetupPassenger(i); - if (pPassenger) { - ++CPopulation::ms_nTotalCarPassengerPeds; - pPassenger->bCarPassenger = true; +#ifdef GTA_NETWORK + if (!gIsMultiplayerGame) +#endif + { + int32 passengers = 0; + for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) + passengers += (CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < PROBABILITY_OF_PASSENGER_IN_VEHICLE) ? 1 : 0; + if (CModelInfo::IsCarModel(carModel) && (CModelInfo::GetModelInfo(carModel)->GetAnimFileIndex() == CAnimManager::GetAnimationBlockIndex("van") && passengers >= 1)) + passengers = 1; + for (int i = 0; i < passengers; i++) { + CPed* pPassenger = pVehicle->SetupPassenger(i); + if (pPassenger) { + ++CPopulation::ms_nTotalCarPassengerPeds; + pPassenger->bCarPassenger = true; + } } } } @@ -741,6 +783,9 @@ CCarCtrl::GenerateOneRandomCar() } } } +#ifdef GTA_NETWORK + // TODO +#endif } int32 @@ -802,6 +847,8 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, int* pClass) { } if (i == 0) return -1; + if (CModelInfo::GetColModel(model)->boundingSphere.radius > 20.0f) + return -1; return model; } @@ -3404,7 +3451,13 @@ CCarCtrl::BoatWithTallMast(int32 mi) bool CCarCtrl::OkToCreateVehicleAtThisPosition(const CVector& pos) { +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + // TODO + } +#else return true; +#endif } float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type) diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp index 8e0929ae..cf7a7f0c 100644 --- a/src/core/IniFile.cpp +++ b/src/core/IniFile.cpp @@ -8,7 +8,12 @@ #include "Population.h" float CIniFile::PedNumberMultiplier = 0.6f; -float CIniFile::CarNumberMultiplier = 0.8f; +float CIniFile::CarNumberMultiplier = +#ifdef GTA_PSP + 0.7f; +#else + 0.8f; +#endif void CIniFile::LoadIniFile() { diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index efaa1ef8..173b50ff 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -1089,26 +1089,31 @@ enum MI_LAST_VEHICLE = MI_VCNMAV, + // these indices are sort of original - // with these three i don't know which is which: - MI_RCBARON = -999, - MI_CADDY = -963, + MI_CADDY = -999, + + // with these two i don't know which is which: + MI_RCBARON = -963, MI_BAGGAGE = -955, + MI_SANDKING = -981, + MI_VICECHEE = -954, + MI_MARQUIS = -990, + + // these two also unknown + MI_RIO = -992, + MI_TROPIC = -988, + // HACK HACK, hopefully temporary MI_SEASPAR = -2000, MI_SPARROW, MI_FBIRANCH, - MI_VICECHEE, - MI_RIO, MI_SQUALO, MI_JETMAX, MI_COASTG, MI_DINGHY, - MI_MARQUIS, MI_SKIMMER, - MI_TROPIC, - MI_SANDKING, MI_VOODOO, MI_CUBAN, MI_PHEONIX, diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 1625b1b2..0b6f4422 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -495,7 +495,7 @@ CAutomobile::ProcessControl(void) m_aSuspensionSpringRatio[1] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[1].surfaceB) == ADHESIVE_SAND || m_aSuspensionSpringRatio[2] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[2].surfaceB) == ADHESIVE_SAND || m_aSuspensionSpringRatio[3] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[3].surfaceB) == ADHESIVE_SAND){ - if(GetModelIndex() != MI_RCBANDIT /*&& GetModelIndex() != MI_SANDKING*/ && GetModelIndex() != MI_BFINJECT){ + if(GetModelIndex() != MI_RCBANDIT && GetModelIndex() != MI_SANDKING && GetModelIndex() != MI_BFINJECT){ bStuckInSand = true; if(CWeather::WetRoads > 0.0f) ApplyMoveForce(m_vecMoveSpeed * -CTimer::GetTimeStep()*SAND_SLOWDOWN*m_fMass * (1.0f-CWeather::WetRoads)); diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index d1404b14..281311e8 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -84,6 +84,9 @@ CVehicle::CVehicle(uint8 CreatedBy) m_fGasPedal = 0.0f; m_fBrakePedal = 0.0; m_vehLCS_264 = 0; +#if defined FIX_BUGS || !defined GTA_PSP + bRewardVehicle = false; +#endif m_vehLCS_29E = 0; m_vehLCS_29C = 0; m_vehLCS_2A3 = -1; diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index b89c8158..dc044b53 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -248,7 +248,7 @@ public: #if (!defined GTA_PS2 || defined FIX_BUGS) // <- I think this can be moved back to CAutomobile? uint8 m_bombType : 3; #endif - uint8 bDriverLastFrame : 1; + uint8 bDriverLastFrame : 1; // originally not in CVehicle (TODO - carbomb stuff) uint8 bRewardVehicle : 1; // 25B_40 int8 m_numPedsUseItAsCover; |