mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-11-18 04:47:46 +00:00
Merge branch 'lcs-dev' into lcs
This commit is contained in:
commit
613d08d3e2
|
@ -33,6 +33,7 @@ public:
|
||||||
static void RequestCollision(const CVector2D &pos);
|
static void RequestCollision(const CVector2D &pos);
|
||||||
static void EnsureCollisionIsInMemory(const CVector2D &pos);
|
static void EnsureCollisionIsInMemory(const CVector2D &pos);
|
||||||
static bool HasCollisionLoaded(const CVector2D &pos);
|
static bool HasCollisionLoaded(const CVector2D &pos);
|
||||||
|
static bool HasCollisionLoaded(eLevelName level) { return true; }; // TODO
|
||||||
|
|
||||||
static ColDef *GetSlot(int slot) {
|
static ColDef *GetSlot(int slot) {
|
||||||
assert(slot >= 0);
|
assert(slot >= 0);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Accident.h"
|
#include "Accident.h"
|
||||||
#include "AutoPilot.h"
|
#include "AutoPilot.h"
|
||||||
|
#include "Bridge.h"
|
||||||
#include "CarCtrl.h"
|
#include "CarCtrl.h"
|
||||||
#include "General.h"
|
#include "General.h"
|
||||||
#include "HandlingMgr.h"
|
#include "HandlingMgr.h"
|
||||||
|
@ -74,6 +75,18 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||||
case STATUS_PLAYER_DISABLED:
|
case STATUS_PLAYER_DISABLED:
|
||||||
break;
|
break;
|
||||||
case STATUS_SIMPLE:
|
case STATUS_SIMPLE:
|
||||||
|
{
|
||||||
|
if (pVehicle->m_pCurGroundEntity && CBridge::ThisIsABridgeObjectMovingUp(pVehicle->m_pCurGroundEntity->GetModelIndex()))
|
||||||
|
pVehicle->SetStatus(STATUS_PHYSICS);
|
||||||
|
CColPoint colPoint;
|
||||||
|
CEntity* pEntity;
|
||||||
|
if ((pVehicle->m_randomSeed & 0x3F) == (CTimer::GetFrameCounter() & 0x3F) &&
|
||||||
|
!CWorld::ProcessVerticalLine(pVehicle->GetPosition(), -2.0f, colPoint, pEntity, true, false, false, false, true, false, nil)) {
|
||||||
|
debug("FLOATING CAR TURNED INTO PHYSICS CAR!\n");
|
||||||
|
pVehicle->SetStatus(STATUS_PHYSICS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// fallthough
|
||||||
case STATUS_PHYSICS:
|
case STATUS_PHYSICS:
|
||||||
switch (pVehicle->AutoPilot.m_nCarMission) {
|
switch (pVehicle->AutoPilot.m_nCarMission) {
|
||||||
case MISSION_RAMPLAYER_FARAWAY:
|
case MISSION_RAMPLAYER_FARAWAY:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "Cranes.h"
|
#include "Cranes.h"
|
||||||
#include "Curves.h"
|
#include "Curves.h"
|
||||||
#include "CutsceneMgr.h"
|
#include "CutsceneMgr.h"
|
||||||
|
#include "Frontend.h"
|
||||||
#include "Gangs.h"
|
#include "Gangs.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Garages.h"
|
#include "Garages.h"
|
||||||
|
@ -76,10 +77,11 @@
|
||||||
#define DISTANCE_BETWEEN_CAR_AND_DEAD_PED (6.0f)
|
#define DISTANCE_BETWEEN_CAR_AND_DEAD_PED (6.0f)
|
||||||
#define PROBABILITY_OF_PASSENGER_IN_VEHICLE (0.125f)
|
#define PROBABILITY_OF_PASSENGER_IN_VEHICLE (0.125f)
|
||||||
|
|
||||||
#define ONSCREEN_DESPAWN_RANGE (120.0f)
|
#define ONSCREEN_DESPAWN_RANGE (190.0f)
|
||||||
#define MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN (100.0f)
|
#define MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN (130.0f)
|
||||||
#define REQUEST_ONSCREEN_DISTANCE ((ONSCREEN_DESPAWN_RANGE + MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN) / 2)
|
#define REQUEST_ONSCREEN_DISTANCE (140.0f)
|
||||||
#define OFFSCREEN_DESPAWN_RANGE (40.0f)
|
#define OFFSCREEN_DESPAWN_RANGE (60.0f)
|
||||||
|
#define MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN (40.0f)
|
||||||
#define EXTENDED_RANGE_DESPAWN_MULTIPLIER (1.5f)
|
#define EXTENDED_RANGE_DESPAWN_MULTIPLIER (1.5f)
|
||||||
|
|
||||||
//--MIAMI: file done
|
//--MIAMI: file done
|
||||||
|
@ -95,7 +97,7 @@ int32 CCarCtrl::NumRandomCars;
|
||||||
int32 CCarCtrl::NumParkedCars;
|
int32 CCarCtrl::NumParkedCars;
|
||||||
int32 CCarCtrl::NumPermanentCars;
|
int32 CCarCtrl::NumPermanentCars;
|
||||||
int8 CCarCtrl::CountDownToCarsAtStart;
|
int8 CCarCtrl::CountDownToCarsAtStart;
|
||||||
int32 CCarCtrl::MaxNumberOfCarsInUse = 12;
|
int32 CCarCtrl::MaxNumberOfCarsInUse = 30;
|
||||||
uint32 CCarCtrl::LastTimeLawEnforcerCreated;
|
uint32 CCarCtrl::LastTimeLawEnforcerCreated;
|
||||||
uint32 CCarCtrl::LastTimeFireTruckCreated;
|
uint32 CCarCtrl::LastTimeFireTruckCreated;
|
||||||
uint32 CCarCtrl::LastTimeAmbulanceCreated;
|
uint32 CCarCtrl::LastTimeAmbulanceCreated;
|
||||||
|
@ -161,14 +163,19 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
carClass = COPS;
|
carClass = COPS;
|
||||||
carModel = ChoosePoliceCarModel();
|
carModel = ChoosePoliceCarModel();
|
||||||
}else{
|
}else{
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
carModel = ChooseModel(&zone, &carClass);
|
carModel = ChooseModel(&zone, &carClass);
|
||||||
if (carModel == -1 || (carClass == COPS && pWanted->m_nWantedLevel >= 1))
|
if (carModel == -1)
|
||||||
|
return;
|
||||||
|
if (!(carClass == COPS && pWanted->m_nWantedLevel >= 1))
|
||||||
/* All cop spawns with wanted level are handled by condition above. */
|
/* 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. */
|
/* In particular it means that cop cars never spawn if player has wanted level of 1. */
|
||||||
return;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
float frontX, frontY;
|
float frontX, frontY;
|
||||||
float preferredDistance, angleLimit;
|
float preferredDistance, angleLimit;
|
||||||
|
float requestMultiplier;
|
||||||
bool invertAngleLimitTest;
|
bool invertAngleLimitTest;
|
||||||
CVector spawnPosition;
|
CVector spawnPosition;
|
||||||
int32 curNodeId, nextNodeId;
|
int32 curNodeId, nextNodeId;
|
||||||
|
@ -188,11 +195,14 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
angleLimit = -1.0f;
|
angleLimit = -1.0f;
|
||||||
bTopDownCamera = true;
|
bTopDownCamera = true;
|
||||||
invertAngleLimitTest = true;
|
invertAngleLimitTest = true;
|
||||||
preferredDistance = OFFSCREEN_DESPAWN_RANGE + 15.0f;
|
preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN + 15.0f;
|
||||||
/* BUG: testForCollision not initialized in original game. */
|
/* BUG: testForCollision not initialized in original game. */
|
||||||
testForCollision = false;
|
testForCollision = false;
|
||||||
}else if (!pPlayerVehicle){
|
}else if (!pPlayerVehicle){
|
||||||
/* Player is not in vehicle. */
|
/* Player is not in vehicle. */
|
||||||
|
requestMultiplier = 13.0f / 20.0f;
|
||||||
|
if (FrontEndMenuManager.m_PrefsUseWideScreen) // TODO(LCS): static
|
||||||
|
requestMultiplier *= 4.0f / 3.0f;
|
||||||
testForCollision = true;
|
testForCollision = true;
|
||||||
frontX = TheCamera.CamFrontXNorm;
|
frontX = TheCamera.CamFrontXNorm;
|
||||||
frontY = TheCamera.CamFrontYNorm;
|
frontY = TheCamera.CamFrontYNorm;
|
||||||
|
@ -202,17 +212,24 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
/* Forward to his current direction (camera direction). */
|
/* Forward to his current direction (camera direction). */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = true;
|
invertAngleLimitTest = true;
|
||||||
preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier;
|
preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Spawn a vehicle close to player to his side. */
|
/* Spawn a vehicle close to player to his side. */
|
||||||
/* Kinda not within camera angle. */
|
/* Kinda not within camera angle. */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = false;
|
invertAngleLimitTest = false;
|
||||||
preferredDistance = OFFSCREEN_DESPAWN_RANGE;
|
preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if (fPlayerVehicleSpeed > 0.4f){ /* 72 km/h */
|
}
|
||||||
|
else {
|
||||||
|
requestMultiplier = 13.0f / 20.0f;
|
||||||
|
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON && !FrontEndMenuManager.m_PrefsUseWideScreen)
|
||||||
|
requestMultiplier *= 0.9f;
|
||||||
|
if (FrontEndMenuManager.m_PrefsUseWideScreen) // TODO(LCS): static
|
||||||
|
requestMultiplier *= 4.0f / 3.0f;
|
||||||
|
if (fPlayerVehicleSpeed > 0.4f) { /* 72 km/h */
|
||||||
/* Player is moving fast in vehicle */
|
/* Player is moving fast in vehicle */
|
||||||
/* Prefer spawning vehicles very far away from him. */
|
/* Prefer spawning vehicles very far away from him. */
|
||||||
frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed;
|
frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed;
|
||||||
|
@ -224,24 +241,25 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
/* Spawn a vehicle in a very narrow gap in front of a player */
|
/* Spawn a vehicle in a very narrow gap in front of a player */
|
||||||
angleLimit = 0.85f; /* approx 30 degrees */
|
angleLimit = 0.85f; /* approx 30 degrees */
|
||||||
invertAngleLimitTest = true;
|
invertAngleLimitTest = true;
|
||||||
preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier;
|
preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* Spawn a vehicle relatively far away from player. */
|
/* Spawn a vehicle relatively far away from player. */
|
||||||
/* Forward to his current direction (camera direction). */
|
/* Forward to his current direction (camera direction). */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = true;
|
invertAngleLimitTest = true;
|
||||||
preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier;
|
preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
/* Spawn a vehicle close to player to his side. */
|
/* Spawn a vehicle close to player to his side. */
|
||||||
/* Kinda not within camera angle. */
|
/* Kinda not within camera angle. */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = false;
|
invertAngleLimitTest = false;
|
||||||
preferredDistance = OFFSCREEN_DESPAWN_RANGE;
|
preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if (fPlayerVehicleSpeed > 0.1f){ /* 18 km/h */
|
}
|
||||||
|
else if (fPlayerVehicleSpeed > 0.1f) { /* 18 km/h */
|
||||||
/* Player is moving moderately fast in vehicle */
|
/* Player is moving moderately fast in vehicle */
|
||||||
/* Spawn more vehicles to player's side. */
|
/* Spawn more vehicles to player's side. */
|
||||||
frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed;
|
frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed;
|
||||||
|
@ -252,14 +270,14 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
/* Spawn a vehicle in a very narrow gap in front of a player */
|
/* Spawn a vehicle in a very narrow gap in front of a player */
|
||||||
angleLimit = 0.85f; /* approx 30 degrees */
|
angleLimit = 0.85f; /* approx 30 degrees */
|
||||||
invertAngleLimitTest = true;
|
invertAngleLimitTest = true;
|
||||||
preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier;
|
preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Spawn a vehicle relatively far away from player. */
|
/* Spawn a vehicle relatively far away from player. */
|
||||||
/* Forward to his current direction (camera direction). */
|
/* Forward to his current direction (camera direction). */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = true;
|
invertAngleLimitTest = true;
|
||||||
preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier;
|
preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -267,10 +285,11 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
/* Kinda not within camera angle. */
|
/* Kinda not within camera angle. */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = false;
|
invertAngleLimitTest = false;
|
||||||
preferredDistance = OFFSCREEN_DESPAWN_RANGE;
|
preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
/* Player is in vehicle but moving very slow. */
|
/* Player is in vehicle but moving very slow. */
|
||||||
/* Then use camera direction instead of vehicle direction. */
|
/* Then use camera direction instead of vehicle direction. */
|
||||||
testForCollision = true;
|
testForCollision = true;
|
||||||
|
@ -282,17 +301,18 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
/* Forward to his current direction (camera direction). */
|
/* Forward to his current direction (camera direction). */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = true;
|
invertAngleLimitTest = true;
|
||||||
preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier;
|
preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Spawn a vehicle close to player to his side. */
|
/* Spawn a vehicle close to player to his side. */
|
||||||
/* Kinda not within camera angle. */
|
/* Kinda not within camera angle. */
|
||||||
angleLimit = 0.707f; /* 45 degrees */
|
angleLimit = 0.707f; /* 45 degrees */
|
||||||
invertAngleLimitTest = false;
|
invertAngleLimitTest = false;
|
||||||
preferredDistance = OFFSCREEN_DESPAWN_RANGE;
|
preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!ThePaths.GenerateCarCreationCoors(vecTargetPos.x, vecTargetPos.y, frontX, frontY,
|
if (!ThePaths.GenerateCarCreationCoors(vecTargetPos.x, vecTargetPos.y, frontX, frontY,
|
||||||
preferredDistance, angleLimit, invertAngleLimitTest, &spawnPosition, &curNodeId, &nextNodeId,
|
preferredDistance, angleLimit, invertAngleLimitTest, &spawnPosition, &curNodeId, &nextNodeId,
|
||||||
&positionBetweenNodes, carClass == COPS && pWanted->m_nWantedLevel >= 1))
|
&positionBetweenNodes, carClass == COPS && pWanted->m_nWantedLevel >= 1))
|
||||||
|
@ -300,6 +320,8 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
CPathNode* pCurNode = &ThePaths.m_pathNodes[curNodeId];
|
CPathNode* pCurNode = &ThePaths.m_pathNodes[curNodeId];
|
||||||
CPathNode* pNextNode = &ThePaths.m_pathNodes[nextNodeId];
|
CPathNode* pNextNode = &ThePaths.m_pathNodes[nextNodeId];
|
||||||
bool bBoatGenerated = false;
|
bool bBoatGenerated = false;
|
||||||
|
if (!OkToCreateVehicleAtThisPosition(spawnPosition))
|
||||||
|
return;
|
||||||
if ((CGeneral::GetRandomNumber() & 0xF) > Min(pCurNode->spawnRate, pNextNode->spawnRate))
|
if ((CGeneral::GetRandomNumber() & 0xF) > Min(pCurNode->spawnRate, pNextNode->spawnRate))
|
||||||
return;
|
return;
|
||||||
if (pCurNode->bWaterPath) {
|
if (pCurNode->bWaterPath) {
|
||||||
|
@ -599,12 +621,12 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * (pVehicle->bExtendedRange ? EXTENDED_RANGE_DESPAWN_MULTIPLIER : 1.0f) * ONSCREEN_DESPAWN_RANGE ||
|
if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * requestMultiplier * (pVehicle->bExtendedRange ? EXTENDED_RANGE_DESPAWN_MULTIPLIER : 1.0f) * ONSCREEN_DESPAWN_RANGE ||
|
||||||
(vecTargetPos - pVehicle->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN) {
|
(vecTargetPos - pVehicle->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * requestMultiplier * MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN) {
|
||||||
delete pVehicle;
|
delete pVehicle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < 82.5f * TheCamera.GenerationDistMultiplier || bTopDownCamera) {
|
if ((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < 105.0f * requestMultiplier * TheCamera.GenerationDistMultiplier || bTopDownCamera) {
|
||||||
delete pVehicle;
|
delete pVehicle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -654,13 +676,13 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
int nMadDrivers;
|
int nMadDrivers;
|
||||||
switch (pVehicle->GetVehicleAppearance()) {
|
switch (pVehicle->GetVehicleAppearance()) {
|
||||||
case VEHICLE_APPEARANCE_BIKE:
|
case VEHICLE_APPEARANCE_BIKE:
|
||||||
nMadDrivers = 30;
|
nMadDrivers = 20;
|
||||||
break;
|
break;
|
||||||
case VEHICLE_APPEARANCE_BOAT:
|
case VEHICLE_APPEARANCE_BOAT:
|
||||||
nMadDrivers = 40;
|
nMadDrivers = 40;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
nMadDrivers = 6;
|
nMadDrivers = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((CGeneral::GetRandomNumber() & 0x7F) < nMadDrivers || bMadDriversCheat) {
|
if ((CGeneral::GetRandomNumber() & 0x7F) < nMadDrivers || bMadDriversCheat) {
|
||||||
|
@ -719,12 +741,6 @@ CCarCtrl::GenerateOneRandomCar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
CCarCtrl::BoatWithTallMast(int32 mi)
|
|
||||||
{
|
|
||||||
return mi == MI_RIO || mi == MI_TROPIC || mi == MI_MARQUIS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
CCarCtrl::ChooseBoatModel(int32 rating)
|
CCarCtrl::ChooseBoatModel(int32 rating)
|
||||||
{
|
{
|
||||||
|
@ -944,6 +960,7 @@ CCarCtrl::RemoveCarsIfThePoolGetsFull(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pClosestVehicle) {
|
if (pClosestVehicle) {
|
||||||
|
debug(":::::::::::\'Nearest removed\' cause pools was full -> NumRandomCars %d\n", NumRandomCars);
|
||||||
CWorld::Remove(pClosestVehicle);
|
CWorld::Remove(pClosestVehicle);
|
||||||
delete pClosestVehicle;
|
delete pClosestVehicle;
|
||||||
}
|
}
|
||||||
|
@ -966,7 +983,10 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float distanceToPlayer = (pVehicle->GetPosition() - vecPlayerPos).Magnitude2D();
|
float distanceToPlayer = (pVehicle->GetPosition() - vecPlayerPos).Magnitude2D();
|
||||||
float threshold = OFFSCREEN_DESPAWN_RANGE;
|
float despawnMultiplier = 1.0f;
|
||||||
|
if (FindPlayerVehicle() && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON && !FrontEndMenuManager.m_PrefsUseWideScreen)
|
||||||
|
despawnMultiplier = 0.75f;
|
||||||
|
float threshold = OFFSCREEN_DESPAWN_RANGE * despawnMultiplier;
|
||||||
if (pVehicle->GetIsOnScreen() ||
|
if (pVehicle->GetIsOnScreen() ||
|
||||||
TheCamera.Cams[TheCamera.ActiveCam].LookingLeft ||
|
TheCamera.Cams[TheCamera.ActiveCam].LookingLeft ||
|
||||||
TheCamera.Cams[TheCamera.ActiveCam].LookingRight ||
|
TheCamera.Cams[TheCamera.ActiveCam].LookingRight ||
|
||||||
|
@ -979,7 +999,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
|
||||||
pVehicle->bIsCarParkVehicle ||
|
pVehicle->bIsCarParkVehicle ||
|
||||||
CTimer::GetTimeInMilliseconds() < pVehicle->m_nSetPieceExtendedRangeTime
|
CTimer::GetTimeInMilliseconds() < pVehicle->m_nSetPieceExtendedRangeTime
|
||||||
){
|
){
|
||||||
threshold = ONSCREEN_DESPAWN_RANGE * TheCamera.GenerationDistMultiplier;
|
threshold = ONSCREEN_DESPAWN_RANGE * despawnMultiplier * TheCamera.GenerationDistMultiplier;
|
||||||
}
|
}
|
||||||
if (TheCamera.GetForward().z < -0.9f)
|
if (TheCamera.GetForward().z < -0.9f)
|
||||||
threshold = 70.0f;
|
threshold = 70.0f;
|
||||||
|
@ -1572,7 +1592,7 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float
|
||||||
if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMCAR_CLOSE && pOtherEntity == pVehicle->AutoPilot.m_pTargetCar)
|
if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMCAR_CLOSE && pOtherEntity == pVehicle->AutoPilot.m_pTargetCar)
|
||||||
return;
|
return;
|
||||||
CVector2D vecDiff = pOtherCar->GetPosition() - pVehicle->GetPosition();
|
CVector2D vecDiff = pOtherCar->GetPosition() - pVehicle->GetPosition();
|
||||||
float angleBetweenVehicles = CGeneral::GetATanOfXY(vecDiff.x, vecDiff.y);
|
float angleBetweenVehicles = GetATanOfXY(vecDiff.x, vecDiff.y);
|
||||||
float distance = vecDiff.Magnitude();
|
float distance = vecDiff.Magnitude();
|
||||||
if (distance < 1.0f)
|
if (distance < 1.0f)
|
||||||
return;
|
return;
|
||||||
|
@ -1582,7 +1602,7 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float
|
||||||
return;
|
return;
|
||||||
CVector2D forward = pVehicle->GetForward();
|
CVector2D forward = pVehicle->GetForward();
|
||||||
forward.Normalise();
|
forward.Normalise();
|
||||||
float forwardAngle = CGeneral::GetATanOfXY(forward.x, forward.y);
|
float forwardAngle = GetATanOfXY(forward.x, forward.y);
|
||||||
float angleDiff = angleBetweenVehicles - forwardAngle;
|
float angleDiff = angleBetweenVehicles - forwardAngle;
|
||||||
float lenProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.y * sin(angleDiff));
|
float lenProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.y * sin(angleDiff));
|
||||||
float widthProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.x * cos(angleDiff));
|
float widthProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.x * cos(angleDiff));
|
||||||
|
@ -1591,16 +1611,12 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float
|
||||||
diffToLeftAngle = ABS(diffToLeftAngle);
|
diffToLeftAngle = ABS(diffToLeftAngle);
|
||||||
float angleToWeave = lengthToEvade / 2;
|
float angleToWeave = lengthToEvade / 2;
|
||||||
if (diffToLeftAngle < angleToWeave){
|
if (diffToLeftAngle < angleToWeave){
|
||||||
*pAngleToWeaveLeft = angleBetweenVehicles - angleToWeave;
|
*pAngleToWeaveLeft = LimitRadianAngle(angleBetweenVehicles - angleToWeave);
|
||||||
while (*pAngleToWeaveLeft < -PI)
|
|
||||||
*pAngleToWeaveLeft += TWOPI;
|
|
||||||
}
|
}
|
||||||
float diffToRightAngle = LimitRadianAngle(angleBetweenVehicles - *pAngleToWeaveRight);
|
float diffToRightAngle = LimitRadianAngle(angleBetweenVehicles - *pAngleToWeaveRight);
|
||||||
diffToRightAngle = ABS(diffToRightAngle);
|
diffToRightAngle = ABS(diffToRightAngle);
|
||||||
if (diffToRightAngle < angleToWeave){
|
if (diffToRightAngle < angleToWeave){
|
||||||
*pAngleToWeaveRight = angleBetweenVehicles + angleToWeave;
|
*pAngleToWeaveRight = LimitRadianAngle(angleBetweenVehicles + angleToWeave);
|
||||||
while (*pAngleToWeaveRight > PI)
|
|
||||||
*pAngleToWeaveRight -= TWOPI;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1632,23 +1648,19 @@ void CCarCtrl::WeaveForPed(CEntity* pOtherEntity, CVehicle* pVehicle, float* pAn
|
||||||
return;
|
return;
|
||||||
CPed* pPed = (CPed*)pOtherEntity;
|
CPed* pPed = (CPed*)pOtherEntity;
|
||||||
CVector2D vecDiff = pPed->GetPosition() - pVehicle->GetPosition();
|
CVector2D vecDiff = pPed->GetPosition() - pVehicle->GetPosition();
|
||||||
float angleBetweenVehicleAndPed = CGeneral::GetATanOfXY(vecDiff.x, vecDiff.y);
|
float angleBetweenVehicleAndPed = GetATanOfXY(vecDiff.x, vecDiff.y);
|
||||||
float distance = vecDiff.Magnitude();
|
float distance = vecDiff.Magnitude();
|
||||||
float lengthToEvade = (WIDTH_COEF_TO_WEAVE_SAFELY * 2 * pVehicle->GetColModel()->boundingBox.max.x + PED_WIDTH_TO_WEAVE) / distance;
|
float lengthToEvade = (WIDTH_COEF_TO_WEAVE_SAFELY * 2 * pVehicle->GetColModel()->boundingBox.max.x + PED_WIDTH_TO_WEAVE) / distance;
|
||||||
float diffToLeftAngle = LimitRadianAngle(angleBetweenVehicleAndPed - *pAngleToWeaveLeft);
|
float diffToLeftAngle = LimitRadianAngle(angleBetweenVehicleAndPed - *pAngleToWeaveLeft);
|
||||||
diffToLeftAngle = ABS(diffToLeftAngle);
|
diffToLeftAngle = ABS(diffToLeftAngle);
|
||||||
float angleToWeave = lengthToEvade / 2;
|
float angleToWeave = lengthToEvade / 2;
|
||||||
if (diffToLeftAngle < angleToWeave) {
|
if (diffToLeftAngle < angleToWeave) {
|
||||||
*pAngleToWeaveLeft = angleBetweenVehicleAndPed - angleToWeave;
|
*pAngleToWeaveLeft = LimitRadianAngle(angleBetweenVehicleAndPed - angleToWeave);
|
||||||
while (*pAngleToWeaveLeft < -PI)
|
|
||||||
*pAngleToWeaveLeft += TWOPI;
|
|
||||||
}
|
}
|
||||||
float diffToRightAngle = LimitRadianAngle(angleBetweenVehicleAndPed - *pAngleToWeaveRight);
|
float diffToRightAngle = LimitRadianAngle(angleBetweenVehicleAndPed - *pAngleToWeaveRight);
|
||||||
diffToRightAngle = ABS(diffToRightAngle);
|
diffToRightAngle = ABS(diffToRightAngle);
|
||||||
if (diffToRightAngle < angleToWeave) {
|
if (diffToRightAngle < angleToWeave) {
|
||||||
*pAngleToWeaveRight = angleBetweenVehicleAndPed + angleToWeave;
|
*pAngleToWeaveRight = LimitRadianAngle(angleBetweenVehicleAndPed + angleToWeave);
|
||||||
while (*pAngleToWeaveRight > PI)
|
|
||||||
*pAngleToWeaveRight -= TWOPI;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1704,23 +1716,19 @@ void CCarCtrl::WeaveForObject(CEntity* pOtherEntity, CVehicle* pVehicle, float*
|
||||||
rightCoef * pObject->GetRight() +
|
rightCoef * pObject->GetRight() +
|
||||||
forwardCoef * pObject->GetForward() -
|
forwardCoef * pObject->GetForward() -
|
||||||
pVehicle->GetPosition();
|
pVehicle->GetPosition();
|
||||||
float angleBetweenVehicleAndObject = CGeneral::GetATanOfXY(vecDiff.x, vecDiff.y);
|
float angleBetweenVehicleAndObject = GetATanOfXY(vecDiff.x, vecDiff.y);
|
||||||
float distance = vecDiff.Magnitude();
|
float distance = vecDiff.Magnitude();
|
||||||
float lengthToEvade = (WIDTH_COEF_TO_WEAVE_SAFELY * 2 * pVehicle->GetColModel()->boundingBox.max.x + OBJECT_WIDTH_TO_WEAVE) / distance;
|
float lengthToEvade = (WIDTH_COEF_TO_WEAVE_SAFELY * 2 * pVehicle->GetColModel()->boundingBox.max.x + OBJECT_WIDTH_TO_WEAVE) / distance;
|
||||||
float diffToLeftAngle = LimitRadianAngle(angleBetweenVehicleAndObject - *pAngleToWeaveLeft);
|
float diffToLeftAngle = LimitRadianAngle(angleBetweenVehicleAndObject - *pAngleToWeaveLeft);
|
||||||
diffToLeftAngle = ABS(diffToLeftAngle);
|
diffToLeftAngle = ABS(diffToLeftAngle);
|
||||||
float angleToWeave = lengthToEvade / 2;
|
float angleToWeave = lengthToEvade / 2;
|
||||||
if (diffToLeftAngle < angleToWeave) {
|
if (diffToLeftAngle < angleToWeave) {
|
||||||
*pAngleToWeaveLeft = angleBetweenVehicleAndObject - angleToWeave;
|
*pAngleToWeaveLeft = LimitRadianAngle(angleBetweenVehicleAndObject - angleToWeave);
|
||||||
while (*pAngleToWeaveLeft < -PI)
|
|
||||||
*pAngleToWeaveLeft += TWOPI;
|
|
||||||
}
|
}
|
||||||
float diffToRightAngle = LimitRadianAngle(angleBetweenVehicleAndObject - *pAngleToWeaveRight);
|
float diffToRightAngle = LimitRadianAngle(angleBetweenVehicleAndObject - *pAngleToWeaveRight);
|
||||||
diffToRightAngle = ABS(diffToRightAngle);
|
diffToRightAngle = ABS(diffToRightAngle);
|
||||||
if (diffToRightAngle < angleToWeave) {
|
if (diffToRightAngle < angleToWeave) {
|
||||||
*pAngleToWeaveRight = angleBetweenVehicleAndObject + angleToWeave;
|
*pAngleToWeaveRight = LimitRadianAngle(angleBetweenVehicleAndObject + angleToWeave);
|
||||||
while (*pAngleToWeaveRight > PI)
|
|
||||||
*pAngleToWeaveRight -= TWOPI;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1762,7 +1770,7 @@ bool CCarCtrl::PickNextNodeAccordingStrategy(CVehicle* pVehicle)
|
||||||
void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
|
void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
|
||||||
{
|
{
|
||||||
if (pVehicle->m_nRouteSeed)
|
if (pVehicle->m_nRouteSeed)
|
||||||
CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed);
|
CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed++);
|
||||||
int32 prevNode = pVehicle->AutoPilot.m_nCurrentRouteNode;
|
int32 prevNode = pVehicle->AutoPilot.m_nCurrentRouteNode;
|
||||||
int32 curNode = pVehicle->AutoPilot.m_nNextRouteNode;
|
int32 curNode = pVehicle->AutoPilot.m_nNextRouteNode;
|
||||||
uint8 totalLinks = ThePaths.m_pathNodes[curNode].numLinks;
|
uint8 totalLinks = ThePaths.m_pathNodes[curNode].numLinks;
|
||||||
|
@ -1848,14 +1856,16 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
|
||||||
pNextPathNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode];
|
pNextPathNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode];
|
||||||
if ((!pNextPathNode->bDisabled || pPrevPathNode->bDisabled) &&
|
if ((!pNextPathNode->bDisabled || pPrevPathNode->bDisabled) &&
|
||||||
(!pNextPathNode->bBetweenLevels || pPrevPathNode->bBetweenLevels || !pVehicle->AutoPilot.m_bStayInCurrentLevel))
|
(!pNextPathNode->bBetweenLevels || pPrevPathNode->bBetweenLevels || !pVehicle->AutoPilot.m_bStayInCurrentLevel))
|
||||||
/* Nice way to exit loop but this will fail because this is used for indexing! */
|
break;
|
||||||
nextLink = 1000;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextLink < 999)
|
if (nextLink >= totalLinks) {
|
||||||
/* If everything else failed, turn vehicle around */
|
/* If everything else failed, turn vehicle around */
|
||||||
|
nextLink = 0;
|
||||||
|
debug("Couldn\'t find ANYTHING. Just go back from where we came.\n");
|
||||||
pVehicle->AutoPilot.m_nNextRouteNode = prevNode;
|
pVehicle->AutoPilot.m_nNextRouteNode = prevNode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pNextPathNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode];
|
pNextPathNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode];
|
||||||
pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurPathNode->firstLink]];
|
pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurPathNode->firstLink]];
|
||||||
if (prevNode == pVehicle->AutoPilot.m_nNextRouteNode){
|
if (prevNode == pVehicle->AutoPilot.m_nNextRouteNode){
|
||||||
|
@ -1967,7 +1977,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (pVehicle->m_nRouteSeed)
|
if (pVehicle->m_nRouteSeed)
|
||||||
CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed);
|
CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed++);
|
||||||
int prevNode = pVehicle->AutoPilot.m_nCurrentRouteNode;
|
int prevNode = pVehicle->AutoPilot.m_nCurrentRouteNode;
|
||||||
int curNode = pVehicle->AutoPilot.m_nNextRouteNode;
|
int curNode = pVehicle->AutoPilot.m_nNextRouteNode;
|
||||||
CPathNode* pPrevNode = &ThePaths.m_pathNodes[prevNode];
|
CPathNode* pPrevNode = &ThePaths.m_pathNodes[prevNode];
|
||||||
|
@ -1987,7 +1997,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
|
||||||
int nextLink;
|
int nextLink;
|
||||||
if (numNodes != 1 && numNodes != 2 || pTargetNode[0] == pCurNode){
|
if (numNodes != 1 && numNodes != 2 || pTargetNode[0] == pCurNode){
|
||||||
if (numNodes != 2 || pTargetNode[1] == pCurNode) {
|
if (numNodes != 2 || pTargetNode[1] == pCurNode) {
|
||||||
float currentAngle = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
float currentAngle = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
||||||
nextLink = 0;
|
nextLink = 0;
|
||||||
float lowestAngleChange = 10.0f;
|
float lowestAngleChange = 10.0f;
|
||||||
int numLinks = pCurNode->numLinks;
|
int numLinks = pCurNode->numLinks;
|
||||||
|
@ -1997,7 +2007,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
|
||||||
if (conNode == prevNode && i > 1)
|
if (conNode == prevNode && i > 1)
|
||||||
continue;
|
continue;
|
||||||
CPathNode* pTestNode = &ThePaths.m_pathNodes[conNode];
|
CPathNode* pTestNode = &ThePaths.m_pathNodes[conNode];
|
||||||
float angle = CGeneral::GetATanOfXY(pTestNode->GetX() - pCurNode->GetX(), pTestNode->GetY() - pCurNode->GetY());
|
float angle = GetATanOfXY(pTestNode->GetX() - pCurNode->GetX(), pTestNode->GetY() - pCurNode->GetY());
|
||||||
angle = LimitRadianAngle(angle - currentAngle);
|
angle = LimitRadianAngle(angle - currentAngle);
|
||||||
angle = ABS(angle);
|
angle = ABS(angle);
|
||||||
if (angle < lowestAngleChange) {
|
if (angle < lowestAngleChange) {
|
||||||
|
@ -2415,6 +2425,16 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe
|
||||||
*pHandbrake = true;
|
*pHandbrake = true;
|
||||||
return;
|
return;
|
||||||
case MISSION_CRUISE:
|
case MISSION_CRUISE:
|
||||||
|
if (CTrafficLights::ShouldCarStopForBridge(pVehicle)) {
|
||||||
|
*pAccel = 0.0f;
|
||||||
|
*pBrake = 1.0f;
|
||||||
|
*pHandbrake = true;
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
*pSwerve = 0.0f;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// fallthough
|
||||||
case MISSION_RAMPLAYER_FARAWAY:
|
case MISSION_RAMPLAYER_FARAWAY:
|
||||||
case MISSION_BLOCKPLAYER_FARAWAY:
|
case MISSION_BLOCKPLAYER_FARAWAY:
|
||||||
case MISSION_GOTOCOORDS:
|
case MISSION_GOTOCOORDS:
|
||||||
|
@ -2485,11 +2505,19 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe
|
||||||
*pHandbrake = false;
|
*pHandbrake = false;
|
||||||
return;
|
return;
|
||||||
case MISSION_RAMCAR_CLOSE:
|
case MISSION_RAMCAR_CLOSE:
|
||||||
|
if (!pVehicle->AutoPilot.m_pTargetCar) {
|
||||||
|
debug("NO TARGET VEHICLE FOR MISSION_RAMCAR_CLOSE\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
SteerAICarWithPhysicsHeadingForTarget(pVehicle, pVehicle->AutoPilot.m_pTargetCar,
|
SteerAICarWithPhysicsHeadingForTarget(pVehicle, pVehicle->AutoPilot.m_pTargetCar,
|
||||||
pVehicle->AutoPilot.m_pTargetCar->GetPosition().x, pVehicle->AutoPilot.m_pTargetCar->GetPosition().y,
|
pVehicle->AutoPilot.m_pTargetCar->GetPosition().x, pVehicle->AutoPilot.m_pTargetCar->GetPosition().y,
|
||||||
pSwerve, pAccel, pBrake, pHandbrake);
|
pSwerve, pAccel, pBrake, pHandbrake);
|
||||||
return;
|
return;
|
||||||
case MISSION_BLOCKCAR_CLOSE:
|
case MISSION_BLOCKCAR_CLOSE:
|
||||||
|
if (!pVehicle->AutoPilot.m_pTargetCar) {
|
||||||
|
debug("NO TARGET VEHICLE FOR MISSION_BLOCKCAR_CLOSE\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
SteerAICarWithPhysicsTryingToBlockTarget(pVehicle,
|
SteerAICarWithPhysicsTryingToBlockTarget(pVehicle,
|
||||||
pVehicle->AutoPilot.m_pTargetCar->GetPosition().x,
|
pVehicle->AutoPilot.m_pTargetCar->GetPosition().x,
|
||||||
pVehicle->AutoPilot.m_pTargetCar->GetPosition().y,
|
pVehicle->AutoPilot.m_pTargetCar->GetPosition().y,
|
||||||
|
@ -2498,6 +2526,9 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe
|
||||||
pSwerve, pAccel, pBrake, pHandbrake);
|
pSwerve, pAccel, pBrake, pHandbrake);
|
||||||
return;
|
return;
|
||||||
case MISSION_BLOCKCAR_HANDBRAKESTOP:
|
case MISSION_BLOCKCAR_HANDBRAKESTOP:
|
||||||
|
if (!pVehicle->AutoPilot.m_pTargetCar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
SteerAICarWithPhysicsTryingToBlockTarget_Stop(pVehicle,
|
SteerAICarWithPhysicsTryingToBlockTarget_Stop(pVehicle,
|
||||||
pVehicle->AutoPilot.m_pTargetCar->GetPosition().x,
|
pVehicle->AutoPilot.m_pTargetCar->GetPosition().x,
|
||||||
pVehicle->AutoPilot.m_pTargetCar->GetPosition().y,
|
pVehicle->AutoPilot.m_pTargetCar->GetPosition().y,
|
||||||
|
@ -2575,8 +2606,8 @@ void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CVehicle* pVehicle, float
|
||||||
{
|
{
|
||||||
CVector2D forward = pVehicle->GetForward();
|
CVector2D forward = pVehicle->GetForward();
|
||||||
forward.Normalise();
|
forward.Normalise();
|
||||||
float angleToTarget = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
float angleToTarget = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
||||||
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
|
float angleForward = GetATanOfXY(forward.x, forward.y);
|
||||||
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
||||||
steerAngle = clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE);
|
steerAngle = clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE);
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
|
@ -2607,8 +2638,8 @@ void CCarCtrl::SteerAIBoatWithPhysicsAttackingPlayer(CVehicle* pVehicle, float*
|
||||||
CVector2D forward = pVehicle->GetForward();
|
CVector2D forward = pVehicle->GetForward();
|
||||||
forward.Normalise();
|
forward.Normalise();
|
||||||
CVector2D vecToProjection = FindPlayerCoors() + FindPlayerSpeed() * projection * GAME_SPEED_TO_CARAI_SPEED;
|
CVector2D vecToProjection = FindPlayerCoors() + FindPlayerSpeed() * projection * GAME_SPEED_TO_CARAI_SPEED;
|
||||||
float angleToTarget = CGeneral::GetATanOfXY(vecToProjection.x - pVehicle->GetPosition().x, vecToProjection.y - pVehicle->GetPosition().y);
|
float angleToTarget = GetATanOfXY(vecToProjection.x - pVehicle->GetPosition().x, vecToProjection.y - pVehicle->GetPosition().y);
|
||||||
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
|
float angleForward = GetATanOfXY(forward.x, forward.y);
|
||||||
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
float speedTarget = pVehicle->AutoPilot.GetCruiseSpeed();
|
float speedTarget = pVehicle->AutoPilot.GetCruiseSpeed();
|
||||||
|
@ -2696,7 +2727,7 @@ void CCarCtrl::SteerAIHeliTowardsTargetCoors(CAutomobile* pHeli)
|
||||||
if (distanceToTarget < 8.0f && pHeli->m_fHeliOrientation < 0.0f)
|
if (distanceToTarget < 8.0f && pHeli->m_fHeliOrientation < 0.0f)
|
||||||
ZTurnSpeedTarget = 0.0f;
|
ZTurnSpeedTarget = 0.0f;
|
||||||
else {
|
else {
|
||||||
float fAngleTarget = CGeneral::GetATanOfXY(vecToTarget.x, vecToTarget.y) + PI;
|
float fAngleTarget = GetATanOfXY(vecToTarget.x, vecToTarget.y) + PI;
|
||||||
if (pHeli->m_fHeliOrientation >= 0.0f)
|
if (pHeli->m_fHeliOrientation >= 0.0f)
|
||||||
fAngleTarget = pHeli->m_fHeliOrientation;
|
fAngleTarget = pHeli->m_fHeliOrientation;
|
||||||
fAngleTarget -= pHeli->m_fOrientation;
|
fAngleTarget -= pHeli->m_fOrientation;
|
||||||
|
@ -2739,7 +2770,7 @@ void CCarCtrl::SteerAIPlaneTowardsTargetCoors(CAutomobile* pPlane)
|
||||||
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
|
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
|
||||||
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
|
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
|
||||||
fForwardZ = clamp(fForwardZ, -0.3f, 0.3f);
|
fForwardZ = clamp(fForwardZ, -0.3f, 0.3f);
|
||||||
float angle = CGeneral::GetATanOfXY(vecToTarget.x, vecToTarget.y);
|
float angle = GetATanOfXY(vecToTarget.x, vecToTarget.y);
|
||||||
while (angle > TWOPI)
|
while (angle > TWOPI)
|
||||||
angle -= TWOPI;
|
angle -= TWOPI;
|
||||||
float difference = LimitRadianAngle(angle - pPlane->m_fOrientation);
|
float difference = LimitRadianAngle(angle - pPlane->m_fOrientation);
|
||||||
|
@ -2836,8 +2867,8 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
|
||||||
projectedPosition.y = positionOnCurrentLinkIncludingLane.y;
|
projectedPosition.y = positionOnCurrentLinkIncludingLane.y;
|
||||||
}
|
}
|
||||||
CVector2D distanceToProjectedPosition = projectedPosition - pVehicle->GetPosition();
|
CVector2D distanceToProjectedPosition = projectedPosition - pVehicle->GetPosition();
|
||||||
float angleCurrentLink = CGeneral::GetATanOfXY(distanceToProjectedPosition.x, distanceToProjectedPosition.y);
|
float angleCurrentLink = GetATanOfXY(distanceToProjectedPosition.x, distanceToProjectedPosition.y);
|
||||||
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
|
float angleForward = GetATanOfXY(forward.x, forward.y);
|
||||||
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
|
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
|
||||||
angleCurrentLink = FindAngleToWeaveThroughTraffic(pVehicle, nil, angleCurrentLink, angleForward);
|
angleCurrentLink = FindAngleToWeaveThroughTraffic(pVehicle, nil, angleCurrentLink, angleForward);
|
||||||
float steerAngle = LimitRadianAngle(angleCurrentLink - angleForward);
|
float steerAngle = LimitRadianAngle(angleCurrentLink - angleForward);
|
||||||
|
@ -2882,11 +2913,11 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
|
||||||
pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x);
|
pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x);
|
||||||
trajectory -= pVehicle->GetPosition();
|
trajectory -= pVehicle->GetPosition();
|
||||||
float speedAngleMultiplier = FindSpeedMultiplier(
|
float speedAngleMultiplier = FindSpeedMultiplier(
|
||||||
CGeneral::GetATanOfXY(trajectory.x, trajectory.y) - angleForward,
|
GetATanOfXY(trajectory.x, trajectory.y) - angleForward,
|
||||||
MIN_ANGLE_FOR_SPEED_LIMITING, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
|
MIN_ANGLE_FOR_SPEED_LIMITING, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
|
||||||
float tmpWideMultiplier = FindSpeedMultiplier(
|
float tmpWideMultiplier = FindSpeedMultiplier(
|
||||||
CGeneral::GetATanOfXY(currentPathLinkForward.x, currentPathLinkForward.y) -
|
GetATanOfXY(currentPathLinkForward.x, currentPathLinkForward.y) -
|
||||||
CGeneral::GetATanOfXY(nextPathLinkForwardX, nextPathLinkForwardY),
|
GetATanOfXY(nextPathLinkForwardX, nextPathLinkForwardY),
|
||||||
MIN_ANGLE_FOR_SPEED_LIMITING_BETWEEN_NODES, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
|
MIN_ANGLE_FOR_SPEED_LIMITING_BETWEEN_NODES, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
|
||||||
float speedNodesMultiplier;
|
float speedNodesMultiplier;
|
||||||
if (scalarDistanceToNextNode > DISTANCE_TO_NEXT_NODE_TO_CONSIDER_SLOWING_DOWN || pVehicle->AutoPilot.m_nCruiseSpeed < 12)
|
if (scalarDistanceToNextNode > DISTANCE_TO_NEXT_NODE_TO_CONSIDER_SLOWING_DOWN || pVehicle->AutoPilot.m_nCruiseSpeed < 12)
|
||||||
|
@ -2920,8 +2951,8 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic
|
||||||
*pHandbrake = false;
|
*pHandbrake = false;
|
||||||
CVector2D forward = pVehicle->GetForward();
|
CVector2D forward = pVehicle->GetForward();
|
||||||
forward.Normalise();
|
forward.Normalise();
|
||||||
float angleToTarget = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
float angleToTarget = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
||||||
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
|
float angleForward = GetATanOfXY(forward.x, forward.y);
|
||||||
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
|
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
|
||||||
angleToTarget = FindAngleToWeaveThroughTraffic(pVehicle, pTarget, angleToTarget, angleForward);
|
angleToTarget = FindAngleToWeaveThroughTraffic(pVehicle, pTarget, angleToTarget, angleForward);
|
||||||
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
||||||
|
@ -3127,7 +3158,7 @@ bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle* pVehicle, CVector vecTar
|
||||||
void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
|
void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
|
||||||
{
|
{
|
||||||
if (pVehicle->m_nRouteSeed)
|
if (pVehicle->m_nRouteSeed)
|
||||||
CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed);
|
CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed++);
|
||||||
int nextLink;
|
int nextLink;
|
||||||
CPathNode* pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode];
|
CPathNode* pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode];
|
||||||
for (nextLink = 0; nextLink < 12; nextLink++)
|
for (nextLink = 0; nextLink < 12; nextLink++)
|
||||||
|
@ -3169,10 +3200,12 @@ void CCarCtrl::GenerateEmergencyServicesCar(void)
|
||||||
return;
|
return;
|
||||||
if (CGame::IsInInterior())
|
if (CGame::IsInInterior())
|
||||||
return;
|
return;
|
||||||
|
if (TheCamera.m_WideScreenOn) // TODO(LCS): verify
|
||||||
|
return;
|
||||||
if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars +
|
if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars +
|
||||||
NumLawEnforcerCars + NumRandomCars > MaxNumberOfCarsInUse)
|
NumLawEnforcerCars + NumRandomCars > MaxNumberOfCarsInUse)
|
||||||
return;
|
return;
|
||||||
if (NumAmbulancesOnDuty == 0){
|
if (NumAmbulancesOnDuty == 0 /* TODO(LCS): && gbEmergencyVehiclesEnabled */){
|
||||||
if (gAccidentManager.CountActiveAccidents() < 2){
|
if (gAccidentManager.CountActiveAccidents() < 2){
|
||||||
if (CStreaming::HasModelLoaded(MI_AMBULAN))
|
if (CStreaming::HasModelLoaded(MI_AMBULAN))
|
||||||
CStreaming::SetModelIsDeletable(MI_MEDIC);
|
CStreaming::SetModelIsDeletable(MI_MEDIC);
|
||||||
|
@ -3191,7 +3224,7 @@ void CCarCtrl::GenerateEmergencyServicesCar(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NumFiretrucksOnDuty == 0){
|
if (NumFiretrucksOnDuty == 0 /* TODO(LCS): && gbEmergencyVehiclesEnabled */){
|
||||||
if (gFireManager.GetTotalActiveFires() < 3){
|
if (gFireManager.GetTotalActiveFires() < 3){
|
||||||
if (CStreaming::HasModelLoaded(MI_FIRETRUCK))
|
if (CStreaming::HasModelLoaded(MI_FIRETRUCK))
|
||||||
CStreaming::SetModelIsDeletable(MI_FIREMAN);
|
CStreaming::SetModelIsDeletable(MI_FIREMAN);
|
||||||
|
@ -3348,6 +3381,17 @@ bool CCarCtrl::MapCouldMoveInThisArea(float x, float y)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CCarCtrl::BoatWithTallMast(int32 mi)
|
||||||
|
{
|
||||||
|
return mi == MI_RIO || mi == MI_TROPIC || mi == MI_MARQUIS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CCarCtrl::OkToCreateVehicleAtThisPosition(const CVector& pos)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type)
|
float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -3357,3 +3401,8 @@ float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type)
|
||||||
}
|
}
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCarCtrl::RenderDebugInfo(CVehicle*)
|
||||||
|
{
|
||||||
|
//TODO(LCS)
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "PathFind.h"
|
#include "PathFind.h"
|
||||||
#include "Boat.h"
|
#include "Boat.h"
|
||||||
|
#include "General.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
|
|
||||||
#define GAME_SPEED_TO_METERS_PER_SECOND 50.0f
|
#define GAME_SPEED_TO_METERS_PER_SECOND 50.0f
|
||||||
|
@ -130,6 +131,10 @@ public:
|
||||||
static void SteerAIBoatWithPhysicsAttackingPlayer(CVehicle*, float*, float*, float*, bool*);
|
static void SteerAIBoatWithPhysicsAttackingPlayer(CVehicle*, float*, float*, float*, bool*);
|
||||||
static void SteerAICarBlockingPlayerForwardAndBack(CVehicle*, float*, float*, float*, bool*);
|
static void SteerAICarBlockingPlayerForwardAndBack(CVehicle*, float*, float*, float*, bool*);
|
||||||
|
|
||||||
|
static bool OkToCreateVehicleAtThisPosition(const CVector&);
|
||||||
|
static void RenderDebugInfo(CVehicle*);
|
||||||
|
static float GetATanOfXY(float x, float y) { float t = CGeneral::GetATanOfXY(x, y); if (t < 0.0f) t += TWOPI; return t; }
|
||||||
|
|
||||||
static float GetPositionAlongCurrentCurve(CVehicle* pVehicle)
|
static float GetPositionAlongCurrentCurve(CVehicle* pVehicle)
|
||||||
{
|
{
|
||||||
uint32 timeInCurve = CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeEnteredCurve;
|
uint32 timeInCurve = CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeEnteredCurve;
|
||||||
|
@ -138,11 +143,7 @@ public:
|
||||||
|
|
||||||
static float LimitRadianAngle(float angle)
|
static float LimitRadianAngle(float angle)
|
||||||
{
|
{
|
||||||
while (angle < -PI)
|
return CGeneral::LimitRadianAngle(angle);
|
||||||
angle += TWOPI;
|
|
||||||
while (angle > PI)
|
|
||||||
angle -= TWOPI;
|
|
||||||
return angle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool bMadDriversCheat;
|
static bool bMadDriversCheat;
|
||||||
|
|
|
@ -100,6 +100,7 @@ bool CTheScripts::bPlayerIsInTheStatium;
|
||||||
int16 CTheScripts::CardStack[CARDS_IN_DECK * MAX_DECKS];
|
int16 CTheScripts::CardStack[CARDS_IN_DECK * MAX_DECKS];
|
||||||
int16 CTheScripts::CardStackPosition;
|
int16 CTheScripts::CardStackPosition;
|
||||||
#endif
|
#endif
|
||||||
|
int CTheScripts::AllowedCollision[MAX_ALLOWED_COLLISIONS];
|
||||||
|
|
||||||
#ifdef MISSION_REPLAY
|
#ifdef MISSION_REPLAY
|
||||||
|
|
||||||
|
@ -1659,11 +1660,13 @@ const uint32 CRunningScript::nSaveStructSize =
|
||||||
sizeof(CRunningScript);
|
sizeof(CRunningScript);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
CMissionCleanup::CMissionCleanup()
|
CMissionCleanup::CMissionCleanup()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CMissionCleanup::Init()
|
void CMissionCleanup::Init()
|
||||||
{
|
{
|
||||||
m_nCount = 0;
|
m_nCount = 0;
|
||||||
|
@ -1673,6 +1676,7 @@ void CMissionCleanup::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
cleanup_entity_struct* CMissionCleanup::FindFree()
|
cleanup_entity_struct* CMissionCleanup::FindFree()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_CLEANUP; i++){
|
for (int i = 0; i < MAX_CLEANUP; i++){
|
||||||
|
@ -1683,6 +1687,26 @@ cleanup_entity_struct* CMissionCleanup::FindFree()
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
|
void SleepThisPed(cleanup_entity_struct* pCleanup, CPed* pPed)
|
||||||
|
{
|
||||||
|
printf("*** SLEEPING PED %i %i\n", pCleanup->id, pPed->GetModelIndex());
|
||||||
|
if (!pPed->GetIsStatic())
|
||||||
|
pPed->RemoveFromMovingList();
|
||||||
|
pPed->bIsStaticWaitingForCollision = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
|
void WakeThisPed(cleanup_entity_struct* pCleanup, CPed* pPed)
|
||||||
|
{
|
||||||
|
printf("*** WAKING UP PED %i %i\n", pCleanup->id, pPed->GetModelIndex());
|
||||||
|
pPed->bIsStaticWaitingForCollision = false;
|
||||||
|
if (!pPed->bIsStatic)
|
||||||
|
pPed->AddToMovingList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CMissionCleanup::AddEntityToList(int32 id, uint8 type)
|
void CMissionCleanup::AddEntityToList(int32 id, uint8 type)
|
||||||
{
|
{
|
||||||
cleanup_entity_struct* pNew = FindFree();
|
cleanup_entity_struct* pNew = FindFree();
|
||||||
|
@ -1693,6 +1717,7 @@ void CMissionCleanup::AddEntityToList(int32 id, uint8 type)
|
||||||
m_nCount++;
|
m_nCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
|
void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_CLEANUP; i++){
|
for (int i = 0; i < MAX_CLEANUP; i++){
|
||||||
|
@ -1744,6 +1769,7 @@ void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects()
|
void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_CLEANUP; i++) {
|
for (int i = 0; i < MAX_CLEANUP; i++) {
|
||||||
|
@ -1752,50 +1778,105 @@ void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects()
|
||||||
{
|
{
|
||||||
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id);
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id);
|
||||||
if (pVehicle) {
|
if (pVehicle) {
|
||||||
if (pVehicle->bIsStaticWaitingForCollision) {
|
eLevelName level = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition());
|
||||||
if (CColStore::HasCollisionLoaded(pVehicle->GetPosition())) {
|
if (level == LEVEL_GENERIC)
|
||||||
pVehicle->bIsStaticWaitingForCollision = false;
|
level = CGame::currLevel;
|
||||||
|
if (!CColStore::HasCollisionLoaded(level)) {
|
||||||
|
if (!pVehicle->bIsStaticWaitingForCollision) {
|
||||||
|
if (!pVehicle->IsHeli() && !pVehicle->IsPlane() && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI &&
|
||||||
|
pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE) {
|
||||||
|
printf("*** SLEEPING VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex());
|
||||||
if (!pVehicle->GetIsStatic())
|
if (!pVehicle->GetIsStatic())
|
||||||
|
pVehicle->RemoveFromMovingList();
|
||||||
|
pVehicle->bIsStaticWaitingForCollision = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (pVehicle->bIsStaticWaitingForCollision) {
|
||||||
|
printf("*** WAKING UP VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex());
|
||||||
|
pVehicle->bIsStaticWaitingForCollision = false;
|
||||||
|
if (!pVehicle->bIsStatic)
|
||||||
pVehicle->AddToMovingList();
|
pVehicle->AddToMovingList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CLEANUP_CHAR:
|
|
||||||
{
|
|
||||||
CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id);
|
|
||||||
if (pPed) {
|
|
||||||
if (pPed->bIsStaticWaitingForCollision) {
|
|
||||||
if (CColStore::HasCollisionLoaded(pPed->GetPosition())) {
|
|
||||||
pPed->bIsStaticWaitingForCollision = false;
|
|
||||||
if (!pPed->GetIsStatic())
|
|
||||||
pPed->AddToMovingList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case CLEANUP_OBJECT:
|
case CLEANUP_OBJECT:
|
||||||
{
|
|
||||||
CObject* pObject = CPools::GetObjectPool()->GetAt(m_sEntities[i].id);
|
CObject* pObject = CPools::GetObjectPool()->GetAt(m_sEntities[i].id);
|
||||||
if (pObject) {
|
if (pObject) {
|
||||||
if (pObject->bIsStaticWaitingForCollision) {
|
eLevelName level = CTheZones::GetLevelFromPosition(&pObject->GetPosition());
|
||||||
if (CColStore::HasCollisionLoaded(pObject->GetPosition())) {
|
if (level == LEVEL_GENERIC)
|
||||||
pObject->bIsStaticWaitingForCollision = false;
|
level = CGame::currLevel;
|
||||||
|
if (!CColStore::HasCollisionLoaded(level)) {
|
||||||
|
if (!pObject->bIsStaticWaitingForCollision) {
|
||||||
if (!pObject->GetIsStatic())
|
if (!pObject->GetIsStatic())
|
||||||
|
pObject->RemoveFromMovingList();
|
||||||
|
pObject->bIsStaticWaitingForCollision = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (pObject->bIsStaticWaitingForCollision) {
|
||||||
|
pObject->bIsStaticWaitingForCollision = false;
|
||||||
|
if (!pObject->bIsStatic)
|
||||||
pObject->AddToMovingList();
|
pObject->AddToMovingList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
}
|
||||||
|
for (int i = 0; i < MAX_CLEANUP; i++) {
|
||||||
|
switch (m_sEntities[i].type) {
|
||||||
|
case CLEANUP_CHAR:
|
||||||
|
{
|
||||||
|
CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (pPed) {
|
||||||
|
eLevelName level = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
|
||||||
|
if (level == LEVEL_GENERIC)
|
||||||
|
level = CGame::currLevel;
|
||||||
|
if (!pPed->bIsStaticWaitingForCollision) {
|
||||||
|
if (pPed->bInVehicle) {
|
||||||
|
if (pPed->m_pMyVehicle->GetIsStatic()) {
|
||||||
|
SleepThisPed(&m_sEntities[i], pPed);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CColStore::HasCollisionLoaded(level)) {
|
||||||
|
if (pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() ||
|
||||||
|
pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())
|
||||||
|
SleepThisPed(&m_sEntities[i], pPed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!pPed->bInVehicle) {
|
||||||
|
if (CColStore::HasCollisionLoaded(level)) {
|
||||||
|
if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() ||
|
||||||
|
pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic()))
|
||||||
|
WakeThisPed(&m_sEntities[i], pPed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!pPed->m_pMyVehicle->GetIsStatic()) {
|
||||||
|
WakeThisPed(&m_sEntities[i], pPed);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (CColStore::HasCollisionLoaded(level)) {
|
||||||
|
if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() ||
|
||||||
|
pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic()))
|
||||||
|
WakeThisPed(&m_sEntities[i], pPed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS) except TODO
|
||||||
void CMissionCleanup::Process()
|
void CMissionCleanup::Process()
|
||||||
{
|
{
|
||||||
CPopulation::m_AllRandomPedsThisType = -1;
|
CPopulation::m_AllRandomPedsThisType = -1;
|
||||||
|
@ -1803,6 +1884,8 @@ void CMissionCleanup::Process()
|
||||||
CCarCtrl::CarDensityMultiplier = 1.0f;
|
CCarCtrl::CarDensityMultiplier = 1.0f;
|
||||||
CPed::nThreatReactionRangeMultiplier = 1;
|
CPed::nThreatReactionRangeMultiplier = 1;
|
||||||
CPed::nEnterCarRangeMultiplier = 1;
|
CPed::nEnterCarRangeMultiplier = 1;
|
||||||
|
for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++)
|
||||||
|
CTheScripts::AllowedCollision[i] = 0;
|
||||||
FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = 1.0f;
|
FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = 1.0f;
|
||||||
CRoadBlocks::ClearScriptRoadBlocks();
|
CRoadBlocks::ClearScriptRoadBlocks();
|
||||||
CRouteNode::Initialise();
|
CRouteNode::Initialise();
|
||||||
|
@ -1810,20 +1893,19 @@ void CMissionCleanup::Process()
|
||||||
TheCamera.Restore();
|
TheCamera.Restore();
|
||||||
TheCamera.SetWideScreenOff();
|
TheCamera.SetWideScreenOff();
|
||||||
CSpecialFX::bLiftCam = false;
|
CSpecialFX::bLiftCam = false;
|
||||||
CSpecialFX::bVideoCam = false;
|
// TODO(LCS): CHud::m_ClockEventWarningMinutes = 0;
|
||||||
CTimeCycle::StopExtraColour(0);
|
// TODO(LCS): CHud::m_ClockEventFlashTimer = 0;
|
||||||
|
CTimeCycle::StopExtraColour(0); // TODO: thiscall
|
||||||
for (int i = 0; i < MISSION_AUDIO_SLOTS; i++)
|
for (int i = 0; i < MISSION_AUDIO_SLOTS; i++)
|
||||||
DMAudio.ClearMissionAudio(i);
|
DMAudio.ClearMissionAudio(i);
|
||||||
CWeather::ReleaseWeather();
|
CWeather::ReleaseWeather();
|
||||||
for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++)
|
for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++)
|
||||||
CStreaming::SetMissionDoesntRequireSpecialChar(i);
|
CStreaming::SetMissionDoesntRequireSpecialChar(i);
|
||||||
for (int i = 0; i < NUM_OF_CUTSCENE_OBJECTS; i++)
|
|
||||||
CStreaming::SetMissionDoesntRequireModel(MI_CUTOBJ01 + i);
|
|
||||||
CStreaming::ms_disableStreaming = false;
|
CStreaming::ms_disableStreaming = false;
|
||||||
|
if (CHud::m_ItemToFlash != ITEM_ARMOUR && CHud::m_ItemToFlash != ITEM_HEALTH)
|
||||||
CHud::m_ItemToFlash = -1;
|
CHud::m_ItemToFlash = -1;
|
||||||
CHud::SetHelpMessage(nil, false);
|
CHud::SetHelpMessage(nil, false); // nil, false, false, true TODO(LCS)
|
||||||
CUserDisplay::OnscnTimer.m_bDisabled = false;
|
CUserDisplay::OnscnTimer.m_bDisabled = false;
|
||||||
CTheScripts::RemoveScriptTextureDictionary();
|
|
||||||
CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByCops = false;
|
CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByCops = false;
|
||||||
CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
|
CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
|
||||||
CWorld::Players[0].MakePlayerSafe(false);
|
CWorld::Players[0].MakePlayerSafe(false);
|
||||||
|
@ -1831,10 +1913,11 @@ void CMissionCleanup::Process()
|
||||||
CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0;
|
CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0;
|
||||||
CPad::GetPad(0)->SetDrunkInputDelay(0);
|
CPad::GetPad(0)->SetDrunkInputDelay(0);
|
||||||
CWorld::Players[0].m_bDriveByAllowed = true;
|
CWorld::Players[0].m_bDriveByAllowed = true;
|
||||||
|
CPad::GetPad(0)->unk_B4 = 1.0f;
|
||||||
|
CPad::GetPad(0)->unk_B8 = 0.5f;
|
||||||
DMAudio.ShutUpPlayerTalking(0);
|
DMAudio.ShutUpPlayerTalking(0);
|
||||||
CVehicle::bDisableRemoteDetonation = false;
|
CVehicle::bDisableRemoteDetonation = false;
|
||||||
CVehicle::bDisableRemoteDetonationOnContact = false;
|
CVehicle::bDisableRemoteDetonationOnContact = false;
|
||||||
CGameLogic::ClearShortCut();
|
|
||||||
CTheScripts::RiotIntensity = 0;
|
CTheScripts::RiotIntensity = 0;
|
||||||
CTheScripts::StoreVehicleIndex = -1;
|
CTheScripts::StoreVehicleIndex = -1;
|
||||||
CTheScripts::StoreVehicleWasRandom = true;
|
CTheScripts::StoreVehicleWasRandom = true;
|
||||||
|
@ -1872,12 +1955,17 @@ void CMissionCleanup::Process()
|
||||||
m_sEntities[i].type = CLEANUP_UNUSED;
|
m_sEntities[i].type = CLEANUP_UNUSED;
|
||||||
m_nCount--;
|
m_nCount--;
|
||||||
}
|
}
|
||||||
|
for (int i = 1; i < NUMSTREAMINFO; i++) {
|
||||||
|
if (CStreaming::IsScriptOwnedModel(i))
|
||||||
|
CStreaming::SetMissionDoesntRequireModel(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NB: CUpsideDownCarCheck is not used by actual script at all
|
/* NB: CUpsideDownCarCheck is not used by actual script at all
|
||||||
* It has a weird usage: AreAnyCarsUpsideDown would fail any mission
|
* It has a weird usage: AreAnyCarsUpsideDown would fail any mission
|
||||||
* just like death or arrest. */
|
* just like death or arrest. */
|
||||||
|
|
||||||
|
// done(LCS) except TODO
|
||||||
void CUpsideDownCarCheck::Init()
|
void CUpsideDownCarCheck::Init()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
||||||
|
@ -1886,12 +1974,14 @@ void CUpsideDownCarCheck::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id)
|
bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id)
|
||||||
{
|
{
|
||||||
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(id);
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(id);
|
||||||
return IsCarUpsideDown(pVehicle);
|
return IsCarUpsideDown(pVehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle)
|
bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle)
|
||||||
{
|
{
|
||||||
assert(pVehicle);
|
assert(pVehicle);
|
||||||
|
@ -1900,6 +1990,7 @@ bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle)
|
||||||
pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD;
|
pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CUpsideDownCarCheck::UpdateTimers()
|
void CUpsideDownCarCheck::UpdateTimers()
|
||||||
{
|
{
|
||||||
uint32 timeStep = CTimer::GetTimeStepInMilliseconds();
|
uint32 timeStep = CTimer::GetTimeStepInMilliseconds();
|
||||||
|
@ -1917,6 +2008,7 @@ void CUpsideDownCarCheck::UpdateTimers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
bool CUpsideDownCarCheck::AreAnyCarsUpsideDown()
|
bool CUpsideDownCarCheck::AreAnyCarsUpsideDown()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
||||||
|
@ -1926,6 +2018,7 @@ bool CUpsideDownCarCheck::AreAnyCarsUpsideDown()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CUpsideDownCarCheck::AddCarToCheck(int32 id)
|
void CUpsideDownCarCheck::AddCarToCheck(int32 id)
|
||||||
{
|
{
|
||||||
uint16 index = 0;
|
uint16 index = 0;
|
||||||
|
@ -1939,6 +2032,7 @@ void CUpsideDownCarCheck::AddCarToCheck(int32 id)
|
||||||
m_sCars[index].m_nUpsideDownTimer = 0;
|
m_sCars[index].m_nUpsideDownTimer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CUpsideDownCarCheck::RemoveCarFromCheck(int32 id)
|
void CUpsideDownCarCheck::RemoveCarFromCheck(int32 id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
||||||
|
@ -1949,6 +2043,7 @@ void CUpsideDownCarCheck::RemoveCarFromCheck(int32 id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
bool CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile(int32 id)
|
bool CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile(int32 id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
|
||||||
|
@ -1958,6 +2053,7 @@ bool CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile(int32 id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void stuck_car_data::Reset()
|
void stuck_car_data::Reset()
|
||||||
{
|
{
|
||||||
m_nVehicleIndex = -1;
|
m_nVehicleIndex = -1;
|
||||||
|
@ -1968,6 +2064,7 @@ void stuck_car_data::Reset()
|
||||||
m_bStuck = false;
|
m_bStuck = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CStuckCarCheck::Init()
|
void CStuckCarCheck::Init()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++) {
|
for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++) {
|
||||||
|
@ -1975,6 +2072,7 @@ void CStuckCarCheck::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CStuckCarCheck::Process()
|
void CStuckCarCheck::Process()
|
||||||
{
|
{
|
||||||
uint32 timer = CTimer::GetTimeInMilliseconds();
|
uint32 timer = CTimer::GetTimeInMilliseconds();
|
||||||
|
@ -1995,6 +2093,7 @@ void CStuckCarCheck::Process()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CStuckCarCheck::AddCarToCheck(int32 id, float radius, uint32 time)
|
void CStuckCarCheck::AddCarToCheck(int32 id, float radius, uint32 time)
|
||||||
{
|
{
|
||||||
CVehicle* pv = CPools::GetVehiclePool()->GetAt(id);
|
CVehicle* pv = CPools::GetVehiclePool()->GetAt(id);
|
||||||
|
@ -2015,6 +2114,7 @@ void CStuckCarCheck::AddCarToCheck(int32 id, float radius, uint32 time)
|
||||||
m_sCars[index].m_bStuck = false;
|
m_sCars[index].m_bStuck = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
void CStuckCarCheck::RemoveCarFromCheck(int32 id)
|
void CStuckCarCheck::RemoveCarFromCheck(int32 id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++){
|
for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++){
|
||||||
|
@ -2024,6 +2124,7 @@ void CStuckCarCheck::RemoveCarFromCheck(int32 id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// done(LCS)
|
||||||
bool CStuckCarCheck::HasCarBeenStuckForAWhile(int32 id)
|
bool CStuckCarCheck::HasCarBeenStuckForAWhile(int32 id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++){
|
for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++){
|
||||||
|
@ -2033,36 +2134,45 @@ bool CStuckCarCheck::HasCarBeenStuckForAWhile(int32 id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRunningScript::CollectParameters(uint32* pIp, int16 total)
|
void CRunningScript::CollectParameters(uint32* pIp, int16 total, int* pParameters)
|
||||||
{
|
{
|
||||||
for (int16 i = 0; i < total; i++){
|
while (total--){
|
||||||
uint16 varIndex;
|
uint16 varIndex;
|
||||||
switch (CTheScripts::Read1ByteFromScript(pIp))
|
switch (CTheScripts::Read1ByteFromScript(pIp))
|
||||||
{
|
{
|
||||||
|
case ARGUMENT_END:
|
||||||
|
return;
|
||||||
|
case ARGUMENT_INT_ZERO:
|
||||||
|
*pParameters = 0;
|
||||||
|
break;
|
||||||
|
case ARGUMENT_FLOAT_ZERO:
|
||||||
|
*pParameters = 0;
|
||||||
|
break;
|
||||||
|
case ARGUMENT_FLOAT_1BYTE:
|
||||||
|
*pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24;
|
||||||
|
break;
|
||||||
|
case ARGUMENT_FLOAT_2BYTES:
|
||||||
|
*pParameters = (uint32)(uint8)CTheScripts::Read2BytesFromScript(pIp) << 16;
|
||||||
|
break;
|
||||||
|
case ARGUMENT_FLOAT_3BYTES:
|
||||||
|
*pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 8;
|
||||||
|
*pParameters |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16;
|
||||||
|
break;
|
||||||
case ARGUMENT_INT32:
|
case ARGUMENT_INT32:
|
||||||
case ARGUMENT_FLOAT:
|
case ARGUMENT_FLOAT:
|
||||||
ScriptParams[i] = CTheScripts::Read4BytesFromScript(pIp);
|
*pParameters = CTheScripts::Read4BytesFromScript(pIp);
|
||||||
break;
|
|
||||||
case ARGUMENT_GLOBALVAR:
|
|
||||||
varIndex = CTheScripts::Read2BytesFromScript(pIp);
|
|
||||||
script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace());
|
|
||||||
ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[varIndex]);
|
|
||||||
break;
|
|
||||||
case ARGUMENT_LOCALVAR:
|
|
||||||
varIndex = CTheScripts::Read2BytesFromScript(pIp);
|
|
||||||
script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables));
|
|
||||||
ScriptParams[i] = m_anLocalVariables[varIndex];
|
|
||||||
break;
|
break;
|
||||||
case ARGUMENT_INT8:
|
case ARGUMENT_INT8:
|
||||||
ScriptParams[i] = CTheScripts::Read1ByteFromScript(pIp);
|
*pParameters = CTheScripts::Read1ByteFromScript(pIp);
|
||||||
break;
|
break;
|
||||||
case ARGUMENT_INT16:
|
case ARGUMENT_INT16:
|
||||||
ScriptParams[i] = CTheScripts::Read2BytesFromScript(pIp);
|
*pParameters = CTheScripts::Read2BytesFromScript(pIp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script_assert(0);
|
*pParameters = *GetPointerToScriptVariable(pIp, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pParameters++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2072,11 +2182,24 @@ int CRunningScript::CollectParameterForDebug(char* buf, bool& var)
|
||||||
uint16 varIndex;
|
uint16 varIndex;
|
||||||
char tmpstr[24];
|
char tmpstr[24];
|
||||||
var = false;
|
var = false;
|
||||||
|
int tmp;
|
||||||
switch (CTheScripts::Read1ByteFromScript(&m_nIp))
|
switch (CTheScripts::Read1ByteFromScript(&m_nIp))
|
||||||
{
|
{
|
||||||
case ARGUMENT_INT32:
|
case ARGUMENT_END:
|
||||||
case ARGUMENT_FLOAT:
|
return 0; // TODO(LCS)
|
||||||
return CTheScripts::Read4BytesFromScript(&m_nIp);
|
case ARGUMENT_INT_ZERO:
|
||||||
|
return 0;
|
||||||
|
case ARGUMENT_FLOAT_ZERO:
|
||||||
|
return 0;
|
||||||
|
case ARGUMENT_FLOAT_1BYTE:
|
||||||
|
return (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 24;
|
||||||
|
case ARGUMENT_FLOAT_2BYTES:
|
||||||
|
return (uint32)(uint8)CTheScripts::Read2BytesFromScript(&m_nIp) << 16;
|
||||||
|
case ARGUMENT_FLOAT_3BYTES:
|
||||||
|
tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 8;
|
||||||
|
tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16;
|
||||||
|
return tmp;
|
||||||
|
/*
|
||||||
case ARGUMENT_GLOBALVAR:
|
case ARGUMENT_GLOBALVAR:
|
||||||
varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
|
varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
|
||||||
script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace());
|
script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace());
|
||||||
|
@ -2091,13 +2214,19 @@ int CRunningScript::CollectParameterForDebug(char* buf, bool& var)
|
||||||
sprintf(tmpstr, " %d@", varIndex);
|
sprintf(tmpstr, " %d@", varIndex);
|
||||||
strcat(buf, tmpstr);
|
strcat(buf, tmpstr);
|
||||||
return m_anLocalVariables[varIndex];
|
return m_anLocalVariables[varIndex];
|
||||||
|
*/
|
||||||
|
case ARGUMENT_INT32:
|
||||||
|
case ARGUMENT_FLOAT:
|
||||||
|
return CTheScripts::Read4BytesFromScript(&m_nIp);
|
||||||
|
break;
|
||||||
case ARGUMENT_INT8:
|
case ARGUMENT_INT8:
|
||||||
return CTheScripts::Read1ByteFromScript(&m_nIp);
|
return CTheScripts::Read1ByteFromScript(&m_nIp);
|
||||||
|
break;
|
||||||
case ARGUMENT_INT16:
|
case ARGUMENT_INT16:
|
||||||
return CTheScripts::Read2BytesFromScript(&m_nIp);
|
return CTheScripts::Read2BytesFromScript(&m_nIp);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
PrintToLog("%s - script assertion failed in CollectParameterForDebug", buf);
|
// TODO(LCS): GetPointerToScriptVariableForDebug();
|
||||||
script_assert(0);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2108,6 +2237,7 @@ void CRunningScript::GetStoredParameterForDebug(char* buf)
|
||||||
uint16 varIndex;
|
uint16 varIndex;
|
||||||
char tmpstr[24];
|
char tmpstr[24];
|
||||||
switch (CTheScripts::Read1ByteFromScript(&m_nIp)) {
|
switch (CTheScripts::Read1ByteFromScript(&m_nIp)) {
|
||||||
|
/*
|
||||||
case ARGUMENT_GLOBALVAR:
|
case ARGUMENT_GLOBALVAR:
|
||||||
varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
|
varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
|
||||||
sprintf(tmpstr, " $%d", varIndex / 4);
|
sprintf(tmpstr, " $%d", varIndex / 4);
|
||||||
|
@ -2118,6 +2248,7 @@ void CRunningScript::GetStoredParameterForDebug(char* buf)
|
||||||
sprintf(tmpstr, " %d@", varIndex);
|
sprintf(tmpstr, " %d@", varIndex);
|
||||||
strcat(buf, tmpstr);
|
strcat(buf, tmpstr);
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
default:
|
default:
|
||||||
PrintToLog("%s - script_assertion failed in GetStoredParameterForDebug", buf);
|
PrintToLog("%s - script_assertion failed in GetStoredParameterForDebug", buf);
|
||||||
script_assert(0);
|
script_assert(0);
|
||||||
|
@ -2128,14 +2259,25 @@ void CRunningScript::GetStoredParameterForDebug(char* buf)
|
||||||
int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
|
int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
|
||||||
{
|
{
|
||||||
uint32* pIp = &ip;
|
uint32* pIp = &ip;
|
||||||
|
int tmp;
|
||||||
switch (CTheScripts::Read1ByteFromScript(pIp))
|
switch (CTheScripts::Read1ByteFromScript(pIp))
|
||||||
{
|
{
|
||||||
|
case ARGUMENT_END:
|
||||||
|
return 0; // TODO(LCS)
|
||||||
|
case ARGUMENT_INT_ZERO:
|
||||||
|
return 0;
|
||||||
|
case ARGUMENT_FLOAT_ZERO:
|
||||||
|
return 0;
|
||||||
|
case ARGUMENT_FLOAT_1BYTE:
|
||||||
|
return (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 24;
|
||||||
|
case ARGUMENT_FLOAT_2BYTES:
|
||||||
|
return (uint32)(uint8)CTheScripts::Read2BytesFromScript(&m_nIp) << 16;
|
||||||
|
case ARGUMENT_FLOAT_3BYTES:
|
||||||
|
tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 8;
|
||||||
|
tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16;
|
||||||
|
return tmp;
|
||||||
case ARGUMENT_INT32:
|
case ARGUMENT_INT32:
|
||||||
return CTheScripts::Read4BytesFromScript(pIp);
|
return CTheScripts::Read4BytesFromScript(pIp);
|
||||||
case ARGUMENT_GLOBALVAR:
|
|
||||||
return *((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]);
|
|
||||||
case ARGUMENT_LOCALVAR:
|
|
||||||
return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
|
|
||||||
case ARGUMENT_INT8:
|
case ARGUMENT_INT8:
|
||||||
return CTheScripts::Read1ByteFromScript(pIp);
|
return CTheScripts::Read1ByteFromScript(pIp);
|
||||||
case ARGUMENT_INT16:
|
case ARGUMENT_INT16:
|
||||||
|
@ -2143,7 +2285,7 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
|
||||||
case ARGUMENT_FLOAT:
|
case ARGUMENT_FLOAT:
|
||||||
return CTheScripts::Read4BytesFromScript(pIp);
|
return CTheScripts::Read4BytesFromScript(pIp);
|
||||||
default:
|
default:
|
||||||
script_assert(0);
|
return *GetPointerToScriptVariable(pIp, 0);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2151,33 +2293,17 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
|
||||||
void CRunningScript::StoreParameters(uint32* pIp, int16 number)
|
void CRunningScript::StoreParameters(uint32* pIp, int16 number)
|
||||||
{
|
{
|
||||||
for (int16 i = 0; i < number; i++){
|
for (int16 i = 0; i < number; i++){
|
||||||
switch (CTheScripts::Read1ByteFromScript(pIp)) {
|
*GetPointerToScriptVariable(pIp, 0) = ScriptParams[i];
|
||||||
case ARGUMENT_GLOBALVAR:
|
|
||||||
*(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i];
|
|
||||||
break;
|
|
||||||
case ARGUMENT_LOCALVAR:
|
|
||||||
m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
script_assert(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32* GetPointerToScriptVariable(CRunningScript* pScript, uint32* pIp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type)
|
int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type)
|
||||||
{
|
{
|
||||||
switch (CTheScripts::Read1ByteFromScript(pIp))
|
return ::GetPointerToScriptVariable(this, pIp);
|
||||||
{
|
|
||||||
case ARGUMENT_GLOBALVAR:
|
|
||||||
script_assert(type == VAR_GLOBAL);
|
|
||||||
return (int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)];
|
|
||||||
case ARGUMENT_LOCALVAR:
|
|
||||||
script_assert(type == VAR_LOCAL);
|
|
||||||
return &m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
|
|
||||||
default:
|
|
||||||
script_assert(0);
|
|
||||||
}
|
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRunningScript::Init()
|
void CRunningScript::Init()
|
||||||
|
|
|
@ -216,9 +216,12 @@ public:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARGUMENT_END = 0,
|
ARGUMENT_END = 0,
|
||||||
|
ARGUMENT_INT_ZERO,
|
||||||
|
ARGUMENT_FLOAT_ZERO,
|
||||||
|
ARGUMENT_FLOAT_1BYTE,
|
||||||
|
ARGUMENT_FLOAT_2BYTES,
|
||||||
|
ARGUMENT_FLOAT_3BYTES,
|
||||||
ARGUMENT_INT32,
|
ARGUMENT_INT32,
|
||||||
ARGUMENT_GLOBALVAR,
|
|
||||||
ARGUMENT_LOCALVAR,
|
|
||||||
ARGUMENT_INT8,
|
ARGUMENT_INT8,
|
||||||
ARGUMENT_INT16,
|
ARGUMENT_INT16,
|
||||||
ARGUMENT_FLOAT
|
ARGUMENT_FLOAT
|
||||||
|
@ -273,7 +276,8 @@ enum {
|
||||||
MAX_NUM_MISSION_SCRIPTS = 120,
|
MAX_NUM_MISSION_SCRIPTS = 120,
|
||||||
MAX_NUM_BUILDING_SWAPS = 25,
|
MAX_NUM_BUILDING_SWAPS = 25,
|
||||||
MAX_NUM_INVISIBILITY_SETTINGS = 20,
|
MAX_NUM_INVISIBILITY_SETTINGS = 20,
|
||||||
MAX_NUM_STORED_LINES = 1024
|
MAX_NUM_STORED_LINES = 1024,
|
||||||
|
MAX_ALLOWED_COLLISIONS = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
class CTheScripts
|
class CTheScripts
|
||||||
|
@ -324,6 +328,8 @@ public:
|
||||||
#define CARDS_IN_STACK (CARDS_IN_DECK * MAX_DECKS)
|
#define CARDS_IN_STACK (CARDS_IN_DECK * MAX_DECKS)
|
||||||
static int16 CardStack[CARDS_IN_STACK];
|
static int16 CardStack[CARDS_IN_STACK];
|
||||||
static int16 CardStackPosition;
|
static int16 CardStackPosition;
|
||||||
|
|
||||||
|
static int AllowedCollision[MAX_ALLOWED_COLLISIONS];
|
||||||
#endif
|
#endif
|
||||||
static bool bPlayerIsInTheStatium;
|
static bool bPlayerIsInTheStatium;
|
||||||
static uint8 RiotIntensity;
|
static uint8 RiotIntensity;
|
||||||
|
@ -448,6 +454,8 @@ enum {
|
||||||
NUM_TIMERS = 2
|
NUM_TIMERS = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern int ScriptParams[32];
|
||||||
|
|
||||||
class CRunningScript
|
class CRunningScript
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
|
@ -509,7 +517,7 @@ public:
|
||||||
|
|
||||||
static const uint32 nSaveStructSize;
|
static const uint32 nSaveStructSize;
|
||||||
|
|
||||||
void CollectParameters(uint32*, int16);
|
void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams);
|
||||||
int32 CollectNextParameterWithoutIncreasingPC(uint32);
|
int32 CollectNextParameterWithoutIncreasingPC(uint32);
|
||||||
int32* GetPointerToScriptVariable(uint32*, int16);
|
int32* GetPointerToScriptVariable(uint32*, int16);
|
||||||
void StoreParameters(uint32*, int16);
|
void StoreParameters(uint32*, int16);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// --MIAMI: file done
|
// --MIAMI: file done
|
||||||
|
|
||||||
float CIniFile::PedNumberMultiplier = 0.6f;
|
float CIniFile::PedNumberMultiplier = 0.6f;
|
||||||
float CIniFile::CarNumberMultiplier = 0.6f;
|
float CIniFile::CarNumberMultiplier = 0.8f;
|
||||||
|
|
||||||
void CIniFile::LoadIniFile()
|
void CIniFile::LoadIniFile()
|
||||||
{
|
{
|
||||||
|
@ -27,5 +27,5 @@ void CIniFile::LoadIniFile()
|
||||||
}
|
}
|
||||||
CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier;
|
CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier;
|
||||||
CPopulation::MaxNumberOfPedsInUseInterior = 40.0f * PedNumberMultiplier;
|
CPopulation::MaxNumberOfPedsInUseInterior = 40.0f * PedNumberMultiplier;
|
||||||
CCarCtrl::MaxNumberOfCarsInUse = 12.0f * CarNumberMultiplier;
|
CCarCtrl::MaxNumberOfCarsInUse = 30.0f * CarNumberMultiplier;
|
||||||
}
|
}
|
|
@ -164,6 +164,8 @@ public:
|
||||||
int32 LastTimeTouched;
|
int32 LastTimeTouched;
|
||||||
int32 AverageWeapon;
|
int32 AverageWeapon;
|
||||||
int32 AverageEntries;
|
int32 AverageEntries;
|
||||||
|
float unk_B4;
|
||||||
|
float unk_B8;
|
||||||
|
|
||||||
#ifdef DETECT_PAD_INPUT_SWITCH
|
#ifdef DETECT_PAD_INPUT_SWITCH
|
||||||
static bool IsAffectedByController;
|
static bool IsAffectedByController;
|
||||||
|
|
|
@ -123,6 +123,7 @@ public:
|
||||||
static bool HasColLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_COL); }
|
static bool HasColLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_COL); }
|
||||||
static bool HasAnimLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_ANIM); }
|
static bool HasAnimLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_ANIM); }
|
||||||
static bool CanRemoveModel(int32 id) { return (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0; }
|
static bool CanRemoveModel(int32 id) { return (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0; }
|
||||||
|
static bool IsScriptOwnedModel(int32 id) { return (ms_aInfoForModel[id].m_flags & STREAMFLAGS_SCRIPTOWNED); }
|
||||||
static bool CanRemoveTxd(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_TXD); }
|
static bool CanRemoveTxd(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_TXD); }
|
||||||
static bool CanRemoveCol(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_COL); }
|
static bool CanRemoveCol(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_COL); }
|
||||||
static bool CanRemoveAnim(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_ANIM); }
|
static bool CanRemoveAnim(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_ANIM); }
|
||||||
|
|
Loading…
Reference in a new issue