mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-30 03:35:41 +00:00
lcs car ctrl 2
This commit is contained in:
parent
ed5a9d5dc1
commit
b9b9dabd75
4 changed files with 87 additions and 55 deletions
|
@ -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:
|
||||||
|
|
|
@ -746,12 +746,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)
|
||||||
{
|
{
|
||||||
|
@ -1603,7 +1597,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;
|
||||||
|
@ -1613,7 +1607,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));
|
||||||
|
@ -1622,16 +1616,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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1663,23 +1653,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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1735,23 +1721,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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2031,7 +2013,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;
|
||||||
|
@ -2041,7 +2023,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) {
|
||||||
|
@ -2459,6 +2441,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:
|
||||||
|
@ -2529,11 +2521,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,
|
||||||
|
@ -2542,6 +2542,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,
|
||||||
|
@ -2619,8 +2622,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
|
||||||
|
@ -2651,8 +2654,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();
|
||||||
|
@ -2740,7 +2743,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;
|
||||||
|
@ -2783,7 +2786,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);
|
||||||
|
@ -2880,8 +2883,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);
|
||||||
|
@ -2920,11 +2923,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)
|
||||||
|
@ -2958,8 +2961,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);
|
||||||
|
@ -3165,7 +3168,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++)
|
||||||
|
@ -3207,10 +3210,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);
|
||||||
|
@ -3229,7 +3234,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);
|
||||||
|
@ -3386,6 +3391,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)
|
||||||
|
@ -3395,3 +3411,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,8 +131,9 @@ 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&) { return true; }
|
static bool OkToCreateVehicleAtThisPosition(const CVector&);
|
||||||
static float GetATanOfXY(float x, float y) { float t = CGeneral::GetATanOfXY(x, y); if (t < 0.0f) t += TWOPI; return t; } // TODO(LCS): replace where required
|
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)
|
||||||
{
|
{
|
||||||
|
@ -141,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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
Loading…
Reference in a new issue