1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-06 01:45:55 +00:00

garage stuff

This commit is contained in:
Nikolay Korolev 2021-01-26 02:23:55 +03:00
parent e9d58b5a90
commit d7bd0be53e
8 changed files with 173 additions and 50 deletions

View file

@ -16,6 +16,7 @@
#include "Particle.h"
#include "PlayerPed.h"
#include "Replay.h"
#include "Script.h"
#include "Stats.h"
#include "Streaming.h"
#include "Text.h"
@ -43,7 +44,7 @@
#define RESPRAY_PRICE (100)
// Distances
#define DISTANCE_TO_CALL_OFF_CHASE (10.0f)
#define DISTANCE_TO_CALL_OFF_CHASE (50.0f)
#define DISTANCE_FOR_MRWHOOP_HACK (0.5f)
#define DISTANCE_TO_ACTIVATE_GARAGE (8.0f)
#define DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE (17.0f)
@ -127,6 +128,7 @@ CStoredCar CGarages::aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_
int32 hGarages = AEHANDLE_NONE;
CGarage CGarages::aGarages[NUM_GARAGES];
bool CGarages::bCamShouldBeOutisde;
uint8 CGarages::CrusherRewardMultiplier;
#ifndef MASTER
bool bPrintNearestObject;
@ -137,6 +139,7 @@ void CGarages::Init(void)
#ifndef MASTER
VarConsole.Add("Print nearest object", &bPrintNearestObject, true);
#endif
CrusherRewardMultiplier = 1;
CrushedCarId = -1;
NumGarages = 0;
MessageEndTime = 0;
@ -217,7 +220,7 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
pGarage->m_fSupX = Max(Max(X1, X2), X3);
pGarage->m_fInfY = Min(Min(Min(Y1, Y2), Y3), Y2 + Y3 - Y1);
pGarage->m_fSupY = Max(Max(Y1, Y2), Y3);
pGarage->m_vecCorner1 = CVector(X1, Y1, Z1);
pGarage->m_vecCorner1 = CVector2D(X1, Y1);
pGarage->m_fInfZ = Z1;
pGarage->m_vDir1 = CVector2D(X2 - X1, Y2 - Y1);
pGarage->m_vDir2 = CVector2D(X3 - X1, Y3 - Y1);
@ -235,6 +238,22 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
pGarage->m_bRecreateDoorOnNextRefresh = false;
pGarage->m_bRotatedDoor = false;
pGarage->m_bCameraFollowsPlayer = false;
pGarage->m_nTimeToStartAction = 0;
pGarage->field_2 = false;
pGarage->m_nTargetModelIndex = targetId;
pGarage->m_bCollectedCarsState = 0;
pGarage->m_bDeactivated = false;
pGarage->m_bResprayHappened = false;
pGarage->m_bInitialized = false;
pGarage->field_F0 = 0;
pGarage->field_FC = 0;
pGarage->m_bInitialized = InitDoorGubbins(NumGarages, type);
return NumGarages++;
}
bool CGarages::InitDoorGubbins(uint32 id, uint8 type)
{
CGarage* pGarage = &aGarages[id];
pGarage->RefreshDoorPointers(true);
if (pGarage->m_pDoor1) {
pGarage->m_fDoor1Z = pGarage->m_pDoor1->GetPosition().z;
@ -249,12 +268,6 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
pGarage->m_fDoorHeight = pGarage->m_pDoor1 ? FindDoorHeightForMI(pGarage->m_pDoor1->GetModelIndex()) : 4.0f;
pGarage->m_fDoorPos = 0.0f;
pGarage->m_eGarageState = GS_FULLYCLOSED;
pGarage->m_nTimeToStartAction = 0;
pGarage->field_2 = false;
pGarage->m_nTargetModelIndex = targetId;
pGarage->m_bCollectedCarsState = 0;
pGarage->m_bDeactivated = false;
pGarage->m_bResprayHappened = false;
switch (type) {
case GARAGE_MISSION:
case GARAGE_COLLECTORSITEMS:
@ -263,7 +276,6 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
case GARAGE_COLLECTCARS_2:
case GARAGE_COLLECTCARS_3:
case GARAGE_FORCARTOCOMEOUTOF:
case GARAGE_60SECONDS:
case GARAGE_MISSION_KEEPCAR:
case GARAGE_FOR_SCRIPT_TO_OPEN:
case GARAGE_HIDEOUT_ONE:
@ -290,6 +302,7 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
case GARAGE_BOMBSHOP2:
case GARAGE_BOMBSHOP3:
case GARAGE_RESPRAY:
case GARAGE_60SECONDS:
pGarage->m_eGarageState = GS_OPENED;
pGarage->m_fDoorPos = pGarage->m_fDoorHeight;
break;
@ -304,7 +317,16 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
pGarage->UpdateCrusherAngle();
else
pGarage->UpdateDoorsHeight();
return NumGarages++;
return pGarage->m_fDoorHeight > 0.0f;
}
void CGarages::SetupAnyGaragesForThisIsland(void)
{
for (int i = 0; i < NumGarages; i++) {
CGarage* pGarage = &aGarages[i];
if (!pGarage->m_bInitialized)
pGarage->m_bInitialized = InitDoorGubbins(i, pGarage->m_eGarageType);
}
}
void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi)
@ -315,6 +337,21 @@ void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi)
pGarage->m_eGarageState = GS_FULLYCLOSED;
}
void CGarages::LockGarage(int16 garage, bool state)
{
CGarage* pGarage = &aGarages[garage];
pGarage->m_bLocked = state;
if (pGarage->m_bLocked) {
pGarage->m_fDoorPos = 0.0f;
pGarage->m_eGarageState = GS_FULLYCLOSED;
pGarage->m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + 2000;
pGarage->UpdateDoorsHeight();
}
else {
pGarage->m_eGarageState = GS_OPENING;
}
}
void CGarage::Update()
{
if (m_eGarageType != GARAGE_CRUSHER) {
@ -354,7 +391,7 @@ void CGarage::Update()
if (m_bDeactivated && m_eGarageState == GS_FULLYCLOSED)
return;
if (m_bRotatedDoor) {
#ifdef GTA_PS2
#if defined GTA_PS2 || defined GTA_PSP
if (m_eGarageState == GS_OPENING) {
if (m_pDoor1) {
if (FindPlayerPed()->m_pCurrentPhysSurface == m_pDoor1)
@ -438,7 +475,10 @@ void CGarage::Update()
#else
if (FindPlayerVehicle())
#endif
{
((CAutomobile*)(FindPlayerVehicle()))->m_fFireBlowUpTimer = 0.0f;
FindPlayerVehicle()->m_bGarageTurnedLightsOff = true;
}
CWorld::CallOffChaseForArea(
m_fInfX - DISTANCE_TO_CALL_OFF_CHASE,
m_fInfY - DISTANCE_TO_CALL_OFF_CHASE,
@ -446,6 +486,7 @@ void CGarage::Update()
m_fSupY + DISTANCE_TO_CALL_OFF_CHASE);
break;
case GS_FULLYCLOSED:
m_fDoorPos = 0.0f;
if (CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction) {
m_eGarageState = GS_OPENING;
DMAudio.PlayFrontEndSound(SOUND_GARAGE_OPENING, 1);
@ -480,11 +521,8 @@ void CGarage::Update()
FindPlayerVehicle()->GetRight() = -FindPlayerVehicle()->GetRight();
}
bChangedColour = false;
#ifdef FIX_BUGS
if (!FindPlayerVehicle()->IsCar() || !((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) {
#else
if (!((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) {
#endif
if ((!FindPlayerVehicle()->IsCar() || !((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) &&
(!FindPlayerVehicle()->IsBike() || !((CBike*)(FindPlayerVehicle()))->bFixedColour)) {
uint8 colour1, colour2;
uint16 attempt;
FindPlayerVehicle()->GetModelInfo()->ChooseVehicleColour(colour1, colour2);
@ -497,12 +535,36 @@ void CGarage::Update()
FindPlayerVehicle()->m_currentColour1 = colour1;
FindPlayerVehicle()->m_currentColour2 = colour2;
if (bChangedColour) {
CVector vCorners[] = {
CVector(m_fInfX, m_fInfY, 0.0f), CVector(m_fInfX, m_fSupY, 0.0f),
CVector(m_fSupX, m_fInfY, 0.0f), CVector(m_fSupX, m_fSupY, 0.0f)
};
CVector vMiddles[] = {
CVector(m_fInfX + (m_fSupX - m_fInfX) / 2, m_fInfY, 0.0f), CVector(m_fInfX, m_fInfY + (m_fSupY - m_fInfY) / 2, 0.0f),
CVector(m_fInfX + (m_fSupX - m_fInfX) / 2, m_fSupY, 0.0f), CVector(m_fSupX, m_fInfY + (m_fSupY - m_fInfY) / 2, 0.0f),
};
int nClosestCornerToCamera = 0;
int nClosestMiddleToCamera = 0;
for (int i = 1; i < 4; i++) {
if ((vCorners[nClosestCornerToCamera] - TheCamera.GetPosition()).Magnitude() >
(vCorners[i] - TheCamera.GetPosition()).Magnitude())
nClosestCornerToCamera = i;
if ((vMiddles[nClosestMiddleToCamera] - TheCamera.GetPosition()).Magnitude() >
(vMiddles[i] - TheCamera.GetPosition()).Magnitude())
nClosestMiddleToCamera = i;
}
CVector vDirectionCenterToMiddle = vMiddles[nClosestMiddleToCamera] - CVector(GetGarageCenterX(), GetGarageCenterY(), 0.0f);
vDirectionCenterToMiddle.Normalise();
for (int i = 0; i < NUM_PARTICLES_IN_RESPRAY; i++) {
CVector pos;
pos.x = CGeneral::GetRandomNumberInRange(m_fInfX + 0.5f, m_fSupX - 0.5f);
pos.y = CGeneral::GetRandomNumberInRange(m_fInfY + 0.5f, m_fSupY - 0.5f);
pos.z = CGeneral::GetRandomNumberInRange(m_fDoor1Z - 3.0f, m_fDoor1Z + 1.0f);
CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, CVehicleModelInfo::ms_vehicleColourTable[colour1]);
CVector pos(vMiddles[nClosestMiddleToCamera] - vDirectionCenterToMiddle * 0.5f);
CVector dir(CrossProduct(vDirectionCenterToMiddle, CVector(0.0f, 0.0f, 1.0f)));
float fDirMultiplier = (vCorners[nClosestCornerToCamera] - vMiddles[nClosestMiddleToCamera]).Magnitude();
pos += dir * CGeneral::GetRandomNumberInRange(-1.0f, 1.0f) * fDirMultiplier; // TODO: base::RandomReal?
pos += vDirectionCenterToMiddle * CGeneral::GetRandomNumberInRange(-6.0f, 0.4f);
dir = vDirectionCenterToMiddle * 0.04f;
pos.z = m_fInfZ + CGeneral::GetRandomNumberInRange(-0.4f, 0.0f);
CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, dir, nil, 0.0f, CVehicleModelInfo::ms_vehicleColourTable[colour1]); // TODO: mspInfo
}
}
}
@ -512,8 +574,11 @@ void CGarage::Update()
if (!CGarages::RespraysAreFree) {
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - RESPRAY_PRICE);
CStats::AutoPaintingBudget += RESPRAY_PRICE;
CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you!
}
else {
CGarages::TriggerMessage("GA_17", -1, 4000, -1);
}
CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you!
}
else if (bChangedColour) {
if (CGeneral::GetRandomTrueFalse())
@ -538,6 +603,8 @@ void CGarage::Update()
UpdateDoorsHeight();
break;
case GS_OPENEDCONTAINSCAR:
if (FindPlayerVehicle())
FindPlayerVehicle()->m_bGarageTurnedLightsOff = false;
if (IsPlayerOutsideGarage())
m_eGarageState = GS_OPENED;
break;
@ -550,9 +617,18 @@ void CGarage::Update()
case GARAGE_BOMBSHOP1:
case GARAGE_BOMBSHOP2:
case GARAGE_BOMBSHOP3:
if (m_bLocked)
break;
switch (m_eGarageState) {
case GS_OPENED:
UpdateDoorsHeight();
if (IsStaticPlayerCarEntirelyInside()) {
if (FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE) {
CGarages::TriggerMessage("GA_22", -1, 4000, -1);
m_eGarageState = GS_OPENEDCONTAINSCAR;
DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1);
break;
}
if (!FindPlayerVehicle() || FindPlayerVehicle()->m_bombType) {
CGarages::TriggerMessage("GA_5", -1, 4000, -1); //"Your car is already fitted with a bomb"
m_eGarageState = GS_OPENEDCONTAINSCAR;
@ -579,6 +655,8 @@ void CGarage::Update()
m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_SETUP_BOMB;
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
}
if (FindPlayerVehicle())
FindPlayerVehicle()->m_bGarageTurnedLightsOff = true;
UpdateDoorsHeight();
if (m_eGarageType == GARAGE_BOMBSHOP3)
CStreaming::RequestModel(MI_BOMB, STREAMFLAGS_DONT_REMOVE);
@ -595,13 +673,25 @@ void CGarage::Update()
if (!CGarages::BombsAreFree)
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - BOMB_PRICE);
if (FindPlayerVehicle() && (FindPlayerVehicle()->IsCar() || FindPlayerVehicle()->IsBike())) {
#if (!defined GTA_PS2 || defined FIX_BUGS)
#if (!defined GTA_PS2 || defined FIX_BUGS) // <- this remained in CAutomobile in LCS
FindPlayerVehicle()->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType);
FindPlayerVehicle()->m_pBombRigger = FindPlayerPed();
#else // PS2 version contained a bug: CBike was casted to CAutomobile, but due to coincidence it didn't corrupt memory
((CAutomobile*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType);
((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed();
#endif
// what is this
uint32 i = CPools::GetVehiclePool()->GetSize();
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (pVehicle) {
if (pVehicle->IsCar() && pVehicle->GetStatus() == STATUS_WRECKED) {
CAutomobile* pCar = (CAutomobile*)pVehicle;
pCar->m_pBombRigger = nil;
pCar->m_pBlowUpEntity = nil;
}
}
}
if (m_eGarageType == GARAGE_BOMBSHOP3)
CGarages::GivePlayerDetonator();
CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
@ -640,6 +730,7 @@ void CGarage::Update()
CHud::SetHelpMessage(TheText.Get("GA_8"), false); // Use the detonator to activate the bomb.
break;
}
CGarages::TriggerMessage(CGarages::BombsAreFree ? "GA_24" : "GA_23", -1, 4000, -1);
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
}
@ -657,6 +748,8 @@ void CGarage::Update()
UpdateDoorsHeight();
break;
case GS_OPENEDCONTAINSCAR:
if (FindPlayerVehicle())
FindPlayerVehicle()->m_bGarageTurnedLightsOff = false;
if (IsPlayerOutsideGarage())
m_eGarageState = GS_OPENED;
break;
@ -670,16 +763,12 @@ void CGarage::Update()
switch (m_eGarageState) {
case GS_OPENED:
if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE)) {
if ((CTimer::GetFrameCounter() & 0x1F) == 0
#ifndef GTA_PS2
&& (!m_pTarget || IsEntityTouching3D(m_pTarget))
#endif
) {
if ((CTimer::GetFrameCounter() & 0x1F) == 0 && !IsAnyOtherCarTouchingGarage(nil)) {
m_eGarageState = GS_CLOSING;
m_bClosingWithoutTargetCar = true;
}
}
else if (!FindPlayerVehicle() && m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) &&
else if (m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) &&
IsEntityEntirelyOutside(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 2.0f)) {
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
@ -691,7 +780,11 @@ void CGarage::Update()
if (m_pTarget)
ThrowCarsNearDoorOutOfGarage(m_pTarget);
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
if (!IsEntityEntirelyOutside(FindPlayerPed(), 1.0f)) {
printf("FIX FOR IE GARAGE TRAPPING PLAYER\n");
m_eGarageState = GS_OPENING;
}
else if (m_fDoorPos == 0.0f) {
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
if (m_bClosingWithoutTargetCar)
m_eGarageState = GS_FULLYCLOSED;
@ -787,22 +880,21 @@ void CGarage::Update()
UpdateDoorsHeight();
break;
case GS_FULLYCLOSED:
if (CTheScripts::IsPlayerOnAMission()) {
m_pTarget = nil;
break;
}
if (IsEntityEntirelyOutside(FindPlayerPed(), 0.0f)) {
printf("FIX FOR IE GARAGE TRAPPING PLAYER\n");
m_eGarageState = GS_OPENING;
}
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_eGarageState = GS_OPENING;
}
}
m_pTarget = nil;
@ -838,6 +930,7 @@ void CGarage::Update()
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
}
UpdateDoorsHeight();
if (!IsGarageEmpty())
m_eGarageState = GS_OPENING;
break;
@ -858,6 +951,7 @@ void CGarage::Update()
break;
}
break;
case GARAGE_60SECONDS:
case GARAGE_CRUSHER:
{
// for now version from III
@ -870,9 +964,10 @@ void CGarage::Update()
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle)
continue;
if (pVehicle->IsCar() && IsEntityEntirelyInside3D(pVehicle, 0.0f)) {
m_eGarageState = GS_CLOSING;
if ((pVehicle->IsCar() || pVehicle->IsBike()) && IsEntityEntirelyInside3D(pVehicle, 0.0f)) {
m_eGarageState = GS_WAITINGFORCAR;
m_pTarget = pVehicle;
m_nTimeCrusherCraneActivated = CTimer::GetTimeInMilliseconds();
m_pTarget->RegisterReference((CEntity**)&m_pTarget);
}
}
@ -892,9 +987,10 @@ void CGarage::Update()
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;
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward * CGarages::CrusherRewardMultiplier;
CMessages::AddMessageWithNumber(TheText.Get("CRUSHED"), 5000, 1, reward* CGarages::CrusherRewardMultiplier, -1, -1, -1, -1, -1);
DestroyVehicleAndDriverAndPassengers(m_pTarget);
//++CStats::CarsCrushed;
//++CStats::CarsCrushed; // TODO
m_pTarget = nil;
m_eGarageState = GS_AFTERDROPOFF;
m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_CRUSH_CAR;
@ -922,9 +1018,12 @@ void CGarage::Update()
}
UpdateCrusherAngle();
break;
//case GS_FULLYCLOSED:
//case GS_CLOSEDCONTAINSCAR:
//case GS_OPENEDCONTAINSCAR:
case GS_WAITINGFORCAR:
if (m_pTarget) {
if (CTimer::GetTimeInMilliseconds() - m_nTimeCrusherCraneActivated > 3000)
m_eGarageState = GS_CLOSING;
}
break;
default:
break;
}
@ -1089,7 +1188,10 @@ void CGarage::Update()
break;
case GS_FULLYCLOSED:
{
float distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y);
float distance = INFINITY;
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed) {
distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y);
}
if (distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_ON_FOOT) ||
distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_IN_CAR) && FindPlayerVehicle()) {
if (FindPlayerVehicle() && CGarages::CountCarsInHideoutGarage(m_eGarageType) >= FindMaxNumStoredCarsForGarage()) {
@ -1273,6 +1375,7 @@ bool CGarage::IsPointInsideGarage(CVector pos, float m_fMargin)
bool CGarage::IsEntityEntirelyInside3D(CEntity* pEntity, float fMargin)
{
// TODO: hack for GARAGE_60SECONDS
if (pEntity->GetPosition().x < m_fInfX - fMargin || pEntity->GetPosition().x > m_fSupX + fMargin ||
pEntity->GetPosition().y < m_fInfY - fMargin || pEntity->GetPosition().y > m_fSupY + fMargin ||
pEntity->GetPosition().z < m_fInfZ - fMargin || pEntity->GetPosition().z > m_fSupZ + fMargin)

View file

@ -15,6 +15,7 @@ enum eGarageState
GS_OPENEDCONTAINSCAR,
GS_CLOSEDCONTAINSCAR,
GS_AFTERDROPOFF,
GS_WAITINGFORCAR
};
enum eGarageType
@ -121,6 +122,7 @@ public:
float m_fSupX;
float m_fInfY;
float m_fSupY;
uint32 m_nTimeCrusherCraneActivated;
float m_fDoorPos;
float m_fDoorHeight;
float m_fDoor1X;
@ -133,6 +135,11 @@ public:
uint8 m_bCollectedCarsState;
CVehicle *m_pTarget;
CStoredCar m_sStoredCar; // not needed
bool m_bInitialized;
uint32 field_F0;
bool m_bLocked;
uint32 field_F8;
uint32 field_FC;
void OpenThisGarage();
void CloseThisGarage();
@ -219,6 +226,7 @@ public:
static CGarage aGarages[NUM_GARAGES];
static CStoredCar aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_CARS];
static bool bCamShouldBeOutisde;
static uint8 CrusherRewardMultiplier;
static void Init(void);
#ifndef PS2
@ -297,6 +305,8 @@ public:
}
static bool IsThisGarageTypeSafehouse(uint8 type) { return FindSafeHouseIndexForGarageType(type) >= 0; }
static void SetupAnyGaragesForThisIsland(void) {} // TODO(LCS)
static bool InitDoorGubbins(uint32, uint8);
static void SetupAnyGaragesForThisIsland(void);
static void LockGarage(int16, bool);
};

View file

@ -7,6 +7,7 @@
#include "DMAudio.h"
#include "Frontend.h"
#include "GameLogic.h"
#include "Garages.h"
#include "General.h"
#include "Hud.h"
#include "Messages.h"
@ -286,7 +287,7 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command)
return 0;
case COMMAND_LOCK_GARAGE:
CollectParameters(&m_nIp, 2);
// CGarages::LockGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
CGarages::LockGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
return 0;
case COMMAND_IS_FINAL_GAME:
#ifdef FINAL

View file

@ -1225,6 +1225,10 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
if (pVehicle->m_vehType == VEHICLE_TYPE_CAR)
#endif
((CAutomobile*)pVehicle)->bFixedColour = (GET_INTEGER_PARAM(1) == 0);
#ifdef FIX_BUGS
else if (pVehicle->m_vehType == VEHICLE_TYPE_BIKE)
((CBike*)pVehicle)->bFixedColour = (GET_INTEGER_PARAM(1) == 0);
#endif
return 0;
}

View file

@ -134,6 +134,8 @@ CBike::CBike(int32 id, uint8 CreatedBy)
bIsOnFire = false;
bWheelieCam = false;
bFixedColour = false; // <- figure out actual place (TODO)
m_fTireTemperature = 1.0f;
m_fBrakeDestabilization = 0.0f;
m_fVelocityChangeForAudio = 0;

View file

@ -75,6 +75,7 @@ public:
uint8 bExtraSpeed : 1; // leaning forward
uint8 bIsOnFire : 1;
uint8 bWheelieCam : 1;
uint8 bFixedColour : 1; // <- figure out its actual place (TODO)
int16 m_doingBurnout;
float m_fTireTemperature;
float m_fBrakeDestabilization;

View file

@ -133,6 +133,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
bCreatedAsPoliceVehicle = false;
bRestingOnPhysical = false;
bParking = false;
m_bGarageTurnedLightsOff = false;
bCanPark = CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < 0.0f; // never true. probably doesn't work very well
bIsVan = false;
bIsBus = false;

View file

@ -251,6 +251,7 @@ public:
uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default)
int8 m_nPacManPickupsCarried;
uint8 m_nRoadblockType;
bool m_bGarageTurnedLightsOff;
float m_fHealth; // 1000.0f = full health. 250.0f = fire. 0 -> explode
float m_fEngineEnergy; // TODO(LCS): better name. it adds up acceleration force, so possibly kinetic energy??
uint8 m_nCurrentGear;