Merge pull request #535 from Nick007J/miami

garages, carctrl, script
This commit is contained in:
aap 2020-05-11 23:28:52 +02:00 committed by GitHub
commit ce2071e1e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 625 additions and 568 deletions

View File

@ -2593,6 +2593,50 @@ float CCarCtrl::FindMaxSteerAngle(CVehicle* pVehicle)
return pVehicle->GetModelIndex() == MI_ENFORCER ? 0.7f : DEFAULT_MAX_STEER_ANGLE; return pVehicle->GetModelIndex() == MI_ENFORCER ? 0.7f : DEFAULT_MAX_STEER_ANGLE;
} }
void CCarCtrl::SteerAIHeliTowardsTargetCoors(CAutomobile* pHeli)
{
if (pHeli->m_aWheelSpeed[1] < 0.22f)
pHeli->m_aWheelSpeed[1] += 0.001f;
if (pHeli->m_aWheelSpeed[1] < 0.22f)
return;
CVector2D vecToTarget = pHeli->AutoPilot.m_vecDestinationCoors - pHeli->GetPosition();
float distanceToTarget = vecToTarget.Magnitude();
#ifdef FIX_BUGS
float speed = pHeli->AutoPilot.GetCruiseSpeed() * 0.01f;
#else
float speed = pHeli->AutoPilot.m_nCruiseSpeed * 0.01f;
#endif
if (distanceToTarget >= 100.0f)
{
if (distanceToTarget > 75.0f)
speed *= 0.7f;
else if (distanceToTarget > 10.0f)
speed *= 0.4f;
else
speed *= 0.2f;
}
CVector2D vecAdvanceThisFrame = vecToTarget;
vecAdvanceThisFrame.Normalise();
vecAdvanceThisFrame *= speed;
float resistance = Pow(0.997f, CTimer::GetTimeStep());
pHeli->m_vecMoveSpeed.x *= resistance;
pHeli->m_vecMoveSpeed.y *= resistance;
vecAdvanceThisFrame -= pHeli->m_vecMoveSpeed;
CVector2D vecSpeedChange = vecAdvanceThisFrame - pHeli->m_vecMoveSpeed;
float vecSpeedChangeLength = vecSpeedChange.Magnitude();
vecSpeedChange.Normalise();
float changeMultiplier = 0.002f * CTimer::GetTimeStep();
if (distanceToTarget < 5.0f)
changeMultiplier /= 5.0f;
if (vecSpeedChangeLength < changeMultiplier)
pHeli->AddToMoveSpeed(vecAdvanceThisFrame);
else
pHeli->AddToMoveSpeed(vecSpeedChange * changeMultiplier);
pHeli->SetPosition(pHeli->GetPosition() + CVector(CTimer::GetTimeStep() * pHeli->m_vecMoveSpeed.x, CTimer::GetTimeStep() * pHeli->m_vecMoveSpeed.y, 0.0f));
assert(0);
// This is not finished yet. Heli fields in CAutomobile required
}
void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake) void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake)
{ {
CVector2D forward = pVehicle->GetForward(); CVector2D forward = pVehicle->GetForward();
@ -2620,18 +2664,12 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
if (PickNextNodeAccordingStrategy(pVehicle)) { if (PickNextNodeAccordingStrategy(pVehicle)) {
switch (pVehicle->AutoPilot.m_nCarMission){ switch (pVehicle->AutoPilot.m_nCarMission){
case MISSION_GOTOCOORDS: case MISSION_GOTOCOORDS:
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT; SteerAICarWithPhysicsHeadingForTarget(pVehicle, nil, pVehicle->AutoPilot.m_vecDestinationCoors.x,
*pSwerve = 0.0f; pVehicle->AutoPilot.m_vecDestinationCoors.y, pSwerve, pAccel, pBrake, pHandbrake);
*pAccel = 0.0f;
*pBrake = 0.0f;
*pHandbrake = false;
return; return;
case MISSION_GOTOCOORDS_ACCURATE: case MISSION_GOTOCOORDS_ACCURATE:
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTO_COORDS_STRAIGHT_ACCURATE; SteerAICarWithPhysicsHeadingForTarget(pVehicle, nil, pVehicle->AutoPilot.m_vecDestinationCoors.x,
*pSwerve = 0.0f; pVehicle->AutoPilot.m_vecDestinationCoors.y, pSwerve, pAccel, pBrake, pHandbrake);
*pAccel = 0.0f;
*pBrake = 0.0f;
*pHandbrake = false;
return; return;
} }
} }
@ -2667,6 +2705,7 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
switch (pVehicle->AutoPilot.m_nDrivingStyle) { switch (pVehicle->AutoPilot.m_nDrivingStyle) {
case DRIVINGSTYLE_STOP_FOR_CARS: case DRIVINGSTYLE_STOP_FOR_CARS:
case DRIVINGSTYLE_SLOW_DOWN_FOR_CARS: case DRIVINGSTYLE_SLOW_DOWN_FOR_CARS:
case DRIVINGSTYLE_STOP_FOR_CARS_IGNORE_LIGHTS:
speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle) / pVehicle->AutoPilot.m_nCruiseSpeed; speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle) / pVehicle->AutoPilot.m_nCruiseSpeed;
break; break;
default: default:
@ -2933,8 +2972,6 @@ bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle* pVehicle, CVector vecTar
return false; return false;
} }
//TODO
void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle) void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
{ {
if (pVehicle->m_nRouteSeed) if (pVehicle->m_nRouteSeed)
@ -2952,12 +2989,22 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
curLink = 0; curLink = 0;
curConnection = ThePaths.m_carPathConnections[pCurNode->firstLink]; curConnection = ThePaths.m_carPathConnections[pCurNode->firstLink];
}else{ }else{
curConnection = pVehicle->AutoPilot.m_nNextPathNodeInfo; int closestLink = -1;
while (curConnection == pVehicle->AutoPilot.m_nNextPathNodeInfo){ float md = 999999.9f;
curLink = CGeneral::GetRandomNumber() % pCurNode->numLinks;
curConnection = ThePaths.m_carPathConnections[curLink + pCurNode->firstLink]; for (curLink = 0; curLink < pCurNode->numLinks; curLink++) {
int node = ThePaths.ConnectedNode(curLink + pCurNode->firstLink);
CPathNode* pNode = &ThePaths.m_pathNodes[node];
if (node == pVehicle->AutoPilot.m_nNextRouteNode)
continue;
float dist = CCollision::DistToLine(&pCurNode->GetPosition(), &pNode->GetPosition(), &pVehicle->GetPosition());
if (dist < md) {
md = dist;
closestLink = curLink;
} }
} }
curConnection = ThePaths.m_carPathConnections[closestLink + pCurNode->firstLink];
}
pVehicle->AutoPilot.m_nCurrentPathNodeInfo = curConnection; pVehicle->AutoPilot.m_nCurrentPathNodeInfo = curConnection;
pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(curLink + pCurNode->firstLink) >= pVehicle->AutoPilot.m_nCurrentRouteNode) ? 1 : -1; pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(curLink + pCurNode->firstLink) >= pVehicle->AutoPilot.m_nCurrentRouteNode) ? 1 : -1;
} }

File diff suppressed because it is too large Load Diff

View File

@ -57,8 +57,9 @@ enum eGarageType : int8
enum enum
{ {
TOTAL_COLLECTCARS_GARAGES = GARAGE_COLLECTCARS_3 - GARAGE_COLLECTCARS_1 + 1, TOTAL_COLLECTCARS_GARAGES = 4,
TOTAL_COLLECTCARS_CARS = 16 TOTAL_HIDEOUT_GARAGES = 12,
TOTAL_COLLECTCARS_CARS = 6
}; };
class CStoredCar class CStoredCar
@ -94,6 +95,7 @@ class CGarage
{ {
eGarageType m_eGarageType; eGarageType m_eGarageType;
eGarageState m_eGarageState; eGarageState m_eGarageState;
uint8 m_nMaxStoredCars;
bool field_2; // unused bool field_2; // unused
bool m_bClosingWithoutTargetCar; bool m_bClosingWithoutTargetCar;
bool m_bDeactivated; bool m_bDeactivated;
@ -108,12 +110,17 @@ class CGarage
bool m_bRecreateDoorOnNextRefresh; bool m_bRecreateDoorOnNextRefresh;
bool m_bRotatedDoor; bool m_bRotatedDoor;
bool m_bCameraFollowsPlayer; bool m_bCameraFollowsPlayer;
float m_fX1; CVector2D m_vecCorner1;
float m_fX2; float m_fInfZ;
float m_fY1; CVector2D m_vDir1;
float m_fY2; CVector2D m_vDir2;
float m_fZ1; float m_fSupZ;
float m_fZ2; float m_fDir1Len;
float m_fDir2Len;
float m_fInfX;
float m_fSupX;
float m_fInfY;
float m_fSupY;
float m_fDoorPos; float m_fDoorPos;
float m_fDoorHeight; float m_fDoorHeight;
float m_fDoor1X; float m_fDoor1X;
@ -134,8 +141,8 @@ class CGarage
bool IsClosed() { return m_eGarageState == GS_FULLYCLOSED; } bool IsClosed() { return m_eGarageState == GS_FULLYCLOSED; }
bool IsUsed() { return m_eGarageType != GARAGE_NONE; } bool IsUsed() { return m_eGarageType != GARAGE_NONE; }
void Update(); void Update();
float GetGarageCenterX() { return (m_fX1 + m_fX2) / 2; } float GetGarageCenterX() { return (m_fInfX + m_fSupX) / 2; }
float GetGarageCenterY() { return (m_fY1 + m_fY2) / 2; } float GetGarageCenterY() { return (m_fInfY + m_fSupY) / 2; }
bool IsFar() bool IsFar()
{ {
#ifdef FIX_BUGS #ifdef FIX_BUGS
@ -153,7 +160,6 @@ class CGarage
void UpdateDoorsHeight(); void UpdateDoorsHeight();
bool IsEntityEntirelyInside3D(CEntity*, float); bool IsEntityEntirelyInside3D(CEntity*, float);
bool IsEntityEntirelyOutside(CEntity*, float); bool IsEntityEntirelyOutside(CEntity*, float);
bool IsEntityEntirelyInside(CEntity*);
float CalcDistToGarageRectangleSquared(float, float); float CalcDistToGarageRectangleSquared(float, float);
float CalcSmallestDistToGarageDoorSquared(float, float); float CalcSmallestDistToGarageDoorSquared(float, float);
bool IsAnyOtherCarTouchingGarage(CVehicle* pException); bool IsAnyOtherCarTouchingGarage(CVehicle* pException);
@ -178,17 +184,22 @@ class CGarage
void FindDoorsEntitiesSectorList(CPtrList&, bool); void FindDoorsEntitiesSectorList(CPtrList&, bool);
void PlayerArrestedOrDied(); void PlayerArrestedOrDied();
bool IsPointInsideGarage(CVector);
bool IsPointInsideGarage(CVector, float);
void ThrowCarsNearDoorOutOfGarage(CVehicle*);
int32 FindMaxNumStoredCarsForGarage() { return Max(NUM_GARAGE_STORED_CARS, m_nMaxStoredCars); }
friend class CGarages; friend class CGarages;
friend class cAudioManager; friend class cAudioManager;
friend class CCamera; friend class CCamera;
}; };
VALIDATE_SIZE(CGarage, 140);
class CGarages class CGarages
{ {
enum { enum {
MESSAGE_LENGTH = 8 MESSAGE_LENGTH = 8,
MAX_NUM_CARS_IN_HIDEOUT_GARAGE = 4
}; };
static int32 BankVansCollected; static int32 BankVansCollected;
static bool BombsAreFree; static bool BombsAreFree;
@ -206,9 +217,7 @@ class CGarages
static bool PlayerInGarage; static bool PlayerInGarage;
static int32 PoliceCarsCollected; static int32 PoliceCarsCollected;
static CGarage aGarages[NUM_GARAGES]; static CGarage aGarages[NUM_GARAGES];
static CStoredCar aCarsInSafeHouse1[NUM_GARAGE_STORED_CARS]; static CStoredCar aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][MAX_NUM_CARS_IN_HIDEOUT_GARAGE];
static CStoredCar aCarsInSafeHouse2[NUM_GARAGE_STORED_CARS];
static CStoredCar aCarsInSafeHouse3[NUM_GARAGE_STORED_CARS];
static int32 AudioEntity; static int32 AudioEntity;
static bool bCamShouldBeOutisde; static bool bCamShouldBeOutisde;
@ -251,15 +260,45 @@ public:
static bool IsModelIndexADoor(uint32 id); static bool IsModelIndexADoor(uint32 id);
static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; } static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; }
static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; } static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; }
static void SetMaxNumStoredCarsForGarage(int16 garage, uint8 num) { aGarages[garage].m_nMaxStoredCars = num; }
private: private:
static bool IsCarSprayable(CVehicle*); static bool IsCarSprayable(CVehicle*);
static float FindDoorHeightForMI(int32); static float FindDoorHeightForMI(int32);
static void CloseHideOutGaragesBeforeSave(void); static void CloseHideOutGaragesBeforeSave(void);
static int32 CountCarsInHideoutGarage(eGarageType); static int32 CountCarsInHideoutGarage(eGarageType);
static int32 FindMaxNumStoredCarsForGarage(eGarageType);
static int32 GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; } static int32 GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; }
static int32 GetCarsCollectedIndexForGarageType(eGarageType type) { return type - GARAGE_COLLECTCARS_1; } static int32 GetCarsCollectedIndexForGarageType(eGarageType type)
{
switch (type) {
case GARAGE_COLLECTCARS_1: return 0;
case GARAGE_COLLECTCARS_2: return 1;
case GARAGE_COLLECTCARS_3: return 2;
case GARAGE_COLLECTCARS_4: return 3;
default: assert(0);
}
return 0;
}
static int32 FindSafeHouseIndexForGarageType(eGarageType type)
{
switch (type) {
case GARAGE_HIDEOUT_ONE: return 0;
case GARAGE_HIDEOUT_TWO: return 1;
case GARAGE_HIDEOUT_THREE: return 2;
case GARAGE_HIDEOUT_FOUR: return 3;
case GARAGE_HIDEOUT_FIVE: return 4;
case GARAGE_HIDEOUT_SIX: return 5;
case GARAGE_HIDEOUT_SEVEN: return 6;
case GARAGE_HIDEOUT_EIGHT: return 7;
case GARAGE_HIDEOUT_NINE: return 8;
case GARAGE_HIDEOUT_TEN: return 9;
case GARAGE_HIDEOUT_ELEVEN: return 10;
case GARAGE_HIDEOUT_TWELVE: return 11;
default: assert(0);
}
return -1;
}
static bool IsThisGarageTypeSafehouse(eGarageType type) { return FindSafeHouseIndexForGarageType(type) >= 0; }
friend class cAudioManager; friend class cAudioManager;
friend class CGarage; friend class CGarage;

View File

@ -9746,8 +9746,21 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
case COMMAND_IS_CHAR_IN_ANY_PLANE: case COMMAND_IS_CHAR_IN_ANY_PLANE:
case COMMAND_IS_PLAYER_IN_ANY_PLANE: case COMMAND_IS_PLAYER_IN_ANY_PLANE:
case COMMAND_IS_CHAR_IN_WATER: case COMMAND_IS_CHAR_IN_WATER:
assert(0);
case COMMAND_SET_VAR_INT_TO_CONSTANT: case COMMAND_SET_VAR_INT_TO_CONSTANT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
*ptr = ScriptParams[0];
return 0;
}
case COMMAND_SET_LVAR_INT_TO_CONSTANT: case COMMAND_SET_LVAR_INT_TO_CONSTANT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
*ptr = ScriptParams[0];
return 0;
}
default: default:
assert(0); assert(0);
} }
@ -9802,7 +9815,20 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_GET_NUMBER_OF_SONY_CDS_READ: case COMMAND_GET_NUMBER_OF_SONY_CDS_READ:
case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_COORD_OLD: case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_COORD_OLD:
case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_COORD: case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_COORD:
assert(0);
case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_COORD: case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_COORD:
{
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
int id = CRadar::SetShortRangeCoordBlip(BLIP_COORD, pos, 5, BLIP_DISPLAY_BOTH);
CRadar::SetBlipSprite(id, ScriptParams[3]);
ScriptParams[0] = id;
StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_ADD_MONEY_SPENT_ON_CLOTHES: case COMMAND_ADD_MONEY_SPENT_ON_CLOTHES:
case COMMAND_SET_HELI_ORIENTATION: case COMMAND_SET_HELI_ORIENTATION:
case COMMAND_CLEAR_HELI_ORIENTATION: case COMMAND_CLEAR_HELI_ORIENTATION:
@ -10026,7 +10052,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
switch (command) { switch (command) {
case COMMAND_REGISTER_VIGILANTE_LEVEL: case COMMAND_REGISTER_VIGILANTE_LEVEL:
case COMMAND_CLEAR_ALL_CHAR_ANIMS: case COMMAND_CLEAR_ALL_CHAR_ANIMS:
assert(0);
case COMMAND_SET_MAXIMUM_NUMBER_OF_CARS_IN_GARAGE: case COMMAND_SET_MAXIMUM_NUMBER_OF_CARS_IN_GARAGE:
CollectParameters(&m_nIp, 2);
CGarages::SetMaxNumStoredCarsForGarage(ScriptParams[0], ScriptParams[1]);
break;
case COMMAND_WANTED_STARS_ARE_FLASHING: case COMMAND_WANTED_STARS_ARE_FLASHING:
case COMMAND_SET_ALLOW_HURRICANES: case COMMAND_SET_ALLOW_HURRICANES:
case COMMAND_PLAY_ANNOUNCEMENT: case COMMAND_PLAY_ANNOUNCEMENT:

View File

@ -696,8 +696,8 @@ CCamera::CamControl(void)
garageDoorPos2.z = 0.0f; garageDoorPos2.z = 0.0f;
#endif #endif
} }
garageCenter.x = (pToGarageWeAreIn->m_fX1 + pToGarageWeAreIn->m_fX2)/2.0f; garageCenter.x = pToGarageWeAreIn->GetGarageCenterX();
garageCenter.y = (pToGarageWeAreIn->m_fY1 + pToGarageWeAreIn->m_fY2)/2.0f; garageCenter.y = pToGarageWeAreIn->GetGarageCenterY();
garageCenter.z = 0.0f; garageCenter.z = 0.0f;
if(whichDoor == 1) if(whichDoor == 1)
garageCenterToDoor = garageDoorPos1 - garageCenter; garageCenterToDoor = garageDoorPos1 - garageCenter;
@ -979,8 +979,8 @@ CCamera::CamControl(void)
} }
if(pToGarageWeAreIn){ if(pToGarageWeAreIn){
garageCenter.x = (pToGarageWeAreIn->m_fX1 + pToGarageWeAreIn->m_fX2)/2.0f; garageCenter.x = pToGarageWeAreIn->GetGarageCenterX();
garageCenter.y = (pToGarageWeAreIn->m_fY1 + pToGarageWeAreIn->m_fY2)/2.0f; garageCenter.y = pToGarageWeAreIn->GetGarageCenterY();
garageCenter.z = 0.0f; garageCenter.z = 0.0f;
}else{ }else{
garageDoorPos1.z = 0.0f; garageDoorPos1.z = 0.0f;
@ -1013,8 +1013,8 @@ CCamera::CamControl(void)
if(PedZoomIndicator == CAM_ZOOM_TOPDOWN && !stairs){ if(PedZoomIndicator == CAM_ZOOM_TOPDOWN && !stairs){
garageCamPos = garageCenter; garageCamPos = garageCenter;
garageCamPos.z += FindPlayerPed()->GetPosition().z + 2.1f; garageCamPos.z += FindPlayerPed()->GetPosition().z + 2.1f;
if(pToGarageWeAreIn && garageCamPos.z > pToGarageWeAreIn->m_fX2) // What? if(pToGarageWeAreIn && garageCamPos.z > pToGarageWeAreIn->m_fSupX) // What?
garageCamPos.z = pToGarageWeAreIn->m_fX2; garageCamPos.z = pToGarageWeAreIn->m_fSupX;
}else }else
garageCamPos.z = ground + 3.1f; garageCamPos.z = ground + 3.1f;
SetCamPositionForFixedMode(garageCamPos, CVector(0.0f, 0.0f, 0.0f)); SetCamPositionForFixedMode(garageCamPos, CVector(0.0f, 0.0f, 0.0f));

View File

@ -527,9 +527,11 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition());
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else { }
else {
#ifdef TRIANGULAR_BLIPS #ifdef TRIANGULAR_BLIPS
const CVector& pos = FindPlayerCentreOfWorld_NoSniperShift(); const CVector& pos = FindPlayerCentreOfWorld_NoSniperShift();
const CVector& blipPos = blipEntity->GetPosition(); const CVector& blipPos = blipEntity->GetPosition();
@ -546,6 +548,7 @@ void CRadar::DrawBlips()
} }
} }
} }
}
break; break;
case BLIP_COORD: case BLIP_COORD:
case BLIP_CONTACT_POINT: case BLIP_CONTACT_POINT:
@ -566,9 +569,11 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos);
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else { }
else {
#ifdef TRIANGULAR_BLIPS #ifdef TRIANGULAR_BLIPS
const CVector& pos = FindPlayerCentreOfWorld_NoSniperShift(); const CVector& pos = FindPlayerCentreOfWorld_NoSniperShift();
const CVector& blipPos = ms_RadarTrace[blipId].m_vecPos; const CVector& blipPos = ms_RadarTrace[blipId].m_vecPos;
@ -584,6 +589,7 @@ void CRadar::DrawBlips()
} }
} }
} }
}
break; break;
default: default:
break; break;
@ -632,6 +638,7 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition());
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
else else
@ -652,6 +659,7 @@ void CRadar::DrawBlips()
} }
} }
} }
}
break; break;
default: default:
break; break;
@ -681,6 +689,7 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos);
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
else else
@ -700,6 +709,7 @@ void CRadar::DrawBlips()
#endif #endif
} }
} }
}
break; break;
default: default:
break; break;
@ -992,6 +1002,7 @@ CRadar::Initialise()
ms_RadarTrace[i].m_BlipIndex = 1; ms_RadarTrace[i].m_BlipIndex = 1;
SetRadarMarkerState(i, false); SetRadarMarkerState(i, false);
ms_RadarTrace[i].m_bInUse = false; ms_RadarTrace[i].m_bInUse = false;
ms_RadarTrace[i].m_bShortRange = false;
ms_RadarTrace[i].m_eBlipType = BLIP_NONE; ms_RadarTrace[i].m_eBlipType = BLIP_NONE;
ms_RadarTrace[i].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; ms_RadarTrace[i].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
ms_RadarTrace[i].m_eRadarSprite = RADAR_SPRITE_NONE; ms_RadarTrace[i].m_eRadarSprite = RADAR_SPRITE_NONE;
@ -1102,8 +1113,9 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay
} }
ms_RadarTrace[nextBlip].m_eBlipType = type; ms_RadarTrace[nextBlip].m_eBlipType = type;
ms_RadarTrace[nextBlip].m_nColor = color; ms_RadarTrace[nextBlip].m_nColor = color;
ms_RadarTrace[nextBlip].m_bDim = 1; ms_RadarTrace[nextBlip].m_bDim = true;
ms_RadarTrace[nextBlip].m_bInUse = 1; ms_RadarTrace[nextBlip].m_bInUse = true;
ms_RadarTrace[nextBlip].m_bShortRange = false;
ms_RadarTrace[nextBlip].m_Radius = 1.0f; ms_RadarTrace[nextBlip].m_Radius = 1.0f;
ms_RadarTrace[nextBlip].m_vec2DPos = pos; ms_RadarTrace[nextBlip].m_vec2DPos = pos;
ms_RadarTrace[nextBlip].m_vecPos = pos; ms_RadarTrace[nextBlip].m_vecPos = pos;
@ -1114,6 +1126,15 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay
return CRadar::GetNewUniqueBlipIndex(nextBlip); return CRadar::GetNewUniqueBlipIndex(nextBlip);
} }
int CRadar::SetShortRangeCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay display)
{
int index = SetCoordBlip(type, pos, color, display);
if (index == -1)
return -1;
ms_RadarTrace[GetActualBlipArrayIndex(index)].m_bShortRange = true;
return index;
}
int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDisplay display) int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDisplay display)
{ {
int nextBlip; int nextBlip;
@ -1123,8 +1144,9 @@ int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDispla
} }
ms_RadarTrace[nextBlip].m_eBlipType = type; ms_RadarTrace[nextBlip].m_eBlipType = type;
ms_RadarTrace[nextBlip].m_nColor = color; ms_RadarTrace[nextBlip].m_nColor = color;
ms_RadarTrace[nextBlip].m_bDim = 1; ms_RadarTrace[nextBlip].m_bDim = true;
ms_RadarTrace[nextBlip].m_bInUse = 1; ms_RadarTrace[nextBlip].m_bInUse = true;
ms_RadarTrace[nextBlip].m_bShortRange = false;
ms_RadarTrace[nextBlip].m_Radius = 1.0f; ms_RadarTrace[nextBlip].m_Radius = 1.0f;
ms_RadarTrace[nextBlip].m_nEntityHandle = handle; ms_RadarTrace[nextBlip].m_nEntityHandle = handle;
ms_RadarTrace[nextBlip].m_wScale = 1; ms_RadarTrace[nextBlip].m_wScale = 1;

View File

@ -66,12 +66,12 @@ struct sRadarTrace
uint16 m_BlipIndex; uint16 m_BlipIndex;
bool m_bDim; bool m_bDim;
bool m_bInUse; bool m_bInUse;
bool m_bShortRange;
float m_Radius; float m_Radius;
int16 m_wScale; int16 m_wScale;
uint16 m_eBlipDisplay; // eBlipDisplay uint16 m_eBlipDisplay; // eBlipDisplay
uint16 m_eRadarSprite; // eRadarSprite uint16 m_eRadarSprite; // eRadarSprite
}; };
VALIDATE_SIZE(sRadarTrace, 0x30);
// Values for screen space // Values for screen space
#define RADAR_LEFT (40.0f) #define RADAR_LEFT (40.0f)
@ -149,6 +149,7 @@ public:
static void SetBlipSprite(int32 i, int32 icon); static void SetBlipSprite(int32 i, int32 icon);
static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay); static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay);
static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay); static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay);
static int32 SetShortRangeCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay);
static void SetRadarMarkerState(int32 i, bool flag); static void SetRadarMarkerState(int32 i, bool flag);
static void ShowRadarMarker(CVector pos, uint32 color, float radius); static void ShowRadarMarker(CVector pos, uint32 color, float radius);
static void ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha); static void ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha);

View File

@ -58,6 +58,9 @@ int32 CStats::CarsCrushed;
int32 CStats::FastestTimes[CStats::TOTAL_FASTEST_TIMES]; int32 CStats::FastestTimes[CStats::TOTAL_FASTEST_TIMES];
int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES]; int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES];
int32 CStats::Sprayings;
float CStats::AutoPaintingBudget;
void CStats::Init() void CStats::Init()
{ {
PeopleKilledByOthers = 0; PeopleKilledByOthers = 0;
@ -113,6 +116,9 @@ void CStats::Init()
IndustrialPassed = 0; IndustrialPassed = 0;
CommercialPassed = 0; CommercialPassed = 0;
SuburbanPassed = 0; SuburbanPassed = 0;
Sprayings = 0;
AutoPaintingBudget = 0.0f;
} }
void CStats::RegisterFastestTime(int32 index, int32 time) void CStats::RegisterFastestTime(int32 index, int32 time)

View File

@ -62,6 +62,8 @@ public:
static int32 CarsCrushed; static int32 CarsCrushed;
static int32 FastestTimes[TOTAL_FASTEST_TIMES]; static int32 FastestTimes[TOTAL_FASTEST_TIMES];
static int32 HighestScores[TOTAL_HIGHEST_SCORES]; static int32 HighestScores[TOTAL_HIGHEST_SCORES];
static int32 Sprayings;
static float AutoPaintingBudget;
public: public:
static void Init(void); static void Init(void);

View File

@ -462,3 +462,10 @@ CWanted::UpdateCrimesQ(void)
} }
} }
} }
void
CWanted::Suspend(void)
{
// TODO(MIAMI)!
Reset(); // <- temporary
}

View File

@ -49,6 +49,8 @@ public:
void UpdateCrimesQ(); void UpdateCrimesQ();
void Update(); void Update();
void Suspend();
bool IsIgnored(void) { return m_bIgnoredByCops || m_bIgnoredByEveryone; } bool IsIgnored(void) { return m_bIgnoredByCops || m_bIgnoredByEveryone; }
static int32 WorkOutPolicePresence(CVector posn, float radius); static int32 WorkOutPolicePresence(CVector posn, float radius);

View File

@ -130,7 +130,7 @@ enum Config {
NUM_AUDIO_REFLECTIONS = 5, NUM_AUDIO_REFLECTIONS = 5,
NUM_SCRIPT_MAX_ENTITIES = 40, NUM_SCRIPT_MAX_ENTITIES = 40,
NUM_GARAGE_STORED_CARS = 6, NUM_GARAGE_STORED_CARS = 4,
NUM_CRANES = 8, NUM_CRANES = 8,

View File

@ -117,6 +117,17 @@ public:
void SetMoveSpeed(const CVector& speed) { void SetMoveSpeed(const CVector& speed) {
m_vecMoveSpeed = speed; m_vecMoveSpeed = speed;
} }
void AddToMoveSpeed(float x, float y, float z) {
m_vecMoveSpeed.x += x;
m_vecMoveSpeed.y += y;
m_vecMoveSpeed.z += z;
}
void AddToMoveSpeed(const CVector& addition) {
m_vecMoveSpeed += addition;
}
void AddToMoveSpeed(const CVector2D& addition) {
m_vecMoveSpeed += CVector(addition.x, addition.y, 0.0f);
}
const CVector &GetTurnSpeed() { return m_vecTurnSpeed; } const CVector &GetTurnSpeed() { return m_vecTurnSpeed; }
void SetTurnSpeed(float x, float y, float z) { void SetTurnSpeed(float x, float y, float z) {
m_vecTurnSpeed.x = x; m_vecTurnSpeed.x = x;

View File

@ -84,7 +84,6 @@ public:
float m_aWheelPosition[4]; float m_aWheelPosition[4];
float m_aWheelSpeed[4]; float m_aWheelSpeed[4];
uint8 field_4D8; uint8 field_4D8;
uint8 m_bombType : 3;
uint8 bTaxiLight : 1; uint8 bTaxiLight : 1;
uint8 bHadDriver : 1; // for bombs uint8 bHadDriver : 1; // for bombs
uint8 bFixedColour : 1; uint8 bFixedColour : 1;
@ -92,7 +91,6 @@ public:
uint8 bWaterTight : 1; // no damage for non-player peds uint8 bWaterTight : 1; // no damage for non-player peds
uint8 bNotDamagedUpsideDown : 1; uint8 bNotDamagedUpsideDown : 1;
uint8 bMoreResistantToDamage : 1; uint8 bMoreResistantToDamage : 1;
CEntity *m_pBombRigger;
int16 field_4E0; int16 field_4E0;
uint16 m_hydraulicState; uint16 m_hydraulicState;
uint32 m_nBusDoorTimerEnd; uint32 m_nBusDoorTimerEnd;

View File

@ -187,6 +187,8 @@ public:
uint8 bCreatedAsPoliceVehicle : 1;// True if this guy was created as a police vehicle (enforcer, policecar, miamivice car etc) uint8 bCreatedAsPoliceVehicle : 1;// True if this guy was created as a police vehicle (enforcer, policecar, miamivice car etc)
uint8 bParking : 1; uint8 bParking : 1;
uint8 m_bombType : 3;
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)
int8 m_nPacManPickupsCarried; int8 m_nPacManPickupsCarried;
@ -195,6 +197,7 @@ public:
float m_fHealth; // 1000.0f = full health. 250.0f = fire. 0 -> explode float m_fHealth; // 1000.0f = full health. 250.0f = fire. 0 -> explode
uint8 m_nCurrentGear; uint8 m_nCurrentGear;
float m_fChangeGearTime; float m_fChangeGearTime;
CEntity* m_pBombRigger;
uint32 m_nGunFiringTime; // last time when gun on vehicle was fired (used on boats) uint32 m_nGunFiringTime; // last time when gun on vehicle was fired (used on boats)
uint32 m_nTimeOfDeath; uint32 m_nTimeOfDeath;
uint16 m_nTimeBlocked; uint16 m_nTimeBlocked;