summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audio/AudioManager.cpp2
-rw-r--r--src/audio/DMAudio.h2
-rw-r--r--src/control/Garages.cpp743
-rw-r--r--src/control/Garages.h30
-rw-r--r--src/core/Stats.cpp1
-rw-r--r--src/core/Stats.h1
-rw-r--r--src/modelinfo/VehicleModelInfo.cpp2
-rw-r--r--src/modelinfo/VehicleModelInfo.h1
8 files changed, 660 insertions, 122 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 39c03ef6..2565a269 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -3732,7 +3732,7 @@ cAudioManager::ProcessFrontEnd()
break;
case SOUND_GARAGE_NO_MONEY:
case SOUND_GARAGE_BAD_VEHICLE:
- case SOUND_3C:
+ case SOUND_GARAGE_BOMB_ALREADY_SET:
m_sQueueSample.m_nSampleIndex = SFX_PICKUP_ERROR_LEFT;
stereo = true;
break;
diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h
index 41901c0d..90fe96b5 100644
--- a/src/audio/DMAudio.h
+++ b/src/audio/DMAudio.h
@@ -65,7 +65,7 @@ enum eSound : int16
SOUND_GARAGE_NO_MONEY = 57,
SOUND_GARAGE_BAD_VEHICLE = 58,
SOUND_GARAGE_OPENING = 59,
- SOUND_GARAGE_DENIED = 60,
+ SOUND_GARAGE_BOMB_ALREADY_SET = 60,
SOUND_GARAGE_BOMB1_SET = 61,
SOUND_GARAGE_BOMB2_SET = 62,
SOUND_GARAGE_BOMB3_SET = 63,
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index af443f8e..27392591 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -5,6 +5,7 @@
#include "General.h"
#include "Font.h"
+#include "HandlingMgr.h"
#include "Hud.h"
#include "Messages.h"
#include "ModelIndices.h"
@@ -28,28 +29,62 @@
#define ROTATED_DOOR_CLOSE_SPEED (0.02f)
#define DEFAULT_DOOR_OPEN_SPEED (0.035f)
#define DEFAULT_DOOR_CLOSE_SPEED (0.04f)
+#define CRUSHER_CRANE_SPEED 0.005f
+// Prices
#define BOMB_PRICE 1000
#define RESPRAY_PRICE 1000
+// Distances
#define DISTANCE_TO_CALL_OFF_CHASE 10.0f
#define DISTANCE_FOR_MRWHOOP_HACK 4.0f
#define DISTANCE_TO_ACTIVATE_GARAGE 8.0f
+#define DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE 17.0f
#define DISTANCE_TO_CLOSE_MISSION_GARAGE 30.0f
-#define DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE 25.0
+#define DISTANCE_TO_CLOSE_COLLECTSPECIFICCARS_GARAGE 25.0
+#define DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE 40.0f
+#define DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_ON_FOOT 2.4f
+#define DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_IN_CAR 15.0f
+#define DISTANCE_TO_FORCE_CLOSE_HIDEOUT_GARAGE 70.0f
+#define DISTANCE_TO_OPEN_HIDEOUT_GARAGE_ON_FOOT 1.7f
+#define DISTANCE_TO_OPEN_HIDEOUT_GARAGE_IN_CAR 10.0f
+#define DISTANCE_TO_SHOW_HIDEOUT_MESSAGE 5.0f
+// Time
#define TIME_TO_RESPRAY 2000
+#define TIME_TO_SETUP_BOMB 2000
+#define TIME_TO_CRUSH_CAR 3000
+#define TIME_TO_PROCESS_KEEPCAR_GARAGE 2000
+// Respray stuff
#define FREE_RESPRAY_HEALTH_THRESHOLD 970.0f
#define NUM_PARTICLES_IN_RESPRAY 200
+// Bomb stuff
#define KGS_OF_EXPLOSIVES_IN_BOMB 10
+// Collect specific cars stuff
#define REWARD_FOR_FIRST_POLICE_CAR 5000
#define REWARD_FOR_FIRST_BANK_VAN 5000
#define MAX_POLICE_CARS_TO_COLLECT 10
#define MAX_BANK_VANS_TO_COLLECT 10
+// Collect cars stuff
+#define MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE 0.03f
+
+// Crusher stuff
+#define CRUSHER_VEHICLE_TEST_SPAN 8
+#define CRUSHER_MIN_REWARD 25
+#define CRUSHER_MAX_REWARD 125
+#define CRUSHER_REWARD_COEFFICIENT 1.0f/500000
+
+// Hideout stuff
+#define MAX_STORED_CARS_IN_INDUSTRIAL 1
+#define MAX_STORED_CARS_IN_COMMERCIAL NUM_GARAGE_STORED_CARS
+#define MAX_STORED_CARS_IN_SUBURBAN NUM_GARAGE_STORED_CARS
+#define HIDEOUT_DOOR_SPEED_COEFFICIENT 1.7f
+#define TIME_BETWEEN_HIDEOUT_MESSAGES 18000
+
int32 &CGarages::BankVansCollected = *(int32 *)0x8F1B34;
bool &CGarages::BombsAreFree = *(bool *)0x95CD7A;
bool &CGarages::RespraysAreFree = *(bool *)0x95CD1D;
@@ -268,7 +303,7 @@ void CGarage::Update()
switch (m_eGarageState) {
case GS_OPENED:
if (IsStaticPlayerCarEntirelyInside() && !IsAnyOtherCarTouchingGarage(FindPlayerVehicle())) {
- if (IsCarSprayable()) {
+ if (CGarages::IsCarSprayable(FindPlayerVehicle())) {
if (CWorld::Players[CWorld::PlayerInFocus].m_nMoney >= RESPRAY_PRICE || CGarages::RespraysAreFree) {
m_eGarageState = GS_CLOSING;
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
@@ -405,6 +440,7 @@ void CGarage::Update()
//case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF:
default:
+ break;
}
break;
case GARAGE_BOMBSHOP1:
@@ -420,7 +456,7 @@ void CGarage::Update()
#endif
CGarages::TriggerMessage("GA_5", -1, 4000, -1); //"Your car is already fitted with a bomb"
m_eGarageState = GS_OPENEDCONTAINSCAR;
- DMAudio.PlayFrontEndSound(SOUND_GARAGE_DENIED, 1);
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1);
break;
}
if (!CGarages::BombsAreFree && CWorld::Players[CWorld::PlayerInFocus].m_nMoney >= BOMB_PRICE) {
@@ -438,6 +474,7 @@ void CGarage::Update()
m_fDoorPos = max(0.0f, m_fDoorPos - m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
+ m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_SETUP_BOMB;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
}
UpdateDoorsHeight();
@@ -585,8 +622,8 @@ void CGarage::Update()
m_eGarageState = GS_CLOSING;
}
}
- else if (Abs(FindPlayerCoors().x - GetGarageCenterX()) > DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE ||
- Abs(FindPlayerCoors().y - GetGarageCenterY()) > DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE) {
+ else if (Abs(FindPlayerCoors().x - GetGarageCenterX()) > DISTANCE_TO_CLOSE_COLLECTSPECIFICCARS_GARAGE ||
+ Abs(FindPlayerCoors().y - GetGarageCenterY()) > DISTANCE_TO_CLOSE_COLLECTSPECIFICCARS_GARAGE) {
m_eGarageState = GS_CLOSING;
m_pTarget = nil;
}
@@ -595,6 +632,7 @@ void CGarage::Update()
case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
if (m_pTarget) {
DestroyVehicleAndDriverAndPassengers(m_pTarget);
@@ -644,102 +682,520 @@ void CGarage::Update()
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
+ UpdateDoorsHeight();
break;
//case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF:
default:
+ break;
}
break;
- case GARAGE_COLLECTORSITEMS:
case GARAGE_COLLECTCARS_1:
case GARAGE_COLLECTCARS_2:
case GARAGE_COLLECTCARS_3:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (FindPlayerVehicle() && DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) {
+ m_pTarget = FindPlayerVehicle();
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ if (Abs(FindPlayerCoors().x - GetGarageCenterX()) > DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE ||
+ Abs(FindPlayerCoors().y - GetGarageCenterY()) > DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE) {
+ m_eGarageState = GS_CLOSING;
+ m_pTarget = nil;
+ break;
+ }
+ if (m_pTarget && !FindPlayerVehicle() && IsEntityEntirelyInside3D(m_pTarget, 0.0f) &&
+ !IsAnyOtherCarTouchingGarage(m_pTarget) && IsEntityEntirelyOutside(FindPlayerPed(), 2.0f)) {
+#ifdef FIX_BUGS
+ if (!m_pTarget->IsCar() ||
+ ((CAutomobile*)(m_pTarget))->Damage.GetEngineStatus() <= ENGINE_STATUS_ON_FIRE &&
+ ((CAutomobile*)(m_pTarget))->m_fFireBlowUpTimer == 0.0f) {
+#else
+ if (((CAutomobile*)(m_pTarget))->Damage.GetEngineStatus() <= ENGINE_STATUS_ON_FIRE &&
+ ((CAutomobile*)(m_pTarget))->m_fFireBlowUpTimer == 0.0f) {
+#endif
+ if (m_pTarget->m_status != STATUS_WRECKED) {
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ m_eGarageState = GS_CLOSING;
+ TheCamera.SetCameraDirectlyBehindForFollowPed_CamOnAString();
+ }
+ }
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ if (m_pTarget) {
+ MarkThisCarAsCollectedForCraig(m_pTarget->GetModelIndex());
+ DestroyVehicleAndDriverAndPassengers(m_pTarget);
+ m_pTarget = nil;
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
+ }
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() &&
+ CalcSmallestDistToGarageDoorSquared(
+ FindPlayerVehicle()->GetPosition().x,
+ FindPlayerVehicle()->GetPosition().y
+ ) < SQR(DISTANCE_TO_ACTIVATE_GARAGE)) {
+ if (DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) {
+ if (FindPlayerVehicle()->VehicleCreatedBy == MISSION_VEHICLE)
+ CGarages::TriggerMessage("GA_1A", -1, 5000, -1); // Come back when you're not so busy...
+ else
+ m_eGarageState = GS_OPENING;
+ }
+ else {
+ if (HasCraigCollectedThisCar(FindPlayerVehicle()->GetModelIndex()))
+ CGarages::TriggerMessage("GA_20", -1, 5000, -1); // We got more of these than we can shift. Sorry man, no deal.
+ else if (FindPlayerSpeed().Magnitude() < MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE)
+ CGarages::TriggerMessage("GA_19", -1, 5000, -1); // We're not interested in that model.
+ }
+ }
+ m_pTarget = nil;
+ break;
+ case GS_OPENING:
+ if (FindPlayerVehicle() && DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) {
+ m_pTarget = FindPlayerVehicle();
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : ROTATED_DOOR_OPEN_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
case GARAGE_FORCARTOCOMEOUTOF:
- case GARAGE_60SECONDS:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (IsGarageEmpty())
+ m_eGarageState = GS_CLOSING;
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ if (!IsGarageEmpty())
+ m_eGarageState = GS_OPENING;
+ break;
+ case GS_FULLYCLOSED:
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : ROTATED_DOOR_OPEN_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_OPENEDCONTAINSCAR:
+ case GS_CLOSEDCONTAINSCAR:
+ case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
case GARAGE_CRUSHER:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ {
+ int i = CPools::GetVehiclePool()->GetSize() * (CTimer::GetFrameCounter() % CRUSHER_VEHICLE_TEST_SPAN) / CRUSHER_VEHICLE_TEST_SPAN;
+ int end = CPools::GetVehiclePool()->GetSize() * (CTimer::GetFrameCounter() % CRUSHER_VEHICLE_TEST_SPAN + 1) / CRUSHER_VEHICLE_TEST_SPAN;
+ for (; i < end; i++) {
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
+ if (!pVehicle)
+ continue;
+ if (pVehicle->IsCar() && IsEntityEntirelyInside3D(pVehicle, 0.0f)) {
+ m_eGarageState = GS_CLOSING;
+ m_pTarget = pVehicle;
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ }
+ break;
+ }
+ case GS_CLOSING:
+ if (m_pTarget) {
+ m_fDoorPos = max(0.0f, m_fDoorPos - CRUSHER_CRANE_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos < TWOPI/5) {
+ m_pTarget->bUsesCollision = false;
+ m_pTarget->bAffectedByGravity = false;
+ m_pTarget->SetMoveSpeed(0.0f, 0.0f, 0.0f);
+ }
+ else {
+ m_pTarget->SetMoveSpeed(m_pTarget->GetMoveSpeed()* Pow(0.8f, CTimer::GetTimeStep()));
+ }
+ if (m_fDoorPos == 0.0f) {
+ CGarages::CrushedCarId = CPools::GetVehiclePool()->GetIndex(m_pTarget);
+ float reward = min(CRUSHER_MAX_REWARD, CRUSHER_MIN_REWARD + m_pTarget->pHandling->nMonetaryValue * m_pTarget->m_fHealth * CRUSHER_REWARD_COEFFICIENT);
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward;
+ DestroyVehicleAndDriverAndPassengers(m_pTarget);
+ ++CStats::CarsCrushed;
+ m_pTarget = nil;
+ m_eGarageState = GS_AFTERDROPOFF;
+ m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_CRUSH_CAR;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ }
+ else
+ m_eGarageState = GS_OPENING;
+ UpdateCrusherAngle();
+ break;
+ case GS_AFTERDROPOFF:
+ if (CTimer::GetTimeInMilliseconds() <= m_nTimeToStartAction) {
+ UpdateCrusherShake((myrand() & 0xFF - 128) * 0.0002f, (myrand() & 0xFF - 128) * 0.0002f);
+ }
+ else {
+ UpdateCrusherShake(0.0f, 0.0f);
+ m_eGarageState = GS_OPENING;
+ }
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(HALFPI, m_fDoorPos + CTimer::GetTimeStep() * CRUSHER_CRANE_SPEED);
+ if (m_fDoorPos == HALFPI) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateCrusherAngle();
+ break;
+ //case GS_FULLYCLOSED:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_OPENEDCONTAINSCAR:
+
+ default:
+ break;
+ }
+ if (!FindPlayerVehicle() && (CTimer::GetFrameCounter() & 0x1F) == 0x17 && IsEntityEntirelyInside(FindPlayerPed()))
+ FindPlayerPed()->InflictDamage(nil, WEAPONTYPE_RAMMEDBYCAR, 300.0f, PEDPIECE_TORSO, 0);
+ break;
case GARAGE_MISSION_KEEPCAR:
+ case GARAGE_MISSION_KEEPCAR_REMAINCLOSED:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE) &&
+ !IsAnyOtherCarTouchingGarage(nil)) {
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = true;
+ }
+ else if (m_pTarget && m_pTarget == FindPlayerVehicle() && IsStaticPlayerCarEntirelyInside() && !IsAnyCarBlockingDoor()) {
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = false;
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ if (m_bClosingWithoutTargetCar)
+ m_eGarageState = GS_FULLYCLOSED;
+ else {
+ if (m_pTarget) {
+ m_eGarageState = GS_CLOSEDCONTAINSCAR;
+ m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_PROCESS_KEEPCAR_GARAGE;
+ m_pTarget = nil;
+ }
+ else
+ m_eGarageState = GS_FULLYCLOSED;
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
+ }
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() == m_pTarget && m_pTarget &&
+ CalcDistToGarageRectangleSquared(
+ FindPlayerVehicle()->GetPosition().x,
+ FindPlayerVehicle()->GetPosition().y
+ ) < SQR(DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE))
+ m_eGarageState = GS_OPENING;
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : ROTATED_DOOR_OPEN_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_CLOSEDCONTAINSCAR:
+ if (m_eGarageType == GARAGE_MISSION_KEEPCAR && CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction)
+ m_eGarageState = GS_OPENING;
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
case GARAGE_FOR_SCRIPT_TO_OPEN:
+ switch (m_eGarageState) {
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : ROTATED_DOOR_OPEN_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENED:
+ //case GS_CLOSING:
+ //case GS_FULLYCLOSED:
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE:
+ switch (m_eGarageState) {
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : ROTATED_DOOR_OPEN_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENED:
+ //case GS_FULLYCLOSED:
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+
case GARAGE_HIDEOUT_ONE:
case GARAGE_HIDEOUT_TWO:
case GARAGE_HIDEOUT_THREE:
- case GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE:
- case GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR:
- case GARAGE_MISSION_KEEPCAR_REMAINCLOSED:
switch (m_eGarageState) {
+ case GS_OPENED:
+ {
+ float distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y);
+ // Close car doors either if player is far, or if he is in vehicle and garage is full,
+ // or if player is very very far so that we can remove whatever is blocking garage door without him noticing
+ if ((distance > SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_IN_CAR) ||
+ !FindPlayerVehicle() && distance > SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_ON_FOOT) &&
+ !IsAnyCarBlockingDoor()))
+ m_eGarageState = GS_CLOSING;
+ else if (FindPlayerVehicle() &&
+ CountCarsWithCenterPointWithinGarage(FindPlayerVehicle()) >=
+ CGarages::FindMaxNumStoredCarsForGarage(m_eGarageType)) {
+ m_eGarageState = GS_CLOSING;
+ }
+ else if (distance > SQR(DISTANCE_TO_FORCE_CLOSE_HIDEOUT_GARAGE)) {
+ m_eGarageState = GS_CLOSING;
+ RemoveCarsBlockingDoorNotInside();
+ }
+ break;
+ }
+ case GS_CLOSING:
+#ifndef FIX_BUGS // TODO: check and replace with ifdef
+ if (!IsPlayerOutsideGarage())
+ m_eGarageState = GS_OPENING;
+ m_fDoorPos = max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
+#else
+ m_fDoorPos = max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
+ if (!IsPlayerOutsideGarage())
+ m_eGarageState = GS_OPENING;
+#endif
+ else if (m_fDoorPos == 0.0f) {
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ m_eGarageState = GS_FULLYCLOSED;
+ switch (m_eGarageType) {
+ case GARAGE_HIDEOUT_ONE: StoreAndRemoveCarsForThisHideout(CGarages::aCarsInSafeHouse1, MAX_STORED_CARS_IN_INDUSTRIAL); break;
+ case GARAGE_HIDEOUT_TWO: StoreAndRemoveCarsForThisHideout(CGarages::aCarsInSafeHouse2, MAX_STORED_CARS_IN_COMMERCIAL); break;
+ case GARAGE_HIDEOUT_THREE: StoreAndRemoveCarsForThisHideout(CGarages::aCarsInSafeHouse3, MAX_STORED_CARS_IN_SUBURBAN); break;
+ }
+ }
+ UpdateDoorsHeight();
+ break;
case GS_FULLYCLOSED:
+ {
+ float distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y);
+ if (distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_ON_FOOT) ||
+ distance < SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_IN_CAR) && FindPlayerVehicle()) {
+ if (FindPlayerVehicle() && CGarages::CountCarsInHideoutGarage(m_eGarageType) >= CGarages::FindMaxNumStoredCarsForGarage(m_eGarageType)) {
+ if (m_pDoor1) {
+ if (((CVector2D)FindPlayerVehicle()->GetPosition() - (CVector2D)m_pDoor1->GetPosition()).MagnitudeSqr() < SQR(DISTANCE_TO_SHOW_HIDEOUT_MESSAGE) &&
+ CTimer::GetTimeInMilliseconds() - CGarages::LastTimeHelpMessage > TIME_BETWEEN_HIDEOUT_MESSAGES) {
+ CHud::SetHelpMessage(TheText.Get("GA_21"), false); // You cannot store any more cars in this garage.
+ CGarages::LastTimeHelpMessage = CTimer::GetTimeInMilliseconds();
+ }
+ }
+ }
+ else {
+#ifdef FIX_BUGS
+ bool bCreatedAllCars = false;
+#else
+ bool bCraetedAllCars;
+#endif
+ switch (m_eGarageType) {
+ case GARAGE_HIDEOUT_ONE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse1); break;
+ case GARAGE_HIDEOUT_TWO: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse2); break;
+ case GARAGE_HIDEOUT_THREE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse3); break;
+ }
+ if (bCreatedAllCars)
+ m_eGarageState = GS_OPENING;
+ }
+ }
+ break;
+ }
case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + HIDEOUT_DOOR_SPEED_COEFFICIENT * m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : ROTATED_DOOR_OPEN_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR:
+ switch (m_eGarageState) {
case GS_OPENED:
+ if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE)) {
+ if (m_pTarget && IsEntityEntirelyOutside(m_pTarget, 0.0f) && !IsAnyOtherCarTouchingGarage(nil)) {
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = true;
+ }
+ }
+ break;
case GS_CLOSING:
- case GS_OPENEDCONTAINSCAR:
- case GS_CLOSEDCONTAINSCAR:
- case GS_AFTERDROPOFF:
+ m_fDoorPos = max(0.0f, m_fDoorPos - m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : ROTATED_DOOR_CLOSE_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() == m_pTarget && m_pTarget &&
+ CalcDistToGarageRectangleSquared(
+ FindPlayerVehicle()->GetPosition().x,
+ FindPlayerVehicle()->GetPosition().y
+ ) < SQR(DISTANCE_TO_ACTIVATE_GARAGE))
+ m_eGarageState = GS_OPENING;
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : ROTATED_DOOR_OPEN_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
default:
+ break;
}
break;
+ //case GARAGE_COLLECTORSITEMS:
+ //case GARAGE_60SECONDS:
default:
break;
}
}
-WRAPPER void CGarages::Load(uint8* buf, uint32 size) { EAXJMP(0x428940); }
-WRAPPER void CGarages::Save(uint8* buf, uint32 *size) { EAXJMP(0x4284E0); }
-
-WRAPPER void CGarage::TidyUpGarageClose() { EAXJMP(0x427D90); }
-WRAPPER void CGarage::TidyUpGarage() { EAXJMP(0x427C30); }
-WRAPPER void CGarage::RefreshDoorPointers(bool) { EAXJMP(0x426980); }
-WRAPPER void CGarage::UpdateCrusherAngle() { EAXJMP(0x4268A0); }
-WRAPPER void CGarage::UpdateDoorsHeight() { EAXJMP(0x426730); }
-WRAPPER float CGarages::FindDoorHeightForMI(int32) { EAXJMP(0x427C10); }
+WRAPPER bool CGarage::IsStaticPlayerCarEntirelyInside() { EAXJMP(0x4251C0); }
+WRAPPER bool CGarage::IsEntityEntirelyInside(CEntity*) { EAXJMP(0x425370); }
+WRAPPER bool CGarage::IsEntityEntirelyInside3D(CEntity*, float) { EAXJMP(0x4254F0); }
+WRAPPER bool CGarage::IsEntityEntirelyOutside(CEntity*, float) { EAXJMP(0x425740); }
+WRAPPER bool CGarage::IsGarageEmpty() { EAXJMP(0x425890); }
+WRAPPER bool CGarage::IsPlayerOutsideGarage() { EAXJMP(0x425910); }
+WRAPPER bool CGarage::IsEntityTouching3D(CEntity*) { EAXJMP(0x425950); }
+WRAPPER bool CGarage::EntityHasASphereWayOutsideGarage(CEntity*, float) { EAXJMP(0x425B30); }
+WRAPPER bool CGarage::IsAnyOtherCarTouchingGarage(CVehicle* pException) { EAXJMP(0x425C90); }
+WRAPPER bool CGarage::IsAnyOtherPedTouchingGarage(CPed* pException) { EAXJMP(0x425E20); }
+WRAPPER bool CGarage::IsAnyCarBlockingDoor() { EAXJMP(0x425FB0); }
+WRAPPER int32 CGarage::CountCarsWithCenterPointWithinGarage(CEntity* pException) { EAXJMP(0x426130); }
+WRAPPER void CGarage::RemoveCarsBlockingDoorNotInside() { EAXJMP(0x4261F0); }
-bool
-CGarages::IsModelIndexADoor(uint32 id)
+void CGarages::PrintMessages()
{
- return id == MI_GARAGEDOOR1 ||
- id == MI_GARAGEDOOR2 ||
- id == MI_GARAGEDOOR3 ||
- id == MI_GARAGEDOOR4 ||
- id == MI_GARAGEDOOR5 ||
- id == MI_GARAGEDOOR6 ||
- id == MI_GARAGEDOOR7 ||
- id == MI_GARAGEDOOR9 ||
- id == MI_GARAGEDOOR10 ||
- id == MI_GARAGEDOOR11 ||
- id == MI_GARAGEDOOR12 ||
- id == MI_GARAGEDOOR13 ||
- id == MI_GARAGEDOOR14 ||
- id == MI_GARAGEDOOR15 ||
- id == MI_GARAGEDOOR16 ||
- id == MI_GARAGEDOOR17 ||
- id == MI_GARAGEDOOR18 ||
- id == MI_GARAGEDOOR19 ||
- id == MI_GARAGEDOOR20 ||
- id == MI_GARAGEDOOR21 ||
- id == MI_GARAGEDOOR22 ||
- id == MI_GARAGEDOOR23 ||
- id == MI_GARAGEDOOR24 ||
- id == MI_GARAGEDOOR25 ||
- id == MI_GARAGEDOOR26 ||
- id == MI_GARAGEDOOR27 ||
- id == MI_GARAGEDOOR28 ||
- id == MI_GARAGEDOOR29 ||
- id == MI_GARAGEDOOR30 ||
- id == MI_GARAGEDOOR31 ||
- id == MI_GARAGEDOOR32 ||
- id == MI_CRUSHERBODY ||
- id == MI_CRUSHERLID;
-}
+ if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) {
+ CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); // BUG: game doesn't use macro here.
+ CFont::SetPropOn();
+ CFont::SetJustifyOff();
+ CFont::SetBackgroundOff();
+ CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(50.0f));
+ CFont::SetCentreOn();
+ CFont::SetFontStyle(FONT_BANK);
+ CFont::SetColor(CRGBA(0, 0, 0, 255));
-bool CGarages::HasCarBeenCrushed(int32 handle)
-{
- return CrushedCarId == handle;
+ float y_offset = SCREEN_HEIGHT / 3; // THIS is PS2 calculation
+ // y_offset = SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(84.0f); // This is PC and results in text being written over some HUD elements
+
+ if (MessageNumberInString2 < 0) {
+ if (MessageNumberInString < 0) {
+ CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(2.0f), TheText.Get(MessageIDString));
+
+ CFont::SetColor(CRGBA(89, 115, 150, 255));
+ CFont::PrintString(SCREEN_WIDTH / 2, y_offset, TheText.Get(MessageIDString));
+ }
+ else {
+ CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, -1, -1, -1, -1, -1, gUString);
+
+ CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
+
+ CFont::SetColor(CRGBA(89, 115, 150, 255));
+ CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
+ }
+ }
+ else {
+ CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString);
+ CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
+
+ CFont::SetColor(CRGBA(89, 115, 150, 255));
+ CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
+ }
+ }
}
-WRAPPER void CGarages::TriggerMessage(const char *text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
-WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector&) { EAXJMP(0x428260); }
-WRAPPER bool CGarages::IsPointWithinAnyGarage(CVector&) { EAXJMP(0x428320); }
-WRAPPER void CGarages::PlayerArrestedOrDied() { EAXJMP(0x427F60); }
+WRAPPER bool CGarages::IsCarSprayable(CVehicle*) { EAXJMP(0x426700); }
+WRAPPER void CGarage::UpdateDoorsHeight() { EAXJMP(0x426730); }
+WRAPPER void CGarage::BuildRotatedDoorMatrix(CEntity*, float) { EAXJMP(0x4267C0); }
+WRAPPER void CGarage::UpdateCrusherAngle() { EAXJMP(0x4268A0); }
+WRAPPER void CGarage::UpdateCrusherShake(float, float) { EAXJMP(0x4268E0); }
+WRAPPER void CGarage::RefreshDoorPointers(bool) { EAXJMP(0x426980); }
+WRAPPER void CGarages::TriggerMessage(const char* text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
WRAPPER void CGarages::SetTargetCarForMissonGarage(int16, CVehicle*) { EAXJMP(0x426BD0); }
WRAPPER bool CGarages::HasCarBeenDroppedOffYet(int16) { EAXJMP(0x426C20); }
WRAPPER void CGarages::DeActivateGarage(int16) { EAXJMP(0x426C40); }
@@ -750,20 +1206,9 @@ int32 CGarages::QueryCarsCollected(int16 garage)
return 0;
}
-void CGarages::GivePlayerDetonator()
-{
- FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
- FindPlayerPed()->GetWeapon(FindPlayerPed()->GetWeaponSlot(WEAPONTYPE_DETONATOR)).m_eWeaponState = WEAPONSTATE_READY;
-}
-
-WRAPPER bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) { EAXJMP(0x426D50); }
-WRAPPER bool CGarages::HasResprayHappened(int16 garage) { EAXJMP(0x4274F0); }
-WRAPPER bool CGarages::IsThisCarWithinGarageArea(int16 garage, CEntity* pCar) { EAXJMP(0x427570); }
-
-void CGarage::OpenThisGarage()
+bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car)
{
- if (m_eGarageState == GS_FULLYCLOSED || m_eGarageState == GS_CLOSING || m_eGarageState == GS_CLOSEDCONTAINSCAR)
- m_eGarageState = GS_OPENING;
+ return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType)] & (1 << car);
}
bool CGarages::IsGarageOpen(int16 garage)
@@ -776,12 +1221,29 @@ bool CGarages::IsGarageClosed(int16 garage)
return aGarages[garage].IsClosed();
}
+WRAPPER bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) { EAXJMP(0x426D50); }
+WRAPPER bool CGarage::DoesCraigNeedThisCar(int32) { EAXJMP(0x426D90); }
+WRAPPER bool CGarage::HasCraigCollectedThisCar(int32) { EAXJMP(0x426DF0); }
+WRAPPER void CGarage::MarkThisCarAsCollectedForCraig(int32) { EAXJMP(0x426E50); }
+
+void CGarage::OpenThisGarage()
+{
+ if (m_eGarageState == GS_FULLYCLOSED || m_eGarageState == GS_CLOSING || m_eGarageState == GS_CLOSEDCONTAINSCAR)
+ m_eGarageState = GS_OPENING;
+}
+
void CGarage::CloseThisGarage()
{
if (m_eGarageState == GS_OPENED || m_eGarageState == GS_OPENING)
m_eGarageState = GS_CLOSING;
}
+WRAPPER float CGarage::CalcDistToGarageRectangleSquared(float, float) { EAXJMP(0x426F50); }
+WRAPPER float CGarage::CalcSmallestDistToGarageDoorSquared(float, float) { EAXJMP(0x426FE0); }
+WRAPPER void CGarage::FindDoorsEntities() { EAXJMP(0x427060); }
+WRAPPER void CGarage::FindDoorsEntitiesSectorList(CPtrList&, bool) { EAXJMP(0x427300); }
+WRAPPER bool CGarages::HasResprayHappened(int16 garage) { EAXJMP(0x4274F0); }
+
void CGarages::SetGarageDoorToRotate(int16 garage)
{
if (aGarages[garage].m_bRotatedDoor)
@@ -791,60 +1253,103 @@ void CGarages::SetGarageDoorToRotate(int16 garage)
aGarages[garage].m_fDoorHeight -= 0.1f;
}
-bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car)
-{
- return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType)] & (1 << car);
-}
-
void CGarages::SetLeaveCameraForThisGarage(int16 garage)
{
aGarages[garage].m_bCameraFollowsPlayer = true;
}
-#if 0
-WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }
-#else
-void CGarages::PrintMessages()
+WRAPPER bool CGarages::IsThisCarWithinGarageArea(int16 garage, CEntity* pCar) { EAXJMP(0x427570); }
+
+bool CGarages::HasCarBeenCrushed(int32 handle)
{
- if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) {
- CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); // BUG: game doesn't use macro here.
- CFont::SetPropOn();
- CFont::SetJustifyOff();
- CFont::SetBackgroundOff();
- CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(50.0f));
- CFont::SetCentreOn();
- CFont::SetFontStyle(FONT_BANK);
- CFont::SetColor(CRGBA(0, 0, 0, 255));
+ return CrushedCarId == handle;
+}
- float y_offset = SCREEN_HEIGHT / 3; // THIS is PS2 calculation
- // y_offset = SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(84.0f); // This is PC and results in text being written over some HUD elements
+WRAPPER void CStoredCar::StoreCar(CVehicle*) { EAXJMP(0x4275C0); }
+WRAPPER CVehicle* CStoredCar::RestoreCar() { EAXJMP(0x427690); }
+WRAPPER void CGarage::StoreAndRemoveCarsForThisHideout(CStoredCar*, int32) { EAXJMP(0x427840); }
+WRAPPER bool CGarage::RestoreCarsForThisHideout(CStoredCar*) { EAXJMP(0x427A40); }
+WRAPPER bool CGarages::IsPointInAGarageCameraZone(CVector) { EAXJMP(0x427AB0); }
+WRAPPER bool CGarages::CameraShouldBeOutside() { EAXJMP(0x427BC0); }
- if (MessageNumberInString2 < 0) {
- if (MessageNumberInString < 0) {
- CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(2.0f), TheText.Get(MessageIDString));
+void CGarages::GivePlayerDetonator()
+{
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
+ FindPlayerPed()->GetWeapon(FindPlayerPed()->GetWeaponSlot(WEAPONTYPE_DETONATOR)).m_eWeaponState = WEAPONSTATE_READY;
+}
- CFont::SetColor(CRGBA(89, 115, 150, 255));
- CFont::PrintString(SCREEN_WIDTH / 2, y_offset, TheText.Get(MessageIDString));
- }
- else {
- CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, -1, -1, -1, -1, -1, gUString);
+WRAPPER float CGarages::FindDoorHeightForMI(int32) { EAXJMP(0x427C10); }
+WRAPPER void CGarage::TidyUpGarage() { EAXJMP(0x427C30); }
+WRAPPER void CGarage::TidyUpGarageClose() { EAXJMP(0x427D90); }
+WRAPPER void CGarages::PlayerArrestedOrDied() { EAXJMP(0x427F60); }
+WRAPPER void CGarage::PlayerArrestedOrDied() { EAXJMP(0x427FC0); }
+WRAPPER void CGarage::CenterCarInGarage(CVehicle*) { EAXJMP(0x428000); }
+WRAPPER void CGarages::CloseHideOutGaragesBeforeSave() { EAXJMP(0x428130); }
+WRAPPER int32 CGarages::CountCarsInHideoutGarage(eGarageType) { EAXJMP(0x4281E0); }
+WRAPPER int32 CGarages::FindMaxNumStoredCarsForGarage(eGarageType) { EAXJMP(0x428230); }
+WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector&) { EAXJMP(0x428260); }
+WRAPPER bool CGarages::IsPointWithinAnyGarage(CVector&) { EAXJMP(0x428320); }
+WRAPPER void CGarages::SetAllDoorsBackToOriginalHeight() { EAXJMP(0x4283D0); }
+WRAPPER void CGarages::Save(uint8* buf, uint32* size) { EAXJMP(0x4284E0); }
- CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
+CStoredCar::CStoredCar(const CStoredCar& other)
+{
+ m_nModelIndex = other.m_nModelIndex;
+ m_vecPos = other.m_vecPos;
+ m_vecAngle = other.m_vecAngle;
+ m_bBulletproof = other.m_bBulletproof;
+ m_bFireproof = other.m_bFireproof;
+ m_bExplosionproof = other.m_bExplosionproof;
+ m_bCollisionproof = other.m_bCollisionproof;
+ m_bMeleeproof = other.m_bMeleeproof;
+ m_nPrimaryColor = other.m_nPrimaryColor;
+ m_nSecondaryColor = other.m_nSecondaryColor;
+ m_nRadioStation = other.m_nRadioStation;
+ m_nVariationA = other.m_nVariationA;
+ m_nVariationB = other.m_nVariationB;
+ m_nCarBombType = other.m_nCarBombType;
+}
- CFont::SetColor(CRGBA(89, 115, 150, 255));
- CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
- }
- }
- else {
- CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString);
- CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
+WRAPPER void CGarages::Load(uint8* buf, uint32 size) { EAXJMP(0x428940); }
- CFont::SetColor(CRGBA(89, 115, 150, 255));
- CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
- }
- }
+bool
+CGarages::IsModelIndexADoor(uint32 id)
+{
+ return id == MI_GARAGEDOOR1 ||
+ id == MI_GARAGEDOOR2 ||
+ id == MI_GARAGEDOOR3 ||
+ id == MI_GARAGEDOOR4 ||
+ id == MI_GARAGEDOOR5 ||
+ id == MI_GARAGEDOOR6 ||
+ id == MI_GARAGEDOOR7 ||
+ id == MI_GARAGEDOOR9 ||
+ id == MI_GARAGEDOOR10 ||
+ id == MI_GARAGEDOOR11 ||
+ id == MI_GARAGEDOOR12 ||
+ id == MI_GARAGEDOOR13 ||
+ id == MI_GARAGEDOOR14 ||
+ id == MI_GARAGEDOOR15 ||
+ id == MI_GARAGEDOOR16 ||
+ id == MI_GARAGEDOOR17 ||
+ id == MI_GARAGEDOOR18 ||
+ id == MI_GARAGEDOOR19 ||
+ id == MI_GARAGEDOOR20 ||
+ id == MI_GARAGEDOOR21 ||
+ id == MI_GARAGEDOOR22 ||
+ id == MI_GARAGEDOOR23 ||
+ id == MI_GARAGEDOOR24 ||
+ id == MI_GARAGEDOOR25 ||
+ id == MI_GARAGEDOOR26 ||
+ id == MI_GARAGEDOOR27 ||
+ id == MI_GARAGEDOOR28 ||
+ id == MI_GARAGEDOOR29 ||
+ id == MI_GARAGEDOOR30 ||
+ id == MI_GARAGEDOOR31 ||
+ id == MI_GARAGEDOOR32 ||
+ id == MI_CRUSHERBODY ||
+ id == MI_CRUSHERLID;
}
-#endif
+
STARTPATCHES
InjectHook(0x421C60, CGarages::Init, PATCH_JUMP);
diff --git a/src/control/Garages.h b/src/control/Garages.h
index 89d51a05..f12ccd0f 100644
--- a/src/control/Garages.h
+++ b/src/control/Garages.h
@@ -66,6 +66,9 @@ class CStoredCar
int8 m_nCarBombType;
public:
void Init() { m_nModelIndex = 0; }
+ CStoredCar(const CStoredCar& other);
+ void StoreCar(CVehicle*);
+ CVehicle* RestoreCar();
};
static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar");
@@ -139,12 +142,30 @@ public:
void UpdateDoorsHeight();
bool IsEntityEntirelyInside3D(CEntity*, float);
bool IsEntityEntirelyOutside(CEntity*, float);
+ bool IsEntityEntirelyInside(CEntity*);
float CalcDistToGarageRectangleSquared(float, float);
+ float CalcSmallestDistToGarageDoorSquared(float, float);
bool IsAnyOtherCarTouchingGarage(CVehicle* pException);
bool IsStaticPlayerCarEntirelyInside();
bool IsPlayerOutsideGarage();
- bool IsCarSprayable();
+ bool IsAnyCarBlockingDoor();
void CenterCarInGarage(CVehicle*);
+ bool DoesCraigNeedThisCar(int32);
+ void MarkThisCarAsCollectedForCraig(int32);
+ bool HasCraigCollectedThisCar(int32);
+ bool IsGarageEmpty();
+ void UpdateCrusherShake(float, float);
+ int32 CountCarsWithCenterPointWithinGarage(CEntity* pException);
+ void RemoveCarsBlockingDoorNotInside();
+ void StoreAndRemoveCarsForThisHideout(CStoredCar*, int32);
+ bool RestoreCarsForThisHideout(CStoredCar*);
+ bool IsEntityTouching3D(CEntity*);
+ bool EntityHasASphereWayOutsideGarage(CEntity*, float);
+ bool IsAnyOtherPedTouchingGarage(CPed* pException);
+ void BuildRotatedDoorMatrix(CEntity*, float);
+ void FindDoorsEntities();
+ void FindDoorsEntitiesSectorList(CPtrList&, bool);
+ void PlayerArrestedOrDied();
};
static_assert(sizeof(CGarage) == 140, "CGarage");
@@ -207,6 +228,13 @@ public:
static bool HasImportExportGarageCollectedThisCar(int16, int8);
static void SetLeaveCameraForThisGarage(int16);
static bool IsThisCarWithinGarageArea(int16, CEntity*);
+ static bool IsCarSprayable(CVehicle*);
+ static int32 FindMaxNumStoredCarsForGarage(eGarageType);
+ static int32 CountCarsInHideoutGarage(eGarageType);
+ static bool IsPointInAGarageCameraZone(CVector);
+ static bool CameraShouldBeOutside();
+ static void CloseHideOutGaragesBeforeSave();
+ static void SetAllDoorsBackToOriginalHeight();
static int GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; }
static int GetCarsCollectedIndexForGarageType(eGarageType type) { return type - GARAGE_COLLECTCARS_1; }
diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp
index 2a3f06b3..9478479b 100644
--- a/src/core/Stats.cpp
+++ b/src/core/Stats.cpp
@@ -49,6 +49,7 @@ int32& CStats::TimeTakenDefuseMission = *(int32*)0x880E24;
int32& CStats::TotalNumberKillFrenzies = *(int32*)0x8E2884;
int32& CStats::TotalNumberMissions = *(int32*)0x8E2820;
int32& CStats::KgOfExplosivesUsed = *(int32*)0x8F2510;
+int32& CStats::CarsCrushed = *(int32*)0x943050;
int32(&CStats::FastestTimes)[CStats::TOTAL_FASTEST_TIMES] = *(int32(*)[CStats::TOTAL_FASTEST_TIMES])*(uintptr*)0x6E9128;
int32(&CStats::HighestScores)[CStats::TOTAL_HIGHEST_SCORES] = *(int32(*)[CStats::TOTAL_HIGHEST_SCORES]) * (uintptr*)0x8622B0;
diff --git a/src/core/Stats.h b/src/core/Stats.h
index f6ff8187..1d220905 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -54,6 +54,7 @@ public:
static int32(&FastestTimes)[TOTAL_FASTEST_TIMES];
static int32(&HighestScores)[TOTAL_HIGHEST_SCORES];
static int32 &KgOfExplosivesUsed;
+ static int32 &CarsCrushed;
public:
static void RegisterFastestTime(int32, int32);
diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp
index 87f01177..42ad635b 100644
--- a/src/modelinfo/VehicleModelInfo.cpp
+++ b/src/modelinfo/VehicleModelInfo.cpp
@@ -1113,6 +1113,8 @@ public:
};
STARTPATCHES
+ InjectHook(0x427820, &CVehicleModelInfo::SetComponentsToUse, PATCH_JUMP);
+
InjectHook(0x51FDC0, &CVehicleModelInfo_::DeleteRwObject_, PATCH_JUMP);
InjectHook(0x51FCB0, &CVehicleModelInfo_::CreateInstance_, PATCH_JUMP);
InjectHook(0x51FC60, &CVehicleModelInfo_::SetClump_, PATCH_JUMP);
diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h
index 1a6d6a55..5969c4ca 100644
--- a/src/modelinfo/VehicleModelInfo.h
+++ b/src/modelinfo/VehicleModelInfo.h
@@ -132,5 +132,6 @@ public:
static void ShutdownEnvironmentMaps(void);
static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id);
+ static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; }
};
static_assert(sizeof(CVehicleModelInfo) == 0x1F8, "CVehicleModelInfo: error");