CCarAI + bugfixes
This commit is contained in:
parent
80a74d2e77
commit
803412f33b
@ -6,8 +6,10 @@
|
|||||||
#include "AutoPilot.h"
|
#include "AutoPilot.h"
|
||||||
#include "CarCtrl.h"
|
#include "CarCtrl.h"
|
||||||
#include "General.h"
|
#include "General.h"
|
||||||
|
#include "HandlingMgr.h"
|
||||||
#include "ModelIndices.h"
|
#include "ModelIndices.h"
|
||||||
#include "PlayerPed.h"
|
#include "PlayerPed.h"
|
||||||
|
#include "Pools.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "TrafficLights.h"
|
#include "TrafficLights.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
@ -67,7 +69,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MISSION_RAMPLAYER_CLOSE:
|
case MISSION_RAMPLAYER_CLOSE:
|
||||||
if (FindSwitchDistanceFar(pVehicle) < (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
if (FindSwitchDistanceFar(pVehicle) >= (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
||||||
pVehicle->AutoPilot.m_bIgnorePathfinding) {
|
pVehicle->AutoPilot.m_bIgnorePathfinding) {
|
||||||
if (FindPlayerVehicle()) {
|
if (FindPlayerVehicle()) {
|
||||||
if (pVehicle->GetHasCollidedWith(FindPlayerVehicle())) {
|
if (pVehicle->GetHasCollidedWith(FindPlayerVehicle())) {
|
||||||
@ -92,7 +94,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
else
|
else
|
||||||
pVehicle->m_nTimeBlocked = 0;
|
pVehicle->m_nTimeBlocked = 0;
|
||||||
if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
|
if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
|
||||||
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > 2500) {
|
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING) {
|
||||||
if (pVehicle->bIsLawEnforcer &&
|
if (pVehicle->bIsLawEnforcer &&
|
||||||
(pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
|
(pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
|
||||||
(FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
|
(FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
|
||||||
@ -137,7 +139,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MISSION_BLOCKPLAYER_CLOSE:
|
case MISSION_BLOCKPLAYER_CLOSE:
|
||||||
if (FindSwitchDistanceFar(pVehicle) < (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
if (FindSwitchDistanceFar(pVehicle) >= (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
||||||
pVehicle->AutoPilot.m_bIgnorePathfinding) {
|
pVehicle->AutoPilot.m_bIgnorePathfinding) {
|
||||||
if (FindPlayerVehicle() && FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f)
|
if (FindPlayerVehicle() && FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f)
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
@ -148,7 +150,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
else
|
else
|
||||||
pVehicle->m_nTimeBlocked = 0;
|
pVehicle->m_nTimeBlocked = 0;
|
||||||
if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
|
if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
|
||||||
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > 2500) {
|
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING) {
|
||||||
if (pVehicle->bIsLawEnforcer &&
|
if (pVehicle->bIsLawEnforcer &&
|
||||||
(pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
|
(pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
|
||||||
(FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
|
(FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
|
||||||
@ -343,7 +345,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
}
|
}
|
||||||
float flatSpeed = pVehicle->GetMoveSpeed().MagnitudeSqr2D();
|
float flatSpeed = pVehicle->GetMoveSpeed().MagnitudeSqr2D();
|
||||||
if (flatSpeed > SQR(0.018f)){
|
if (flatSpeed > SQR(0.018f)){
|
||||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds();
|
pVehicle->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds();
|
||||||
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
|
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
|
||||||
}
|
}
|
||||||
if (pVehicle->m_status == STATUS_PHYSICS && pVehicle->AutoPilot.m_nTempAction == TEMPACT_NONE){
|
if (pVehicle->m_status == STATUS_PHYSICS && pVehicle->AutoPilot.m_nTempAction == TEMPACT_NONE){
|
||||||
@ -371,8 +373,8 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((pVehicle->m_randomSeed & 7) == 0){
|
if ((pVehicle->m_randomSeed & 7) == 0){
|
||||||
if (CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeTempAction > 30000 &&
|
if (CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeToStartMission > 30000 &&
|
||||||
CTimer::GetPreviousTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeTempAction <= 30000 &&
|
CTimer::GetPreviousTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeToStartMission <= 30000 &&
|
||||||
pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE &&
|
pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE &&
|
||||||
!CTrafficLights::ShouldCarStopForBridge(pVehicle)){
|
!CTrafficLights::ShouldCarStopForBridge(pVehicle)){
|
||||||
pVehicle->m_status = STATUS_PHYSICS;
|
pVehicle->m_status = STATUS_PHYSICS;
|
||||||
@ -392,7 +394,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
case MISSION_RAMPLAYER_CLOSE:
|
case MISSION_RAMPLAYER_CLOSE:
|
||||||
case MISSION_BLOCKPLAYER_FARAWAY:
|
case MISSION_BLOCKPLAYER_FARAWAY:
|
||||||
case MISSION_BLOCKPLAYER_CLOSE:
|
case MISSION_BLOCKPLAYER_CLOSE:
|
||||||
if (FindPlayerSpeed().Magnitude() > pVehicle->GetMoveSpeed().Magnitude()){
|
if (FindPlayerVehicle() && FindPlayerSpeed().Magnitude() > pVehicle->GetMoveSpeed().Magnitude()){
|
||||||
if (FindPlayerSpeed().Magnitude() > 0.1f){
|
if (FindPlayerSpeed().Magnitude() > 0.1f){
|
||||||
if (DotProduct2D(FindPlayerVehicle()->GetForward(), pVehicle->GetForward()) > 0.0f){
|
if (DotProduct2D(FindPlayerVehicle()->GetForward(), pVehicle->GetForward()) > 0.0f){
|
||||||
CVector2D dist = pVehicle->GetPosition() - FindPlayerCoors();
|
CVector2D dist = pVehicle->GetPosition() - FindPlayerCoors();
|
||||||
@ -428,17 +430,203 @@ void CCarAI::CarHasReasonToStop(CVehicle* pVehicle)
|
|||||||
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
|
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER float CCarAI::GetCarToGoToCoors(CVehicle*, CVector*) { EAXJMP(0x413E50); }
|
float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget)
|
||||||
WRAPPER void CCarAI::AddPoliceOccupants(CVehicle*) { EAXJMP(0x415C60); }
|
{
|
||||||
WRAPPER void CCarAI::AddAmbulanceOccupants(CVehicle*) { EAXJMP(0x415CE0); }
|
if (pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS && pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS_STRAIGHT){
|
||||||
WRAPPER void CCarAI::AddFiretruckOccupants(CVehicle*) { EAXJMP(0x415D00); }
|
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
|
||||||
WRAPPER void CCarAI::TellOccupantsToLeaveCar(CVehicle*) { EAXJMP(0x415D20); }
|
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
||||||
WRAPPER void CCarAI::TellCarToRamOtherCar(CVehicle*, CVehicle*) { EAXJMP(0x415D90); }
|
pVehicle->AutoPilot.m_nCruiseSpeed = 20;
|
||||||
WRAPPER void CCarAI::TellCarToBlockOtherCar(CVehicle*, CVehicle*) { EAXJMP(0x415DE0); }
|
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
|
||||||
WRAPPER eCarMission CCarAI::FindPoliceCarMissionForWantedLevel() { EAXJMP(0x415E30); }
|
pVehicle->m_status = STATUS_PHYSICS;
|
||||||
WRAPPER int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle*) { EAXJMP(0x415EB0); }
|
pVehicle->AutoPilot.m_nCarMission = (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, *pTarget, false)) ?
|
||||||
WRAPPER void CCarAI::MellowOutChaseSpeed(CVehicle*) { EAXJMP(0x416050); }
|
MISSION_GOTOCOORDS_STRAIGHT : MISSION_GOTOCOORDS;
|
||||||
WRAPPER void CCarAI::MakeWayForCarWithSiren(CVehicle *veh) { EAXJMP(0x416280); }
|
}else if (Abs(pTarget->x - pVehicle->AutoPilot.m_vecDestinationCoors.x) > 2.0f ||
|
||||||
|
Abs(pTarget->x - pVehicle->AutoPilot.m_vecDestinationCoors.x) > 2.0f){
|
||||||
|
pVehicle->AutoPilot.m_vecDestinationCoors = *pTarget;
|
||||||
|
}
|
||||||
|
return (pVehicle->GetPosition() - *pTarget).Magnitude2D();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::AddPoliceOccupants(CVehicle* pVehicle)
|
||||||
|
{
|
||||||
|
if (pVehicle->bOccupantsHaveBeenGenerated)
|
||||||
|
return;
|
||||||
|
switch (pVehicle->GetModelIndex()){
|
||||||
|
case MI_FBICAR:
|
||||||
|
case MI_ENFORCER:
|
||||||
|
pVehicle->SetUpDriver();
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
pVehicle->SetupPassenger(i);
|
||||||
|
return;
|
||||||
|
case MI_POLICE:
|
||||||
|
case MI_RHINO:
|
||||||
|
case MI_BARRACKS:
|
||||||
|
pVehicle->SetUpDriver();
|
||||||
|
if (FindPlayerPed()->m_pWanted->m_nWantedLevel > 1)
|
||||||
|
pVehicle->SetupPassenger(0);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::AddAmbulanceOccupants(CVehicle* pVehicle)
|
||||||
|
{
|
||||||
|
pVehicle->SetUpDriver();
|
||||||
|
pVehicle->SetupPassenger(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::AddFiretruckOccupants(CVehicle* pVehicle)
|
||||||
|
{
|
||||||
|
pVehicle->SetUpDriver();
|
||||||
|
pVehicle->SetupPassenger(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle)
|
||||||
|
{
|
||||||
|
if (pVehicle->pDriver){
|
||||||
|
pVehicle->pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle);
|
||||||
|
if (pVehicle->GetModelIndex())
|
||||||
|
pVehicle->pDriver->Say(SOUND_PED_LEAVE_VEHICLE);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++){
|
||||||
|
if (pVehicle->pPassengers[i])
|
||||||
|
pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::TellCarToRamOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
|
||||||
|
{
|
||||||
|
pVehicle->AutoPilot.m_pTargetCar = pTarget;
|
||||||
|
pTarget->RegisterReference((CEntity**)&pVehicle->AutoPilot.m_pTargetCar);
|
||||||
|
pVehicle->AutoPilot.m_nCarMission = MISSION_RAMCAR_FARAWAY;
|
||||||
|
pVehicle->bEngineOn = true;
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = min(6, pVehicle->AutoPilot.m_nCruiseSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
|
||||||
|
{
|
||||||
|
pVehicle->AutoPilot.m_pTargetCar = pTarget;
|
||||||
|
pTarget->RegisterReference((CEntity**)&pVehicle->AutoPilot.m_pTargetCar);
|
||||||
|
pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKCAR_FARAWAY;
|
||||||
|
pVehicle->bEngineOn = true;
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = min(6, pVehicle->AutoPilot.m_nCruiseSpeed);
|
||||||
|
}
|
||||||
|
eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
|
||||||
|
{
|
||||||
|
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){
|
||||||
|
case 0:
|
||||||
|
case 1: return MISSION_BLOCKPLAYER_FARAWAY;
|
||||||
|
case 2: return (CGeneral::GetRandomNumber() & 3) >= 3 ? MISSION_RAMPLAYER_FARAWAY : MISSION_BLOCKPLAYER_FARAWAY;
|
||||||
|
case 3: return (CGeneral::GetRandomNumber() & 3) >= 2 ? MISSION_RAMPLAYER_FARAWAY : MISSION_BLOCKPLAYER_FARAWAY;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6: return (CGeneral::GetRandomNumber() & 3) >= 1 ? MISSION_RAMPLAYER_FARAWAY : MISSION_BLOCKPLAYER_FARAWAY;
|
||||||
|
default: return MISSION_BLOCKPLAYER_FARAWAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle)
|
||||||
|
{
|
||||||
|
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
|
||||||
|
case 0: return CGeneral::GetRandomNumberInRange(12, 16);
|
||||||
|
case 1: return 25;
|
||||||
|
case 2: return 34;
|
||||||
|
case 3: return GAME_SPEED_TO_CARAI_SPEED * pVehicle->pHandling->Transmission.fMaxVelocity * 0.9f;
|
||||||
|
case 4: return GAME_SPEED_TO_CARAI_SPEED * pVehicle->pHandling->Transmission.fMaxVelocity * 1.2f;
|
||||||
|
case 5: return GAME_SPEED_TO_CARAI_SPEED * pVehicle->pHandling->Transmission.fMaxVelocity * 1.25f;
|
||||||
|
case 6: return GAME_SPEED_TO_CARAI_SPEED * pVehicle->pHandling->Transmission.fMaxVelocity * 1.3f;
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle)
|
||||||
|
{
|
||||||
|
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 1){
|
||||||
|
float distanceToPlayer = (pVehicle->GetPosition() - FindPlayerCoors()).Magnitude();
|
||||||
|
if (FindPlayerVehicle()){
|
||||||
|
if (distanceToPlayer < 10.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 15;
|
||||||
|
else if (distanceToPlayer < 20.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 22;
|
||||||
|
else
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 25;
|
||||||
|
}else{
|
||||||
|
if (distanceToPlayer < 20.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 5;
|
||||||
|
else if (distanceToPlayer < 40.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 13;
|
||||||
|
else
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 25;
|
||||||
|
}
|
||||||
|
}else if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 2){
|
||||||
|
float distanceToPlayer = (pVehicle->GetPosition() - FindPlayerCoors()).Magnitude();
|
||||||
|
if (FindPlayerVehicle()) {
|
||||||
|
if (distanceToPlayer < 10.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 27;
|
||||||
|
else if (distanceToPlayer < 20.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 30;
|
||||||
|
else
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 34;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (distanceToPlayer < 20.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 5;
|
||||||
|
else if (distanceToPlayer < 40.0f)
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 18;
|
||||||
|
else
|
||||||
|
pVehicle->AutoPilot.m_nCruiseSpeed = 34;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle)
|
||||||
|
{
|
||||||
|
float flatSpeed = pVehicle->GetMoveSpeed().Magnitude2D();
|
||||||
|
if (flatSpeed < 0.1f)
|
||||||
|
return;
|
||||||
|
CVector2D forward = pVehicle->GetMoveSpeed() / flatSpeed;
|
||||||
|
float projection = flatSpeed * 45 + 20;
|
||||||
|
int i = CPools::GetVehiclePool()->GetSize();
|
||||||
|
while (i--) {
|
||||||
|
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
|
if (!vehicle)
|
||||||
|
continue;
|
||||||
|
if (vehicle->m_vehType != VEHICLE_TYPE_CAR && vehicle->m_vehType != VEHICLE_TYPE_BIKE)
|
||||||
|
continue;
|
||||||
|
if (vehicle->m_status != STATUS_SIMPLE && vehicle->m_status != STATUS_PHYSICS)
|
||||||
|
continue;
|
||||||
|
if (vehicle->VehicleCreatedBy != RANDOM_VEHICLE)
|
||||||
|
continue;
|
||||||
|
if (vehicle->bIsLawEnforcer || vehicle->bIsAmbulanceOnDuty || vehicle->bIsFireTruckOnDuty)
|
||||||
|
continue;
|
||||||
|
if (vehicle == pVehicle)
|
||||||
|
continue;
|
||||||
|
if (Abs(pVehicle->GetPosition().z - vehicle->GetPosition().z) >= 5.0f)
|
||||||
|
continue;
|
||||||
|
CVector2D distance = vehicle->GetPosition() - pVehicle->GetPosition();
|
||||||
|
if (distance.Magnitude() >= projection)
|
||||||
|
continue;
|
||||||
|
if (vehicle->GetMoveSpeed().Magnitude2D() <= 0.05f)
|
||||||
|
continue;
|
||||||
|
float correlation = DotProduct2D(forward, distance) / distance.Magnitude();
|
||||||
|
if (correlation <= 0.0f)
|
||||||
|
continue;
|
||||||
|
if (correlation > 0.8f && DotProduct2D(forward, vehicle->GetForward()) > 0.7f){
|
||||||
|
if (vehicle->AutoPilot.m_nTempAction != TEMPACT_SWERVELEFT && vehicle->AutoPilot.m_nTempAction != TEMPACT_SWERVERIGHT){
|
||||||
|
vehicle->AutoPilot.m_nTempAction = (distance.x * forward.y - distance.y * forward.x > 0.0f) ?
|
||||||
|
TEMPACT_SWERVELEFT : TEMPACT_SWERVERIGHT;
|
||||||
|
vehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2000;
|
||||||
|
}
|
||||||
|
vehicle->m_status = STATUS_PHYSICS;
|
||||||
|
}else{
|
||||||
|
if (DotProduct2D(vehicle->GetMoveSpeed(), distance) < 0.0f && vehicle->AutoPilot.m_nTempAction != TEMPACT_WAIT){
|
||||||
|
vehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
|
||||||
|
vehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
STARTPATCHES
|
STARTPATCHES
|
||||||
ENDPATCHES
|
ENDPATCHES
|
@ -31,9 +31,6 @@
|
|||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Zones.h"
|
#include "Zones.h"
|
||||||
|
|
||||||
#define GAME_SPEED_TO_METERS_PER_SECOND 50.0f
|
|
||||||
#define GAME_SPEED_TO_CARAI_SPEED 60.0f
|
|
||||||
|
|
||||||
#define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS 51.0f
|
#define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS 51.0f
|
||||||
#define DISTANCE_TO_SCAN_FOR_DANGER 11.0f
|
#define DISTANCE_TO_SCAN_FOR_DANGER 11.0f
|
||||||
#define SAFE_DISTANCE_TO_PED 3.0f
|
#define SAFE_DISTANCE_TO_PED 3.0f
|
||||||
@ -53,7 +50,6 @@
|
|||||||
|
|
||||||
#define ATTEMPTS_TO_FIND_NEXT_NODE 15
|
#define ATTEMPTS_TO_FIND_NEXT_NODE 15
|
||||||
|
|
||||||
#define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500
|
|
||||||
#define DISTANCE_TO_SWITCH_FROM_BLOCK_TO_STOP 5.0f
|
#define DISTANCE_TO_SWITCH_FROM_BLOCK_TO_STOP 5.0f
|
||||||
#define DISTANCE_TO_SWITCH_FROM_STOP_TO_BLOCK 10.0f
|
#define DISTANCE_TO_SWITCH_FROM_STOP_TO_BLOCK 10.0f
|
||||||
#define MAX_SPEED_TO_ACCOUNT_IN_INTERCEPTING 0.13f
|
#define MAX_SPEED_TO_ACCOUNT_IN_INTERCEPTING 0.13f
|
||||||
@ -2407,8 +2403,8 @@ void CCarCtrl::SteerAICarWithPhysicsTryingToBlockTarget_Stop(CVehicle* pVehicle,
|
|||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
pVehicle->m_nTimeBlocked = 0;
|
pVehicle->m_nTimeBlocked = 0;
|
||||||
if ((FindPlayerVehicle() == nil || FindPlayerVehicle()->IsUpsideDown() ||
|
if (FindPlayerVehicle() == nil || FindPlayerVehicle()->IsUpsideDown() ||
|
||||||
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f) &&
|
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f &&
|
||||||
pVehicle->m_nTimeBlocked > TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING){
|
pVehicle->m_nTimeBlocked > TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING){
|
||||||
if (pVehicle->bIsLawEnforcer && distanceToTargetSqr < SQR(DISTANCE_TO_SWITCH_FROM_STOP_TO_BLOCK)){
|
if (pVehicle->bIsLawEnforcer && distanceToTargetSqr < SQR(DISTANCE_TO_SWITCH_FROM_STOP_TO_BLOCK)){
|
||||||
CCarAI::TellOccupantsToLeaveCar(pVehicle);
|
CCarAI::TellOccupantsToLeaveCar(pVehicle);
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
#include "Boat.h"
|
#include "Boat.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
|
|
||||||
|
#define GAME_SPEED_TO_METERS_PER_SECOND 50.0f
|
||||||
|
#define GAME_SPEED_TO_CARAI_SPEED 60.0f
|
||||||
|
#define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500
|
||||||
|
|
||||||
class CZoneInfo;
|
class CZoneInfo;
|
||||||
|
|
||||||
enum{
|
enum{
|
||||||
|
@ -2914,7 +2914,7 @@ CPed::QuitEnteringCar(void)
|
|||||||
|
|
||||||
if (veh) {
|
if (veh) {
|
||||||
if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_nPedState == PED_CARJACK)
|
if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_nPedState == PED_CARJACK)
|
||||||
veh->m_veh_flagC10 = false;
|
veh->bIsBeingCarJacked = false;
|
||||||
|
|
||||||
if (veh->m_nNumGettingIn != 0)
|
if (veh->m_nNumGettingIn != 0)
|
||||||
veh->m_nNumGettingIn--;
|
veh->m_nNumGettingIn--;
|
||||||
@ -10517,7 +10517,7 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
|
|||||||
|| !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) {
|
|| !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) {
|
||||||
|
|
||||||
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
|
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
|
||||||
veh->m_veh_flagC10 = false;
|
veh->bIsBeingCarJacked = false;
|
||||||
|
|
||||||
ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER;
|
ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER;
|
||||||
PedSetInCarCB(nil, ped);
|
PedSetInCarCB(nil, ped);
|
||||||
@ -10881,7 +10881,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
|
|||||||
veh->m_status = STATUS_PLAYER_DISABLED;
|
veh->m_status = STATUS_PLAYER_DISABLED;
|
||||||
}
|
}
|
||||||
driver->bBusJacked = true;
|
driver->bBusJacked = true;
|
||||||
veh->m_veh_flagC10 = false;
|
veh->bIsBeingCarJacked = false;
|
||||||
PedSetInCarCB(nil, ped);
|
PedSetInCarCB(nil, ped);
|
||||||
if (ped->m_nPedType == PEDTYPE_COP
|
if (ped->m_nPedType == PEDTYPE_COP
|
||||||
|| ped->m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT
|
|| ped->m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT
|
||||||
@ -11337,7 +11337,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
|
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
|
||||||
veh->m_veh_flagC10 = false;
|
veh->bIsBeingCarJacked = false;
|
||||||
|
|
||||||
if (veh->m_nNumGettingIn)
|
if (veh->m_nNumGettingIn)
|
||||||
--veh->m_nNumGettingIn;
|
--veh->m_nNumGettingIn;
|
||||||
@ -12996,7 +12996,7 @@ CPed::ProcessObjective(void)
|
|||||||
if (m_carInObjective->pDriver) {
|
if (m_carInObjective->pDriver) {
|
||||||
if (m_carInObjective->pDriver->m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS && m_carInObjective->pDriver != m_pedInObjective) {
|
if (m_carInObjective->pDriver->m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS && m_carInObjective->pDriver != m_pedInObjective) {
|
||||||
SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, m_carInObjective);
|
SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, m_carInObjective);
|
||||||
m_carInObjective->m_veh_flagC10 = false;
|
m_carInObjective->bIsBeingCarJacked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13004,7 +13004,7 @@ CPed::ProcessObjective(void)
|
|||||||
if (m_carInObjective->pDriver) {
|
if (m_carInObjective->pDriver) {
|
||||||
if (m_carInObjective->pDriver->m_nPedType == m_nPedType) {
|
if (m_carInObjective->pDriver->m_nPedType == m_nPedType) {
|
||||||
SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, m_carInObjective);
|
SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, m_carInObjective);
|
||||||
m_carInObjective->m_veh_flagC10 = false;
|
m_carInObjective->bIsBeingCarJacked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14575,7 +14575,7 @@ CPed::SetEnterCar(CVehicle *car, uint32 unused)
|
|||||||
}
|
}
|
||||||
if (!IsPedInControl() || m_fHealth <= 0.0f
|
if (!IsPedInControl() || m_fHealth <= 0.0f
|
||||||
|| doorFlag & car->m_nGettingInFlags || doorFlag & car->m_nGettingOutFlags
|
|| doorFlag & car->m_nGettingInFlags || doorFlag & car->m_nGettingOutFlags
|
||||||
|| car->m_veh_flagC10 || m_pVehicleAnim
|
|| car->bIsBeingCarJacked || m_pVehicleAnim
|
||||||
|| doorFlag && !car->IsDoorReady(door) && !car->IsDoorFullyOpen(door))
|
|| doorFlag && !car->IsDoorReady(door) && !car->IsDoorFullyOpen(door))
|
||||||
SetMoveState(PEDMOVE_STILL);
|
SetMoveState(PEDMOVE_STILL);
|
||||||
else
|
else
|
||||||
|
@ -68,15 +68,15 @@ CVehicle::CVehicle(uint8 CreatedBy)
|
|||||||
bTakeLessDamage = false;
|
bTakeLessDamage = false;
|
||||||
bIsDamaged = false;
|
bIsDamaged = false;
|
||||||
bFadeOut = false;
|
bFadeOut = false;
|
||||||
m_veh_flagC10 = false;
|
bIsBeingCarJacked = false;
|
||||||
m_nTimeOfDeath = 0;
|
m_nTimeOfDeath = 0;
|
||||||
m_pCarFire = nil;
|
m_pCarFire = nil;
|
||||||
bHasBeenOwnedByPlayer = false;
|
bHasBeenOwnedByPlayer = false;
|
||||||
bCreateRoadBlockPeds = false;
|
bCreateRoadBlockPeds = false;
|
||||||
bCanBeDamaged = true;
|
bCanBeDamaged = true;
|
||||||
bUsingSpecialColModel = false;
|
bUsingSpecialColModel = false;
|
||||||
m_veh_flagD1 = false;
|
bOccupantsHaveBeenGenerated = false;
|
||||||
m_veh_flagD2 = false;
|
bGunSwitchedOff = false;
|
||||||
m_nGunFiringTime = 0;
|
m_nGunFiringTime = 0;
|
||||||
m_nTimeBlocked = 0;
|
m_nTimeBlocked = 0;
|
||||||
bLightsOn = false;
|
bLightsOn = false;
|
||||||
|
@ -158,19 +158,16 @@ public:
|
|||||||
uint8 bIsDamaged : 1; // This vehicle has been damaged and is displaying all its components
|
uint8 bIsDamaged : 1; // This vehicle has been damaged and is displaying all its components
|
||||||
uint8 bHasBeenOwnedByPlayer : 1;// To work out whether stealing it is a crime
|
uint8 bHasBeenOwnedByPlayer : 1;// To work out whether stealing it is a crime
|
||||||
uint8 bFadeOut : 1; // Fade vehicle out
|
uint8 bFadeOut : 1; // Fade vehicle out
|
||||||
uint8 m_veh_flagC10 : 1;
|
uint8 bIsBeingCarJacked : 1; // Fade vehicle out
|
||||||
uint8 bCreateRoadBlockPeds : 1; // If this vehicle gets close enough we will create peds (coppers or gang members) round it
|
uint8 bCreateRoadBlockPeds : 1; // If this vehicle gets close enough we will create peds (coppers or gang members) round it
|
||||||
uint8 bCanBeDamaged : 1; // Set to FALSE during cut scenes to avoid explosions
|
uint8 bCanBeDamaged : 1; // Set to FALSE during cut scenes to avoid explosions
|
||||||
uint8 bUsingSpecialColModel : 1;// Is player vehicle using special collision model, stored in player strucure
|
uint8 bUsingSpecialColModel : 1;// Is player vehicle using special collision model, stored in player strucure
|
||||||
|
|
||||||
uint8 m_veh_flagD1 : 1;
|
uint8 bOccupantsHaveBeenGenerated : 1; // Is true if the occupants have already been generated. (Shouldn't happen again)
|
||||||
uint8 m_veh_flagD2 : 1;
|
uint8 bGunSwitchedOff : 1; // Level designers can use this to switch off guns on boats
|
||||||
uint8 bVehicleColProcessed : 1;// Has ProcessEntityCollision been processed for this car?
|
uint8 bVehicleColProcessed : 1;// Has ProcessEntityCollision been processed for this car?
|
||||||
uint8 bIsCarParkVehicle : 1; // Car has been created using the special CAR_PARK script command
|
uint8 bIsCarParkVehicle : 1; // Car has been created using the special CAR_PARK script command
|
||||||
uint8 bHasAlreadyBeenRecorded : 1; // Used for replays
|
uint8 bHasAlreadyBeenRecorded : 1; // Used for replays
|
||||||
uint8 m_veh_flagD20 : 1;
|
|
||||||
uint8 m_veh_flagD40 : 1;
|
|
||||||
uint8 m_veh_flagD80 : 1;
|
|
||||||
|
|
||||||
int8 m_numPedsUseItAsCover;
|
int8 m_numPedsUseItAsCover;
|
||||||
uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default)
|
uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default)
|
||||||
|
Loading…
Reference in New Issue
Block a user