2019-05-18 12:39:39 +02:00
|
|
|
#pragma once
|
2019-08-11 19:11:54 +02:00
|
|
|
#include "PathFind.h"
|
2019-09-14 19:53:04 +02:00
|
|
|
#include "Boat.h"
|
2019-08-11 19:11:54 +02:00
|
|
|
#include "Vehicle.h"
|
2019-05-18 12:39:39 +02:00
|
|
|
|
2019-10-10 23:02:55 +02:00
|
|
|
#define GAME_SPEED_TO_METERS_PER_SECOND 50.0f
|
2020-01-03 17:48:13 +01:00
|
|
|
#define METERS_PER_SECOND_TO_GAME_SPEED (1.0f / GAME_SPEED_TO_METERS_PER_SECOND)
|
2019-10-10 23:02:55 +02:00
|
|
|
#define GAME_SPEED_TO_CARAI_SPEED 60.0f
|
|
|
|
#define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500
|
|
|
|
|
2019-08-06 23:32:19 +02:00
|
|
|
class CZoneInfo;
|
2020-05-17 19:36:48 +02:00
|
|
|
class CAutomobile;
|
2019-05-18 12:39:39 +02:00
|
|
|
|
2019-08-11 19:11:54 +02:00
|
|
|
enum{
|
|
|
|
MAX_CARS_TO_KEEP = 2,
|
2020-05-07 17:53:38 +02:00
|
|
|
MAX_CAR_MODELS_IN_ARRAY = 25,
|
2019-08-11 19:11:54 +02:00
|
|
|
};
|
|
|
|
|
2019-09-02 18:04:09 +02:00
|
|
|
#ifdef FIX_BUGS
|
|
|
|
#define FIX_PATHFIND_BUG
|
|
|
|
#endif
|
|
|
|
|
2019-05-18 12:39:39 +02:00
|
|
|
class CCarCtrl
|
|
|
|
{
|
2020-05-07 11:33:20 +02:00
|
|
|
public:
|
2019-08-06 23:32:19 +02:00
|
|
|
enum eCarClass {
|
2020-05-07 11:33:20 +02:00
|
|
|
NORMAL = 0,
|
|
|
|
POOR,
|
2019-08-06 23:32:19 +02:00
|
|
|
RICH,
|
|
|
|
EXEC,
|
|
|
|
WORKER,
|
|
|
|
BIG,
|
|
|
|
TAXI,
|
2020-05-07 11:33:20 +02:00
|
|
|
MOPED,
|
|
|
|
MOTORBIKE,
|
2020-05-07 17:53:38 +02:00
|
|
|
|
2020-05-07 11:33:20 +02:00
|
|
|
LEISUREBOAT,
|
|
|
|
WORKERBOAT,
|
2020-05-07 17:53:38 +02:00
|
|
|
|
2020-05-07 22:21:36 +02:00
|
|
|
COPS,
|
2020-05-16 16:00:40 +02:00
|
|
|
CUBAN,
|
|
|
|
HAITIAN,
|
|
|
|
STREET,
|
|
|
|
DIAZ,
|
|
|
|
BIKER,
|
|
|
|
SECURITY,
|
|
|
|
PLAYER,
|
|
|
|
GOLFERS,
|
2019-08-06 23:32:19 +02:00
|
|
|
GANG9,
|
2020-05-07 22:21:36 +02:00
|
|
|
COPS_BOAT,
|
|
|
|
FIRST_CAR_RATING = NORMAL,
|
|
|
|
FIRST_BOAT_RATING = LEISUREBOAT,
|
2020-05-16 16:00:40 +02:00
|
|
|
FIRST_GANG_CAR_RATING = CUBAN,
|
2020-05-07 22:21:36 +02:00
|
|
|
NUM_CAR_CLASSES = MOTORBIKE - FIRST_CAR_RATING + 1,
|
|
|
|
NUM_BOAT_CLASSES = WORKERBOAT - FIRST_BOAT_RATING + 1,
|
|
|
|
NUM_GANG_CAR_CLASSES = GANG9 - FIRST_GANG_CAR_RATING + 1,
|
|
|
|
TOTAL_CUSTOM_CLASSES = NUM_CAR_CLASSES + NUM_BOAT_CLASSES
|
2019-08-06 23:32:19 +02:00
|
|
|
};
|
2020-05-07 11:33:20 +02:00
|
|
|
|
2019-05-18 12:39:39 +02:00
|
|
|
static void SwitchVehicleToRealPhysics(CVehicle*);
|
2019-06-28 12:34:02 +02:00
|
|
|
static void AddToCarArray(int32 id, int32 vehclass);
|
2019-06-25 00:42:23 +02:00
|
|
|
static void UpdateCarCount(CVehicle*, bool);
|
2019-06-28 12:34:02 +02:00
|
|
|
static int32 ChooseCarModel(int32 vehclass);
|
2019-07-14 13:49:27 +02:00
|
|
|
static bool JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool);
|
|
|
|
static void JoinCarWithRoadSystem(CVehicle*);
|
2019-07-17 13:19:20 +02:00
|
|
|
static void UpdateCarOnRails(CVehicle*);
|
2019-07-17 23:58:06 +02:00
|
|
|
static bool MapCouldMoveInThisArea(float x, float y);
|
2019-07-18 15:41:09 +02:00
|
|
|
static void ScanForPedDanger(CVehicle *veh);
|
2019-07-25 22:34:29 +02:00
|
|
|
static void RemoveFromInterestingVehicleList(CVehicle*);
|
2019-08-06 23:32:19 +02:00
|
|
|
static void GenerateRandomCars(void);
|
2020-05-08 10:43:27 +02:00
|
|
|
static void GenerateOneRandomCar(void);
|
2019-08-06 23:32:19 +02:00
|
|
|
static void GenerateEmergencyServicesCar(void);
|
2020-11-14 12:21:56 +01:00
|
|
|
static int32 ChooseModel(CZoneInfo*, int*);
|
2019-08-06 23:32:19 +02:00
|
|
|
static int32 ChoosePoliceCarModel(void);
|
2019-08-10 09:44:19 +02:00
|
|
|
static int32 ChooseGangCarModel(int32 gang);
|
2019-08-11 19:11:54 +02:00
|
|
|
static void RemoveDistantCars(void);
|
|
|
|
static void PossiblyRemoveVehicle(CVehicle*);
|
|
|
|
static bool IsThisVehicleInteresting(CVehicle*);
|
2019-09-13 21:04:55 +02:00
|
|
|
static void RegisterVehicleOfInterest(CVehicle*);
|
2019-08-11 19:11:54 +02:00
|
|
|
static int32 CountCarsOfType(int32 mi);
|
|
|
|
static void SlowCarOnRailsDownForTrafficAndLights(CVehicle*);
|
2019-09-02 18:04:09 +02:00
|
|
|
static bool PickNextNodeAccordingStrategy(CVehicle*);
|
2019-08-11 19:11:54 +02:00
|
|
|
static void DragCarToPoint(CVehicle*, CVector*);
|
|
|
|
static float FindMaximumSpeedForThisCarInTraffic(CVehicle*);
|
|
|
|
static void SlowCarDownForCarsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float);
|
|
|
|
static void SlowCarDownForPedsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float);
|
2019-08-25 15:47:22 +02:00
|
|
|
static void SlowCarDownForOtherCar(CEntity*, CVehicle*, float*, float);
|
|
|
|
static float TestCollisionBetween2MovingRects(CVehicle*, CVehicle*, float, float, CVector*, CVector*, uint8);
|
2019-09-01 16:02:23 +02:00
|
|
|
static float FindAngleToWeaveThroughTraffic(CVehicle*, CPhysical*, float, float);
|
|
|
|
static void WeaveThroughCarsSectorList(CPtrList&, CVehicle*, CPhysical*, float, float, float, float, float*, float*);
|
|
|
|
static void WeaveForOtherCar(CEntity*, CVehicle*, float*, float*);
|
|
|
|
static void WeaveThroughPedsSectorList(CPtrList&, CVehicle*, CPhysical*, float, float, float, float, float*, float*);
|
|
|
|
static void WeaveForPed(CEntity*, CVehicle*, float*, float*);
|
|
|
|
static void WeaveThroughObjectsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float*);
|
|
|
|
static void WeaveForObject(CEntity*, CVehicle*, float*, float*);
|
2019-09-02 18:04:09 +02:00
|
|
|
#ifdef FIX_PATHFIND_BUG
|
|
|
|
static void PickNextNodeToChaseCar(CVehicle*, float, float, float, CVehicle*);
|
|
|
|
#else
|
|
|
|
static void PickNextNodeToChaseCar(CVehicle*, float, float, CVehicle*);
|
|
|
|
#endif
|
|
|
|
static bool PickNextNodeToFollowPath(CVehicle*);
|
|
|
|
static void PickNextNodeRandomly(CVehicle*);
|
|
|
|
static uint8 FindPathDirection(int32, int32, int32);
|
2019-09-12 12:11:13 +02:00
|
|
|
static void Init(void);
|
|
|
|
static void ReInit(void);
|
2019-09-14 19:53:04 +02:00
|
|
|
static float FindSpeedMultiplier(float, float, float, float);
|
|
|
|
static void SteerAICarWithPhysics(CVehicle*);
|
|
|
|
static void SteerAICarWithPhysics_OnlyMission(CVehicle*, float*, float*, float*, bool*);
|
|
|
|
static float FindMaxSteerAngle(CVehicle*);
|
|
|
|
static void SteerAICarWithPhysicsFollowPath(CVehicle*, float*, float*, float*, bool*);
|
|
|
|
static void SteerAICarWithPhysicsHeadingForTarget(CVehicle*, CPhysical*, float, float, float*, float*, float*, bool*);
|
|
|
|
static void SteerAICarWithPhysicsTryingToBlockTarget(CVehicle*, float, float, float, float, float*, float*, float*, bool*);
|
|
|
|
static void SteerAICarWithPhysicsTryingToBlockTarget_Stop(CVehicle*, float, float, float, float, float*, float*, float*, bool*);
|
2019-09-12 12:11:13 +02:00
|
|
|
static bool ThisRoadObjectCouldMove(int16);
|
2019-09-15 01:28:07 +02:00
|
|
|
static void ClearInterestingVehicleList();
|
|
|
|
static void FindLinksToGoWithTheseNodes(CVehicle*);
|
|
|
|
static bool GenerateOneEmergencyServicesCar(uint32, CVector);
|
2020-05-05 17:04:43 +02:00
|
|
|
static float FindSpeedMultiplierWithSpeedFromNodes(int8);
|
2020-05-07 22:21:36 +02:00
|
|
|
static int32 ChooseBoatModel(int32);
|
|
|
|
static int32 ChooseBoatRating(CZoneInfo* pZoneInfo);
|
|
|
|
static int32 ChooseCarRating(CZoneInfo* pZoneInfo);
|
2020-05-08 10:11:09 +02:00
|
|
|
static void AddToLoadedVehicleArray(int32 mi, int32 rating, int32 freq);
|
|
|
|
static void RemoveFromLoadedVehicleArray(int32 mi, int32 rating);
|
2020-05-08 22:29:43 +02:00
|
|
|
static int32 ChooseCarModelToLoad(int32 rating);
|
|
|
|
static bool BoatWithTallMast(int32 mi);
|
2020-05-09 19:21:13 +02:00
|
|
|
static void RemoveCarsIfThePoolGetsFull(void);
|
2020-05-10 11:25:30 +02:00
|
|
|
static void SteerAIBoatWithPhysicsHeadingForTarget(CVehicle*, float, float, float*, float*, float*);
|
|
|
|
static void SteerAIHeliTowardsTargetCoors(CAutomobile*);
|
|
|
|
static void SteerAIPlaneTowardsTargetCoors(CAutomobile*);
|
|
|
|
static void SteerAIBoatWithPhysicsAttackingPlayer(CVehicle*, float*, float*, float*, bool*);
|
|
|
|
static void SteerAICarBlockingPlayerForwardAndBack(CVehicle*, float*, float*, float*, bool*);
|
2019-08-11 19:11:54 +02:00
|
|
|
|
|
|
|
static float GetPositionAlongCurrentCurve(CVehicle* pVehicle)
|
|
|
|
{
|
|
|
|
uint32 timeInCurve = CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeEnteredCurve;
|
|
|
|
return (float)timeInCurve / pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve;
|
|
|
|
}
|
2019-06-24 16:57:54 +02:00
|
|
|
|
2019-09-01 16:02:23 +02:00
|
|
|
static float LimitRadianAngle(float angle)
|
|
|
|
{
|
|
|
|
while (angle < -PI)
|
|
|
|
angle += TWOPI;
|
|
|
|
while (angle > PI)
|
|
|
|
angle -= TWOPI;
|
|
|
|
return angle;
|
|
|
|
}
|
|
|
|
|
2020-08-16 17:39:11 +02:00
|
|
|
static bool bMadDriversCheat;
|
2020-04-17 07:54:14 +02:00
|
|
|
static int32 NumLawEnforcerCars;
|
|
|
|
static int32 NumAmbulancesOnDuty;
|
|
|
|
static int32 NumFiretrucksOnDuty;
|
|
|
|
static int32 NumRandomCars;
|
|
|
|
static int32 NumMissionCars;
|
|
|
|
static int32 NumParkedCars;
|
|
|
|
static int32 NumPermanentCars;
|
|
|
|
static bool bCarsGeneratedAroundCamera;
|
|
|
|
static float CarDensityMultiplier;
|
|
|
|
static int8 CountDownToCarsAtStart;
|
|
|
|
static int32 MaxNumberOfCarsInUse;
|
|
|
|
static uint32 LastTimeLawEnforcerCreated;
|
|
|
|
static uint32 LastTimeFireTruckCreated;
|
|
|
|
static uint32 LastTimeAmbulanceCreated;
|
|
|
|
static int32 TotalNumOfCarsOfRating[TOTAL_CUSTOM_CLASSES];
|
|
|
|
static int32 CarArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
|
2020-05-07 22:21:36 +02:00
|
|
|
|
2020-05-08 22:29:43 +02:00
|
|
|
static int32 MiamiViceCycle;
|
|
|
|
static uint32 LastTimeMiamiViceGenerated;
|
2020-05-07 22:21:36 +02:00
|
|
|
static int32 NumRequestsOfCarRating[TOTAL_CUSTOM_CLASSES];
|
2020-05-08 10:11:09 +02:00
|
|
|
static int32 NumOfLoadedCarsOfRating[TOTAL_CUSTOM_CLASSES];
|
|
|
|
static int32 CarFreqArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
|
|
|
|
static int32 LoadedCarsArray[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
|
2019-05-18 12:39:39 +02:00
|
|
|
};
|
2019-08-11 19:11:54 +02:00
|
|
|
|
2020-04-17 07:54:14 +02:00
|
|
|
extern CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP];
|