summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/control/CarAI.cpp24
-rw-r--r--src/control/CarCtrl.cpp133
-rw-r--r--src/core/IniFile.cpp7
-rw-r--r--src/modelinfo/ModelIndices.h26
-rw-r--r--src/vehicles/Vehicle.cpp3
-rw-r--r--src/vehicles/Vehicle.h2
6 files changed, 138 insertions, 57 deletions
diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp
index 11d756b4..1ee99b89 100644
--- a/src/control/CarAI.cpp
+++ b/src/control/CarAI.cpp
@@ -599,8 +599,18 @@ void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle)
{
if (pVehicle->pDriver){
pVehicle->pDriver->SetObjective(OBJECTIVE_LEAVE_CAR, pVehicle);
- if (pVehicle->GetModelIndex() == MI_AMBULAN)
+ switch (pVehicle->GetModelIndex()) {
+ case MI_FIRETRUCK:
+ case MI_FBICAR:
+ case MI_ENFORCER:
+ case MI_BARRACKS:
+ case MI_RHINO:
+ case MI_POLICE:
+ break;
+ case MI_AMBULAN:
pVehicle->pDriver->Say(SOUND_PED_LEAVE_VEHICLE);
+ break;
+ }
}
int timer = 100;
for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++){
@@ -616,8 +626,18 @@ void CCarAI::TellOccupantsToFleeCar(CVehicle* pVehicle)
{
if (pVehicle->pDriver && !pVehicle->pDriver->IsPlayer()) {
pVehicle->pDriver->SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE);
- if (pVehicle->GetModelIndex() != MI_FIRETRUCK && pVehicle->GetModelIndex() == MI_AMBULAN)
+ switch (pVehicle->GetModelIndex()) {
+ case MI_FIRETRUCK:
+ case MI_FBIRANCH:
+ case MI_ENFORCER:
+ case MI_BARRACKS:
+ case MI_RHINO:
+ case MI_POLICE:
+ break;
+ case MI_AMBULAN:
pVehicle->pDriver->Say(SOUND_PED_LEAVE_VEHICLE);
+ break;
+ }
}
int timer = 100;
for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) {
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index 026a2057..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;
}
@@ -1586,7 +1633,7 @@ void CCarCtrl::WeaveThroughCarsSectorList(CPtrList& lst, CVehicle* pVehicle, CPh
continue;
if (Abs(pTestVehicle->GetPosition().z - pVehicle->GetPosition().z) >= VEHICLE_HEIGHT_DIFF_TO_CONSIDER_WEAVING)
continue;
- if (pTestVehicle != pVehicle)
+ if (pTestVehicle != pVehicle && (!pVehicle->bPartOfConvoy || !pTestVehicle->bPartOfConvoy))
WeaveForOtherCar(pTestVehicle, pVehicle, pAngleToWeaveLeft, pAngleToWeaveRight);
}
}
@@ -1594,8 +1641,6 @@ void CCarCtrl::WeaveThroughCarsSectorList(CPtrList& lst, CVehicle* pVehicle, CPh
void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float* pAngleToWeaveLeft, float* pAngleToWeaveRight)
{
CVehicle* pOtherCar = (CVehicle*)pOtherEntity;
- if (pVehicle->bPartOfConvoy && pOtherCar->bPartOfConvoy)
- return;
if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE && pOtherEntity == FindPlayerVehicle())
return;
if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMCAR_CLOSE && pOtherEntity == pVehicle->AutoPilot.m_pTargetCar)
@@ -3406,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 581296b9..8cb83d5d 100644
--- a/src/modelinfo/ModelIndices.h
+++ b/src/modelinfo/ModelIndices.h
@@ -1089,28 +1089,30 @@ enum
MI_LAST_VEHICLE = MI_VCNMAV,
- // these indices are sort of original
- // with these two i don't know which is which:
- MI_CADDY = -963,
- MI_BAGGAGE = -999,
- MI_RCBARON = -955,
- MI_COMET = -972, // ps2 CAutomobile::IsOpenTopCar
- MI_SANDKING = -981, // ps2 CAutomobile::ProcessControl
- MI_VOODOO = -984, // ps2 hydraulics
+
+ // these indices are original
+ MI_CADDY = -999,
+ MI_MARQUIS = -990,
MI_SEASPAR = -986,
MI_SPARROW = -985,
+ MI_VOODOO = -984,
+ MI_SANDKING = -981,
+ MI_COMET = -972,
+ MI_BAGGAGE = -963,
+ MI_VICECHEE = -954,
+ MI_RCBARON = -955,
+
+ // these two are unknown
+ MI_RIO = -992,
+ MI_TROPIC = -988,
// HACK HACK, hopefully temporary
MI_FBIRANCH = -2000,
- MI_VICECHEE,
- MI_RIO,
MI_SQUALO,
MI_JETMAX,
MI_COASTG,
MI_DINGHY,
- MI_MARQUIS,
MI_SKIMMER,
- MI_TROPIC,
MI_CUBAN,
MI_PHEONIX,
MI_SABRE,
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 523d12db..7784bc07 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -83,6 +83,9 @@ CVehicle::CVehicle(uint8 CreatedBy)
m_fGasPedal = 0.0f;
m_fBrakePedal = 0.0f;
m_fWheelSpin = 0.0f;
+#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 535d6536..fa2f988c 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;