summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2019-10-08 22:57:21 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2019-10-08 22:57:21 +0200
commit4b4e5abffdebec7c3e8160c31fce72fc67dc6cef (patch)
tree009e58ace09e3bf1a1120b2965bbfe43c2ed2422 /src/control
parentmerge (diff)
downloadre3-4b4e5abffdebec7c3e8160c31fce72fc67dc6cef.tar
re3-4b4e5abffdebec7c3e8160c31fce72fc67dc6cef.tar.gz
re3-4b4e5abffdebec7c3e8160c31fce72fc67dc6cef.tar.bz2
re3-4b4e5abffdebec7c3e8160c31fce72fc67dc6cef.tar.lz
re3-4b4e5abffdebec7c3e8160c31fce72fc67dc6cef.tar.xz
re3-4b4e5abffdebec7c3e8160c31fce72fc67dc6cef.tar.zst
re3-4b4e5abffdebec7c3e8160c31fce72fc67dc6cef.zip
Diffstat (limited to '')
-rw-r--r--src/control/CarAI.cpp101
1 files changed, 48 insertions, 53 deletions
diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp
index 1fc609f6..203ed782 100644
--- a/src/control/CarAI.cpp
+++ b/src/control/CarAI.cpp
@@ -28,6 +28,8 @@ float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle)
void CCarAI::UpdateCarAI(CVehicle* pVehicle)
{
+ //((void(*)(CVehicle*))(0x413E50))(pVehicle);
+ //return;
if (pVehicle->bIsLawEnforcer){
if (pVehicle->AutoPilot.m_nCarMission == MISSION_BLOCKCAR_FARAWAY ||
pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY ||
@@ -67,7 +69,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
case MISSION_RAMPLAYER_CLOSE:
if (FindSwitchDistanceFar(pVehicle) < (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
pVehicle->AutoPilot.m_bIgnorePathfinding) {
- if (FindPlayerVehicle()){
+ if (FindPlayerVehicle()) {
if (pVehicle->GetHasCollidedWith(FindPlayerVehicle())) {
if (pVehicle->AutoPilot.m_nTempAction != TEMPACT_TURNLEFT && pVehicle->AutoPilot.m_nTempAction != TEMPACT_TURNRIGHT) {
if (FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f) {
@@ -90,10 +92,10 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
else
pVehicle->m_nTimeBlocked = 0;
if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
- FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > 2500){
+ FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > 2500) {
if (pVehicle->bIsLawEnforcer &&
(pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
- (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f){
+ (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
TellOccupantsToLeaveCar(pVehicle);
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
@@ -101,24 +103,22 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->m_bSirenOrAlarm = false;
}
}
- else{
- if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), true)){
- pVehicle->AutoPilot.m_nCarMission = MISSION_RAMPLAYER_FARAWAY;
- pVehicle->m_bSirenOrAlarm = false;
- pVehicle->m_nCarHornTimer = 0;
- }
- }
- if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
- (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())){
- CCarCtrl::JoinCarWithRoadSystem(pVehicle);
- pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
- pVehicle->m_bSirenOrAlarm = false;
- if (CCullZones::NoPolice())
- pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
- }
- else if (pVehicle->bIsLawEnforcer)
- MellowOutChaseSpeed(pVehicle);
}
+ else if (!CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), true)){
+ pVehicle->AutoPilot.m_nCarMission = MISSION_RAMPLAYER_FARAWAY;
+ pVehicle->m_bSirenOrAlarm = false;
+ pVehicle->m_nCarHornTimer = 0;
+ }
+ if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
+ (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())){
+ CCarCtrl::JoinCarWithRoadSystem(pVehicle);
+ pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->m_bSirenOrAlarm = false;
+ if (CCullZones::NoPolice())
+ pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
+ }
+ else if (pVehicle->bIsLawEnforcer)
+ MellowOutChaseSpeed(pVehicle);
break;
case MISSION_BLOCKPLAYER_FARAWAY:
if (FindSwitchDistanceClose(pVehicle) > (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
@@ -139,46 +139,41 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
case MISSION_BLOCKPLAYER_CLOSE:
if (FindSwitchDistanceFar(pVehicle) < (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
pVehicle->AutoPilot.m_bIgnorePathfinding) {
- if (FindPlayerVehicle()) {
- if (FindPlayerVehicle() && FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f)
+ if (FindPlayerVehicle() && FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f)
#ifdef FIX_BUGS
- pVehicle->m_nTimeBlocked += CTimer::GetTimeStepInMilliseconds();
+ pVehicle->m_nTimeBlocked += CTimer::GetTimeStepInMilliseconds();
#else
- pVehicle->m_nTimeBlocked += 1000.0f / 60.0f * CTimer::GetTimeStep();
+ pVehicle->m_nTimeBlocked += 1000.0f / 60.0f * CTimer::GetTimeStep();
#endif
- else
- pVehicle->m_nTimeBlocked = 0;
- if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
- FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > 2500) {
- if (pVehicle->bIsLawEnforcer &&
- (pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
- (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
- TellOccupantsToLeaveCar(pVehicle);
- pVehicle->AutoPilot.m_nCruiseSpeed = 0;
- pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1)
- pVehicle->m_bSirenOrAlarm = false;
- }
- }
- else {
- if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), true)) {
- pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FARAWAY;
+ else
+ pVehicle->m_nTimeBlocked = 0;
+ if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
+ FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > 2500) {
+ if (pVehicle->bIsLawEnforcer &&
+ (pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
+ (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
+ TellOccupantsToLeaveCar(pVehicle);
+ pVehicle->AutoPilot.m_nCruiseSpeed = 0;
+ pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
+ if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1)
pVehicle->m_bSirenOrAlarm = false;
- pVehicle->m_nCarHornTimer = 0;
- }
}
- if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
- (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
- CCarCtrl::JoinCarWithRoadSystem(pVehicle);
- pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
- pVehicle->m_bSirenOrAlarm = false;
- if (CCullZones::NoPolice())
- pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
- }
- else if (pVehicle->bIsLawEnforcer)
- MellowOutChaseSpeed(pVehicle);
}
+ }else if (!CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), true)) {
+ pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FARAWAY;
+ pVehicle->m_bSirenOrAlarm = false;
+ pVehicle->m_nCarHornTimer = 0;
+ }
+ if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
+ (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
+ CCarCtrl::JoinCarWithRoadSystem(pVehicle);
+ pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->m_bSirenOrAlarm = false;
+ if (CCullZones::NoPolice())
+ pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
}
+ else if (pVehicle->bIsLawEnforcer)
+ MellowOutChaseSpeed(pVehicle);
break;
case MISSION_GOTOCOORDS:
if ((pVehicle->AutoPilot.m_vecDestinationCoors - pVehicle->GetPosition()).Magnitude2D() < DISTANCE_TO_SWITCH_DISTANCE_GOTO ||