more garages
This commit is contained in:
parent
38c2f8fbb0
commit
0db35f8275
@ -74,6 +74,8 @@
|
|||||||
|
|
||||||
// Collect cars stuff
|
// Collect cars stuff
|
||||||
#define MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE (0.03f)
|
#define MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE (0.03f)
|
||||||
|
#define IMPORT_REWARD (1000)
|
||||||
|
#define IMPORT_ALLCARS_REWARD (200000)
|
||||||
|
|
||||||
// Crusher stuff
|
// Crusher stuff
|
||||||
#define CRUSHER_VEHICLE_TEST_SPAN (8)
|
#define CRUSHER_VEHICLE_TEST_SPAN (8)
|
||||||
@ -88,27 +90,34 @@
|
|||||||
#define HIDEOUT_DOOR_SPEED_COEFFICIENT (1.7f)
|
#define HIDEOUT_DOOR_SPEED_COEFFICIENT (1.7f)
|
||||||
#define TIME_BETWEEN_HIDEOUT_MESSAGES (18000)
|
#define TIME_BETWEEN_HIDEOUT_MESSAGES (18000)
|
||||||
|
|
||||||
int32 &CGarages::BankVansCollected = *(int32 *)0x8F1B34;
|
const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLLECTCARS_CARS] =
|
||||||
bool &CGarages::BombsAreFree = *(bool *)0x95CD7A;
|
{
|
||||||
bool &CGarages::RespraysAreFree = *(bool *)0x95CD1D;
|
{ MI_SECURICA, MI_MOONBEAM, MI_COACH, MI_FLATBED, MI_LINERUN, MI_TRASH, MI_PATRIOT, MI_MRWHOOP, MI_BLISTA, MI_MULE, MI_YANKEE, MI_BOBCAT, MI_DODO, MI_BUS, MI_RUMPO, MI_PONY },
|
||||||
int32 &CGarages::CarsCollected = *(int32 *)0x880E18;
|
{ MI_SENTINEL, MI_CHEETAH, MI_BANSHEE, MI_IDAHO, MI_INFERNUS, MI_TAXI, MI_KURUMA, MI_STRETCH, MI_PEREN, MI_STINGER, MI_MANANA, MI_LANDSTAL, MI_STALLION, MI_BFINJECT, MI_CABBIE, MI_ESPERANT },
|
||||||
int32 (&CGarages::CarTypesCollected)[TOTAL_COLLECTCARS_GARAGES] = *(int32 (*)[TOTAL_COLLECTCARS_GARAGES])*(uintptr*)0x8E286C;
|
{ MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }
|
||||||
int32 &CGarages::CrushedCarId = *(int32 *)0x943060;
|
};
|
||||||
uint32 &CGarages::LastTimeHelpMessage = *(uint32 *)0x8F1B58;
|
|
||||||
int32 &CGarages::MessageNumberInString = *(int32 *)0x885BA8;
|
int32& CGarages::BankVansCollected = *(int32*)0x8F1B34;
|
||||||
const char *CGarages::MessageIDString = (const char *)0x878358;
|
bool& CGarages::BombsAreFree = *(bool*)0x95CD7A;
|
||||||
int32 &CGarages::MessageNumberInString2 = *(int32 *)0x8E2C14;
|
bool& CGarages::RespraysAreFree = *(bool*)0x95CD1D;
|
||||||
uint32 &CGarages::MessageStartTime = *(uint32 *)0x8F2530;
|
int32& CGarages::CarsCollected = *(int32*)0x880E18;
|
||||||
uint32 &CGarages::MessageEndTime = *(uint32 *)0x8F597C;
|
int32(&CGarages::CarTypesCollected)[TOTAL_COLLECTCARS_GARAGES] = *(int32(*)[TOTAL_COLLECTCARS_GARAGES]) * (uintptr*)0x8E286C;
|
||||||
uint32 &CGarages::NumGarages = *(uint32 *)0x8F29F4;
|
int32& CGarages::CrushedCarId = *(int32*)0x943060;
|
||||||
bool &CGarages::PlayerInGarage = *(bool *)0x95CD83;
|
uint32& CGarages::LastTimeHelpMessage = *(uint32*)0x8F1B58;
|
||||||
int32 &CGarages::PoliceCarsCollected = *(int32 *)0x941444;
|
int32& CGarages::MessageNumberInString = *(int32*)0x885BA8;
|
||||||
uint32 &CGarages::GarageToBeTidied = *(uint32 *)0x623570;
|
char(&CGarages::MessageIDString)[8] = *(char(*)[8]) * (uintptr*)0x878358;
|
||||||
CStoredCar(&CGarages::aCarsInSafeHouse1)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS])*(uintptr*)0x6FA210;
|
int32& CGarages::MessageNumberInString2 = *(int32*)0x8E2C14;
|
||||||
CStoredCar(&CGarages::aCarsInSafeHouse2)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS])*(uintptr*)0x6FA300;
|
uint32& CGarages::MessageStartTime = *(uint32*)0x8F2530;
|
||||||
CStoredCar(&CGarages::aCarsInSafeHouse3)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS])*(uintptr*)0x6FA3F0;
|
uint32& CGarages::MessageEndTime = *(uint32*)0x8F597C;
|
||||||
|
uint32& CGarages::NumGarages = *(uint32*)0x8F29F4;
|
||||||
|
bool& CGarages::PlayerInGarage = *(bool*)0x95CD83;
|
||||||
|
int32& CGarages::PoliceCarsCollected = *(int32*)0x941444;
|
||||||
|
uint32& CGarages::GarageToBeTidied = *(uint32*)0x623570;
|
||||||
|
CStoredCar(&CGarages::aCarsInSafeHouse1)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS]) * (uintptr*)0x6FA210;
|
||||||
|
CStoredCar(&CGarages::aCarsInSafeHouse2)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS]) * (uintptr*)0x6FA300;
|
||||||
|
CStoredCar(&CGarages::aCarsInSafeHouse3)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS]) * (uintptr*)0x6FA3F0;
|
||||||
int32& CGarages::AudioEntity = *(int32*)0x5ECEA8;
|
int32& CGarages::AudioEntity = *(int32*)0x5ECEA8;
|
||||||
CGarage(&CGarages::aGarages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])*(uintptr*)0x72BCD0;
|
CGarage(&CGarages::aGarages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES]) * (uintptr*)0x72BCD0;
|
||||||
bool& CGarages::bCamShouldBeOutisde = *(bool*)0x95CDB2;
|
bool& CGarages::bCamShouldBeOutisde = *(bool*)0x95CDB2;
|
||||||
|
|
||||||
void CGarages::Init(void)
|
void CGarages::Init(void)
|
||||||
@ -167,7 +176,7 @@ void CGarages::Update(void)
|
|||||||
}
|
}
|
||||||
if ((CTimer::GetFrameCounter() & 0xF) != 0xC)
|
if ((CTimer::GetFrameCounter() & 0xF) != 0xC)
|
||||||
return;
|
return;
|
||||||
if (++GarageToBeTidied >= 32)
|
if (++GarageToBeTidied >= NUM_GARAGES)
|
||||||
GarageToBeTidied = 0;
|
GarageToBeTidied = 0;
|
||||||
if (!aGarages[GarageToBeTidied].IsUsed())
|
if (!aGarages[GarageToBeTidied].IsUsed())
|
||||||
return;
|
return;
|
||||||
@ -313,12 +322,14 @@ void CGarage::Update()
|
|||||||
m_eGarageState = GS_CLOSING;
|
m_eGarageState = GS_CLOSING;
|
||||||
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
|
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
|
||||||
FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
|
FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
CGarages::TriggerMessage("GA_3", -1, 4000, -1); // No more freebies. $1000 to respray!
|
CGarages::TriggerMessage("GA_3", -1, 4000, -1); // No more freebies. $1000 to respray!
|
||||||
m_eGarageState = GS_OPENEDCONTAINSCAR;
|
m_eGarageState = GS_OPENEDCONTAINSCAR;
|
||||||
DMAudio.PlayFrontEndSound(SOUND_GARAGE_NO_MONEY, 1);
|
DMAudio.PlayFrontEndSound(SOUND_GARAGE_NO_MONEY, 1);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
CGarages::TriggerMessage("GA_1", -1, 4000, -1); // Whoa! I don't touch nothing THAT hot!
|
CGarages::TriggerMessage("GA_1", -1, 4000, -1); // Whoa! I don't touch nothing THAT hot!
|
||||||
m_eGarageState = GS_OPENEDCONTAINSCAR;
|
m_eGarageState = GS_OPENEDCONTAINSCAR;
|
||||||
DMAudio.PlayFrontEndSound(SOUND_GARAGE_BAD_VEHICLE, 1);
|
DMAudio.PlayFrontEndSound(SOUND_GARAGE_BAD_VEHICLE, 1);
|
||||||
@ -839,13 +850,13 @@ void CGarage::Update()
|
|||||||
case GS_CLOSING:
|
case GS_CLOSING:
|
||||||
if (m_pTarget) {
|
if (m_pTarget) {
|
||||||
m_fDoorPos = max(0.0f, m_fDoorPos - CRUSHER_CRANE_SPEED * CTimer::GetTimeStep());
|
m_fDoorPos = max(0.0f, m_fDoorPos - CRUSHER_CRANE_SPEED * CTimer::GetTimeStep());
|
||||||
if (m_fDoorPos < TWOPI/5) {
|
if (m_fDoorPos < TWOPI / 5) {
|
||||||
m_pTarget->bUsesCollision = false;
|
m_pTarget->bUsesCollision = false;
|
||||||
m_pTarget->bAffectedByGravity = false;
|
m_pTarget->bAffectedByGravity = false;
|
||||||
m_pTarget->SetMoveSpeed(0.0f, 0.0f, 0.0f);
|
m_pTarget->SetMoveSpeed(0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_pTarget->SetMoveSpeed(m_pTarget->GetMoveSpeed()* Pow(0.8f, CTimer::GetTimeStep()));
|
m_pTarget->SetMoveSpeed(m_pTarget->GetMoveSpeed() * Pow(0.8f, CTimer::GetTimeStep()));
|
||||||
}
|
}
|
||||||
if (m_fDoorPos == 0.0f) {
|
if (m_fDoorPos == 0.0f) {
|
||||||
CGarages::CrushedCarId = CPools::GetVehiclePool()->GetIndex(m_pTarget);
|
CGarages::CrushedCarId = CPools::GetVehiclePool()->GetIndex(m_pTarget);
|
||||||
@ -1025,15 +1036,9 @@ void CGarage::Update()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GS_CLOSING:
|
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 : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
|
|
||||||
#else
|
|
||||||
m_fDoorPos = max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
|
m_fDoorPos = max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
|
||||||
if (!IsPlayerOutsideGarage())
|
if (!IsPlayerOutsideGarage())
|
||||||
m_eGarageState = GS_OPENING;
|
m_eGarageState = GS_OPENING;
|
||||||
#endif
|
|
||||||
else if (m_fDoorPos == 0.0f) {
|
else if (m_fDoorPos == 0.0f) {
|
||||||
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
|
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
|
||||||
m_eGarageState = GS_FULLYCLOSED;
|
m_eGarageState = GS_FULLYCLOSED;
|
||||||
@ -1138,21 +1143,284 @@ void CGarage::Update()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsStaticPlayerCarEntirelyInside()
|
||||||
|
{
|
||||||
|
if (!FindPlayerVehicle())
|
||||||
|
return false;
|
||||||
|
if (!FindPlayerVehicle()->IsCar())
|
||||||
|
return false;
|
||||||
|
if (FindPlayerPed()->GetPedState() != PED_DRIVING)
|
||||||
|
return false;
|
||||||
|
if (FindPlayerPed()->m_objective == OBJECTIVE_LEAVE_VEHICLE)
|
||||||
|
return false;
|
||||||
|
CVehicle* pVehicle = FindPlayerVehicle();
|
||||||
|
if (pVehicle->GetPosition().x < m_fX1)
|
||||||
|
return false;
|
||||||
|
if (pVehicle->GetPosition().x > m_fX2)
|
||||||
|
return false;
|
||||||
|
if (pVehicle->GetPosition().y < m_fY1)
|
||||||
|
return false;
|
||||||
|
if (pVehicle->GetPosition().y > m_fY2)
|
||||||
|
return false;
|
||||||
|
if (Abs(pVehicle->GetSpeed().x) > 0.01f)
|
||||||
|
return false;
|
||||||
|
if (Abs(pVehicle->GetSpeed().y) > 0.01f)
|
||||||
|
return false;
|
||||||
|
if (Abs(pVehicle->GetSpeed().z) > 0.01f)
|
||||||
|
return false;
|
||||||
|
if (pVehicle->GetSpeed().MagnitudeSqr() > SQR(0.01f))
|
||||||
|
return false;
|
||||||
|
return IsEntityEntirelyInside3D(pVehicle, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER bool CGarage::IsStaticPlayerCarEntirelyInside() { EAXJMP(0x4251C0); }
|
bool CGarage::IsEntityEntirelyInside(CEntity * pEntity)
|
||||||
WRAPPER bool CGarage::IsEntityEntirelyInside(CEntity*) { EAXJMP(0x425370); }
|
{
|
||||||
WRAPPER bool CGarage::IsEntityEntirelyInside3D(CEntity*, float) { EAXJMP(0x4254F0); }
|
if (pEntity->GetPosition().x < m_fX1)
|
||||||
WRAPPER bool CGarage::IsEntityEntirelyOutside(CEntity*, float) { EAXJMP(0x425740); }
|
return false;
|
||||||
WRAPPER bool CGarage::IsGarageEmpty() { EAXJMP(0x425890); }
|
if (pEntity->GetPosition().x > m_fX2)
|
||||||
WRAPPER bool CGarage::IsPlayerOutsideGarage() { EAXJMP(0x425910); }
|
return false;
|
||||||
WRAPPER bool CGarage::IsEntityTouching3D(CEntity*) { EAXJMP(0x425950); }
|
if (pEntity->GetPosition().y < m_fY1)
|
||||||
WRAPPER bool CGarage::EntityHasASphereWayOutsideGarage(CEntity*, float) { EAXJMP(0x425B30); }
|
return false;
|
||||||
WRAPPER bool CGarage::IsAnyOtherCarTouchingGarage(CVehicle* pException) { EAXJMP(0x425C90); }
|
if (pEntity->GetPosition().y > m_fY2)
|
||||||
WRAPPER bool CGarage::IsAnyOtherPedTouchingGarage(CPed* pException) { EAXJMP(0x425E20); }
|
return false;
|
||||||
WRAPPER bool CGarage::IsAnyCarBlockingDoor() { EAXJMP(0x425FB0); }
|
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
|
||||||
WRAPPER int32 CGarage::CountCarsWithCenterPointWithinGarage(CEntity* pException) { EAXJMP(0x426130); }
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
WRAPPER void CGarage::RemoveCarsBlockingDoorNotInside() { EAXJMP(0x4261F0); }
|
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x - radius < m_fX1)
|
||||||
|
return false;
|
||||||
|
if (pos.x + radius > m_fX2)
|
||||||
|
return false;
|
||||||
|
if (pos.y - radius < m_fY1)
|
||||||
|
return false;
|
||||||
|
if (pos.y + radius > m_fY2)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsEntityEntirelyInside3D(CEntity * pEntity, float fMargin)
|
||||||
|
{
|
||||||
|
if (pEntity->GetPosition().x < m_fX1 - fMargin)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().x > m_fX2 + fMargin)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().y < m_fY1 - fMargin)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().y > m_fY2 + fMargin)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().z < m_fZ1 - fMargin)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().z > m_fZ2 + fMargin)
|
||||||
|
return false;
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x + radius < m_fX1 - fMargin)
|
||||||
|
return false;
|
||||||
|
if (pos.x - radius > m_fX2 + fMargin)
|
||||||
|
return false;
|
||||||
|
if (pos.y + radius < m_fY1 - fMargin)
|
||||||
|
return false;
|
||||||
|
if (pos.y - radius > m_fY2 + fMargin)
|
||||||
|
return false;
|
||||||
|
if (pos.z + radius < m_fZ1 - fMargin)
|
||||||
|
return false;
|
||||||
|
if (pos.z - radius > m_fZ2 + fMargin)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsEntityEntirelyOutside(CEntity * pEntity, float fMargin)
|
||||||
|
{
|
||||||
|
if (pEntity->GetPosition().x > m_fX1 - fMargin && pEntity->GetPosition().x < m_fX2 + fMargin &&
|
||||||
|
pEntity->GetPosition().y > m_fY1 - fMargin && pEntity->GetPosition().y < m_fY2 + fMargin)
|
||||||
|
return false;
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x + radius > m_fX1 - fMargin && pos.x - radius < m_fX2 + fMargin &&
|
||||||
|
pos.y + radius > m_fY1 - fMargin && pos.y - radius < m_fY2 + fMargin)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsGarageEmpty()
|
||||||
|
{
|
||||||
|
int16 num;
|
||||||
|
CWorld::FindObjectsIntersectingCube(CVector(m_fX1, m_fY1, m_fZ1), CVector(m_fX2, m_fY2, m_fZ2), &num, 2, nil, false, true, true, false, false);
|
||||||
|
return num == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsPlayerOutsideGarage()
|
||||||
|
{
|
||||||
|
if (FindPlayerVehicle())
|
||||||
|
return IsEntityEntirelyOutside(FindPlayerVehicle(), 0.0f);
|
||||||
|
return IsEntityEntirelyOutside(FindPlayerPed(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsEntityTouching3D(CEntity * pEntity)
|
||||||
|
{
|
||||||
|
float radius = pEntity->GetBoundRadius();
|
||||||
|
if (pEntity->GetPosition().x - radius < m_fX1)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().x + radius > m_fX2)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().y - radius < m_fY1)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().y + radius > m_fY2)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().z - radius < m_fZ1)
|
||||||
|
return false;
|
||||||
|
if (pEntity->GetPosition().z + radius > m_fZ2)
|
||||||
|
return false;
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x + radius > m_fX1 && pos.x - radius < m_fX2 &&
|
||||||
|
pos.y + radius > m_fY1 && pos.y - radius < m_fY2 &&
|
||||||
|
pos.z + radius > m_fZ1 && pos.z - radius < m_fZ2)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::EntityHasASphereWayOutsideGarage(CEntity * pEntity, float fMargin)
|
||||||
|
{
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x + radius + fMargin < m_fX1)
|
||||||
|
return true;
|
||||||
|
if (pos.x - radius - fMargin > m_fX2)
|
||||||
|
return true;
|
||||||
|
if (pos.y + radius + fMargin < m_fY1)
|
||||||
|
return true;
|
||||||
|
if (pos.y - radius - fMargin > m_fY2)
|
||||||
|
return true;
|
||||||
|
if (pos.z + radius + fMargin < m_fZ1)
|
||||||
|
return true;
|
||||||
|
if (pos.z - radius - fMargin > m_fZ2)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsAnyOtherCarTouchingGarage(CVehicle * pException)
|
||||||
|
{
|
||||||
|
uint32 i = CPools::GetVehiclePool()->GetSize();
|
||||||
|
while (i--) {
|
||||||
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
|
if (!pVehicle || pVehicle == pException)
|
||||||
|
continue;
|
||||||
|
if (!IsEntityTouching3D(pVehicle))
|
||||||
|
continue;
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pVehicle->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x + radius > m_fX1 && pos.x - radius < m_fX2 &&
|
||||||
|
pos.y + radius > m_fY1 && pos.y - radius < m_fY2 &&
|
||||||
|
pos.z + radius > m_fZ1 && pos.z - radius < m_fZ2)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsAnyOtherPedTouchingGarage(CPed * pException)
|
||||||
|
{
|
||||||
|
uint32 i = CPools::GetPedPool()->GetSize();
|
||||||
|
while (i--) {
|
||||||
|
CPed* pPed = CPools::GetPedPool()->GetSlot(i);
|
||||||
|
if (!pPed || pPed == pException)
|
||||||
|
continue;
|
||||||
|
if (!IsEntityTouching3D(pPed))
|
||||||
|
continue;
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pPed->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x + radius > m_fX1 && pos.x - radius < m_fX2 &&
|
||||||
|
pos.y + radius > m_fY1 && pos.y - radius < m_fY2 &&
|
||||||
|
pos.z + radius > m_fZ1 && pos.z - radius < m_fZ2)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::IsAnyCarBlockingDoor()
|
||||||
|
{
|
||||||
|
uint32 i = CPools::GetVehiclePool()->GetSize();
|
||||||
|
while (i--) {
|
||||||
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
|
if (!pVehicle)
|
||||||
|
continue;
|
||||||
|
if (!IsEntityTouching3D(pVehicle))
|
||||||
|
continue;
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pVehicle->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pos.x + radius < m_fX1 || pos.x - radius > m_fX2 ||
|
||||||
|
pos.y + radius < m_fY1 || pos.y - radius > m_fY2 ||
|
||||||
|
pos.z + radius < m_fZ1 || pos.z - radius > m_fZ2)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 CGarage::CountCarsWithCenterPointWithinGarage(CEntity * pException)
|
||||||
|
{
|
||||||
|
int32 total = 0;
|
||||||
|
uint32 i = CPools::GetVehiclePool()->GetSize();
|
||||||
|
while (i--) {
|
||||||
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
|
if (!pVehicle || pVehicle == pException)
|
||||||
|
continue;
|
||||||
|
if (pVehicle->GetPosition().x > m_fX1 && pVehicle->GetPosition().x < m_fX2 &&
|
||||||
|
pVehicle->GetPosition().y > m_fY1 && pVehicle->GetPosition().y < m_fY2 &&
|
||||||
|
pVehicle->GetPosition().z > m_fZ1 && pVehicle->GetPosition().z < m_fZ2)
|
||||||
|
total++;
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGarage::RemoveCarsBlockingDoorNotInside()
|
||||||
|
{
|
||||||
|
uint32 i = CPools::GetVehiclePool()->GetSize();
|
||||||
|
while (i--) {
|
||||||
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
|
if (!pVehicle)
|
||||||
|
continue;
|
||||||
|
if (!IsEntityTouching3D(pVehicle))
|
||||||
|
continue;
|
||||||
|
CColModel* pColModel = CModelInfo::GetModelInfo(pVehicle->GetModelIndex())->GetColModel();
|
||||||
|
for (int i = 0; i < pColModel->numSpheres; i++) {
|
||||||
|
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
|
||||||
|
float radius = pColModel->spheres[i].radius;
|
||||||
|
if (pVehicle->GetPosition().x < m_fX1 || pVehicle->GetPosition().x > m_fX2 ||
|
||||||
|
pVehicle->GetPosition().y < m_fY1 || pVehicle->GetPosition().y > m_fY2 ||
|
||||||
|
pVehicle->GetPosition().z < m_fZ1 || pVehicle->GetPosition().z > m_fZ2) {
|
||||||
|
if (pVehicle->bIsLocked && pVehicle->CanBeDeleted()) {
|
||||||
|
CWorld::Remove(pVehicle);
|
||||||
|
delete pVehicle;
|
||||||
|
return; // WHY?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGarages::PrintMessages()
|
void CGarages::PrintMessages()
|
||||||
{
|
{
|
||||||
@ -1166,8 +1434,11 @@ void CGarages::PrintMessages()
|
|||||||
CFont::SetFontStyle(FONT_BANK);
|
CFont::SetFontStyle(FONT_BANK);
|
||||||
CFont::SetColor(CRGBA(0, 0, 0, 255));
|
CFont::SetColor(CRGBA(0, 0, 0, 255));
|
||||||
|
|
||||||
|
#if defined(PS2) || defined (FIX_BUGS)
|
||||||
float y_offset = SCREEN_HEIGHT / 3; // THIS is PS2 calculation
|
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
|
#else
|
||||||
|
float y_offset = SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(84.0f); // This is PC and results in text being written over some HUD elements
|
||||||
|
#endif
|
||||||
|
|
||||||
if (MessageNumberInString2 < 0) {
|
if (MessageNumberInString2 < 0) {
|
||||||
if (MessageNumberInString < 0) {
|
if (MessageNumberInString < 0) {
|
||||||
@ -1195,9 +1466,50 @@ void CGarages::PrintMessages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER bool CGarages::IsCarSprayable(CVehicle*) { EAXJMP(0x426700); }
|
bool CGarages::IsCarSprayable(CVehicle * pVehicle)
|
||||||
WRAPPER void CGarage::UpdateDoorsHeight() { EAXJMP(0x426730); }
|
{
|
||||||
WRAPPER void CGarage::BuildRotatedDoorMatrix(CEntity*, float) { EAXJMP(0x4267C0); }
|
switch (pVehicle->GetModelIndex()) {
|
||||||
|
case MI_FIRETRUCK:
|
||||||
|
case MI_AMBULAN:
|
||||||
|
case MI_POLICE:
|
||||||
|
case MI_ENFORCER:
|
||||||
|
case MI_BUS:
|
||||||
|
case MI_RHINO:
|
||||||
|
case MI_BARRACKS:
|
||||||
|
case MI_DODO:
|
||||||
|
case MI_COACH:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGarage::UpdateDoorsHeight()
|
||||||
|
{
|
||||||
|
RefreshDoorPointers(false);
|
||||||
|
if (m_pDoor1) {
|
||||||
|
m_pDoor1->GetPosition().z = m_fDoorPos + m_fDoor1Z;
|
||||||
|
if (m_bRotatedDoor)
|
||||||
|
BuildRotatedDoorMatrix(m_pDoor1, m_fDoorPos / m_fDoorHeight);
|
||||||
|
m_pDoor1->GetMatrix().UpdateRW();
|
||||||
|
m_pDoor1->UpdateRwFrame();
|
||||||
|
}
|
||||||
|
if (m_pDoor2) {
|
||||||
|
m_pDoor2->GetPosition().z = m_fDoorPos + m_fDoor2Z;
|
||||||
|
if (m_bRotatedDoor)
|
||||||
|
BuildRotatedDoorMatrix(m_pDoor2, m_fDoorPos / m_fDoorHeight);
|
||||||
|
m_pDoor2->GetMatrix().UpdateRW();
|
||||||
|
m_pDoor2->UpdateRwFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGarage::BuildRotatedDoorMatrix(CEntity * pDoor, float fPosition)
|
||||||
|
{
|
||||||
|
float fAngle = -fPosition * HALFPI;
|
||||||
|
CVector r(-Sin(fAngle) * pDoor->GetForward().x, Sin(fAngle) * pDoor->GetForward().y, Cos(fAngle) * pDoor->GetForward().z);
|
||||||
|
pDoor->GetRight() = CrossProduct(r, pDoor->GetForward());
|
||||||
|
}
|
||||||
|
|
||||||
void CGarage::UpdateCrusherAngle()
|
void CGarage::UpdateCrusherAngle()
|
||||||
{
|
{
|
||||||
@ -1207,10 +1519,25 @@ void CGarage::UpdateCrusherAngle()
|
|||||||
m_pDoor2->UpdateRwFrame();
|
m_pDoor2->UpdateRwFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER void CGarage::UpdateCrusherShake(float, float) { EAXJMP(0x4268E0); }
|
void CGarage::UpdateCrusherShake(float X, float Y)
|
||||||
|
{
|
||||||
|
RefreshDoorPointers(false);
|
||||||
|
m_pDoor1->GetPosition().x += X;
|
||||||
|
m_pDoor1->GetPosition().y += Y;
|
||||||
|
m_pDoor1->GetMatrix().UpdateRW();
|
||||||
|
m_pDoor1->UpdateRwFrame();
|
||||||
|
m_pDoor1->GetPosition().x -= X;
|
||||||
|
m_pDoor1->GetPosition().y -= Y;
|
||||||
|
m_pDoor2->GetPosition().x += X;
|
||||||
|
m_pDoor2->GetPosition().y += Y;
|
||||||
|
m_pDoor2->GetMatrix().UpdateRW();
|
||||||
|
m_pDoor2->UpdateRwFrame();
|
||||||
|
m_pDoor2->GetPosition().x -= X;
|
||||||
|
m_pDoor2->GetPosition().y -= Y;
|
||||||
|
}
|
||||||
|
|
||||||
// This is dumb but there is no way to avoid goto. What was there originally even?
|
// This is dumb but there is no way to avoid goto. What was there originally even?
|
||||||
static bool DoINeedToRefreshPointer(CEntity* pDoor, bool bIsDummy, int8 nIndex)
|
static bool DoINeedToRefreshPointer(CEntity * pDoor, bool bIsDummy, int8 nIndex)
|
||||||
{
|
{
|
||||||
bool bNeedToFindDoorEntities = false;
|
bool bNeedToFindDoorEntities = false;
|
||||||
if (pDoor) {
|
if (pDoor) {
|
||||||
@ -1247,11 +1574,53 @@ void CGarage::RefreshDoorPointers(bool bCreate)
|
|||||||
FindDoorsEntities();
|
FindDoorsEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER void CGarages::TriggerMessage(const char* text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
|
void CGarages::TriggerMessage(const char* text, int16 num1, uint16 time, int16 num2)
|
||||||
WRAPPER void CGarages::SetTargetCarForMissonGarage(int16, CVehicle*) { EAXJMP(0x426BD0); }
|
{
|
||||||
WRAPPER bool CGarages::HasCarBeenDroppedOffYet(int16) { EAXJMP(0x426C20); }
|
if (strcmp(text, MessageIDString) == 0 &&
|
||||||
WRAPPER void CGarages::DeActivateGarage(int16) { EAXJMP(0x426C40); }
|
CTimer::GetTimeInMilliseconds() >= MessageStartTime &&
|
||||||
WRAPPER void CGarages::ActivateGarage(int16) { EAXJMP(0x426C60); }
|
CTimer::GetTimeInMilliseconds() <= MessageEndTime) {
|
||||||
|
if (CTimer::GetTimeInMilliseconds() - MessageStartTime <= 500)
|
||||||
|
return;
|
||||||
|
MessageStartTime = CTimer::GetTimeInMilliseconds() - 500;
|
||||||
|
MessageEndTime = CTimer::GetTimeInMilliseconds() - 500 + time;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strcpy(MessageIDString, text);
|
||||||
|
MessageStartTime = CTimer::GetTimeInMilliseconds();
|
||||||
|
MessageEndTime = CTimer::GetTimeInMilliseconds() + time;
|
||||||
|
}
|
||||||
|
MessageNumberInString = num1;
|
||||||
|
MessageNumberInString2 = num2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGarages::SetTargetCarForMissonGarage(int16 garage, CVehicle * pVehicle)
|
||||||
|
{
|
||||||
|
assert(garage >= 0 && garage < NUM_GARAGES);
|
||||||
|
if (pVehicle) {
|
||||||
|
aGarages[garage].m_pTarget = pVehicle;
|
||||||
|
if (aGarages[garage].m_eGarageState == GS_CLOSEDCONTAINSCAR)
|
||||||
|
aGarages[garage].m_eGarageState = GS_FULLYCLOSED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aGarages[garage].m_pTarget = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarages::HasCarBeenDroppedOffYet(int16 garage)
|
||||||
|
{
|
||||||
|
return aGarages[garage].m_eGarageState == GS_CLOSEDCONTAINSCAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGarages::DeActivateGarage(int16 garage)
|
||||||
|
{
|
||||||
|
aGarages[garage].m_bDeactivated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGarages::ActivateGarage(int16 garage)
|
||||||
|
{
|
||||||
|
aGarages[garage].m_bDeactivated = false;
|
||||||
|
if (aGarages[garage].m_eGarageType == GARAGE_FORCARTOCOMEOUTOF && aGarages[garage].m_eGarageState == GS_FULLYCLOSED)
|
||||||
|
aGarages[garage].m_eGarageState = GS_OPENING;
|
||||||
|
}
|
||||||
|
|
||||||
int32 CGarages::QueryCarsCollected(int16 garage)
|
int32 CGarages::QueryCarsCollected(int16 garage)
|
||||||
{
|
{
|
||||||
@ -1260,7 +1629,7 @@ int32 CGarages::QueryCarsCollected(int16 garage)
|
|||||||
|
|
||||||
bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car)
|
bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car)
|
||||||
{
|
{
|
||||||
return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType)] & (1 << car);
|
return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType)] & (BIT(car));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGarages::IsGarageOpen(int16 garage)
|
bool CGarages::IsGarageOpen(int16 garage)
|
||||||
@ -1273,10 +1642,59 @@ bool CGarages::IsGarageClosed(int16 garage)
|
|||||||
return aGarages[garage].IsClosed();
|
return aGarages[garage].IsClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) { EAXJMP(0x426D50); }
|
bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id)
|
||||||
WRAPPER bool CGarage::DoesCraigNeedThisCar(int32) { EAXJMP(0x426D90); }
|
{
|
||||||
WRAPPER bool CGarage::HasCraigCollectedThisCar(int32) { EAXJMP(0x426DF0); }
|
return aGarages[garage].m_bCollectedCarsState & BIT(id);
|
||||||
WRAPPER void CGarage::MarkThisCarAsCollectedForCraig(int32) { EAXJMP(0x426E50); }
|
}
|
||||||
|
|
||||||
|
bool CGarage::DoesCraigNeedThisCar(int32 mi)
|
||||||
|
{
|
||||||
|
if (mi == MI_CORPSE)
|
||||||
|
mi = MI_MANANA;
|
||||||
|
int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType);
|
||||||
|
for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) {
|
||||||
|
if (mi == gaCarsToCollectInCraigsGarages[ct][i])
|
||||||
|
return (CGarages::CarTypesCollected[ct] & BIT(i)) == 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::HasCraigCollectedThisCar(int32 mi)
|
||||||
|
{
|
||||||
|
if (mi == MI_CORPSE)
|
||||||
|
mi = MI_MANANA;
|
||||||
|
int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType);
|
||||||
|
for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) {
|
||||||
|
if (mi == gaCarsToCollectInCraigsGarages[ct][i])
|
||||||
|
return CGarages::CarTypesCollected[ct] & BIT(i);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGarage::MarkThisCarAsCollectedForCraig(int32 mi)
|
||||||
|
{
|
||||||
|
if (mi == MI_CORPSE)
|
||||||
|
mi = MI_MANANA;
|
||||||
|
int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType);
|
||||||
|
int index;
|
||||||
|
for (index = 0; index < TOTAL_COLLECTCARS_CARS; index++) {
|
||||||
|
if (mi == gaCarsToCollectInCraigsGarages[ct][index])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (index >= TOTAL_COLLECTCARS_CARS)
|
||||||
|
return false;
|
||||||
|
CGarages::CarTypesCollected[ct] |= BIT(index);
|
||||||
|
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_REWARD;
|
||||||
|
for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) {
|
||||||
|
if ((CGarages::CarTypesCollected[ct] & BIT(i)) == 0) {
|
||||||
|
CGarages::TriggerMessage("GA_13", -1, 5000, -1); // Delivered like a pro. Complete the list and there'll be a bonus for you.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_ALLCARS_REWARD;
|
||||||
|
CGarages::TriggerMessage("GA_14", -1, 5000, -1); // All the cars. NICE! Here's a little something.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CGarage::OpenThisGarage()
|
void CGarage::OpenThisGarage()
|
||||||
{
|
{
|
||||||
@ -1290,11 +1708,81 @@ void CGarage::CloseThisGarage()
|
|||||||
m_eGarageState = GS_CLOSING;
|
m_eGarageState = GS_CLOSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER float CGarage::CalcDistToGarageRectangleSquared(float, float) { EAXJMP(0x426F50); }
|
float CGarage::CalcDistToGarageRectangleSquared(float X, float Y)
|
||||||
WRAPPER float CGarage::CalcSmallestDistToGarageDoorSquared(float, float) { EAXJMP(0x426FE0); }
|
{
|
||||||
WRAPPER void CGarage::FindDoorsEntities() { EAXJMP(0x427060); }
|
float distX, distY;
|
||||||
|
if (X < m_fX1)
|
||||||
|
distX = m_fX1 - X;
|
||||||
|
else if (X > m_fX2)
|
||||||
|
distX = X - m_fX2;
|
||||||
|
else
|
||||||
|
distX = 0.0f;
|
||||||
|
if (Y < m_fY1)
|
||||||
|
distY = m_fY1 - X;
|
||||||
|
else if (Y > m_fY2)
|
||||||
|
distY = Y - m_fY2;
|
||||||
|
else
|
||||||
|
distY = 0.0f;
|
||||||
|
return SQR(distX) + SQR(distY);
|
||||||
|
}
|
||||||
|
|
||||||
|
float CGarage::CalcSmallestDistToGarageDoorSquared(float X, float Y)
|
||||||
|
{
|
||||||
|
float dist1 = 10000000.0f;
|
||||||
|
float dist2 = 10000000.0f;
|
||||||
|
if (m_pDoor1)
|
||||||
|
dist1 = SQR(m_fDoor1X - X) + SQR(m_fDoor1Y - Y);
|
||||||
|
if (m_pDoor2)
|
||||||
|
dist2 = SQR(m_fDoor2X - X) + SQR(m_fDoor2Y - Y);
|
||||||
|
return min(dist1, dist2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGarage::FindDoorsEntities()
|
||||||
|
{
|
||||||
|
m_pDoor1 = false;
|
||||||
|
m_pDoor2 = false;
|
||||||
|
int xstart = max(0, CWorld::GetSectorIndexX(m_fX1));
|
||||||
|
int xend = min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(m_fX2));
|
||||||
|
int ystart = max(0, CWorld::GetSectorIndexY(m_fY1));
|
||||||
|
int yend = min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(m_fY2));
|
||||||
|
assert(xstart <= xend);
|
||||||
|
assert(ystart <= yend);
|
||||||
|
|
||||||
|
CWorld::AdvanceCurrentScanCode();
|
||||||
|
|
||||||
|
for (int y = ystart; y <= yend; y++) {
|
||||||
|
for (int x = xstart; x <= xend; x++) {
|
||||||
|
CSector* s = CWorld::GetSector(x, y);
|
||||||
|
FindDoorsEntitiesSectorList(s->m_lists[ENTITYLIST_OBJECTS], false);
|
||||||
|
FindDoorsEntitiesSectorList(s->m_lists[ENTITYLIST_OBJECTS_OVERLAP], false);
|
||||||
|
FindDoorsEntitiesSectorList(s->m_lists[ENTITYLIST_DUMMIES], true);
|
||||||
|
FindDoorsEntitiesSectorList(s->m_lists[ENTITYLIST_DUMMIES_OVERLAP], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!m_pDoor1 || !m_pDoor2)
|
||||||
|
return;
|
||||||
|
if (m_pDoor1->GetModelIndex() == MI_CRUSHERBODY || m_pDoor1->GetModelIndex() == MI_CRUSHERLID)
|
||||||
|
return;
|
||||||
|
CVector2D vecDoor1ToGarage(m_pDoor1->GetPosition().x - GetGarageCenterX(), m_pDoor1->GetPosition().y - GetGarageCenterY());
|
||||||
|
CVector2D vecDoor2ToGarage(m_pDoor2->GetPosition().x - GetGarageCenterX(), m_pDoor2->GetPosition().y - GetGarageCenterY());
|
||||||
|
if (DotProduct2D(vecDoor1ToGarage, vecDoor2ToGarage) > 0.0f) {
|
||||||
|
if (vecDoor1ToGarage.MagnitudeSqr() >= vecDoor2ToGarage.MagnitudeSqr()) {
|
||||||
|
m_pDoor1 = m_pDoor2;
|
||||||
|
m_bDoor1IsDummy = m_bDoor2IsDummy;
|
||||||
|
}
|
||||||
|
m_pDoor2 = nil;
|
||||||
|
m_bDoor2IsDummy = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WRAPPER void CGarage::FindDoorsEntitiesSectorList(CPtrList&, bool) { EAXJMP(0x427300); }
|
WRAPPER void CGarage::FindDoorsEntitiesSectorList(CPtrList&, bool) { EAXJMP(0x427300); }
|
||||||
WRAPPER bool CGarages::HasResprayHappened(int16 garage) { EAXJMP(0x4274F0); }
|
|
||||||
|
bool CGarages::HasResprayHappened(int16 garage)
|
||||||
|
{
|
||||||
|
bool result = aGarages[garage].m_bResprayHappened;
|
||||||
|
aGarages[garage].m_bResprayHappened = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void CGarages::SetGarageDoorToRotate(int16 garage)
|
void CGarages::SetGarageDoorToRotate(int16 garage)
|
||||||
{
|
{
|
||||||
@ -1310,7 +1798,7 @@ void CGarages::SetLeaveCameraForThisGarage(int16 garage)
|
|||||||
aGarages[garage].m_bCameraFollowsPlayer = true;
|
aGarages[garage].m_bCameraFollowsPlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER bool CGarages::IsThisCarWithinGarageArea(int16 garage, CEntity* pCar) { EAXJMP(0x427570); }
|
WRAPPER bool CGarages::IsThisCarWithinGarageArea(int16 garage, CEntity * pCar) { EAXJMP(0x427570); }
|
||||||
|
|
||||||
bool CGarages::HasCarBeenCrushed(int32 handle)
|
bool CGarages::HasCarBeenCrushed(int32 handle)
|
||||||
{
|
{
|
||||||
@ -1342,9 +1830,9 @@ WRAPPER int32 CGarages::FindMaxNumStoredCarsForGarage(eGarageType) { EAXJMP(0x42
|
|||||||
WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector&) { EAXJMP(0x428260); }
|
WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector&) { EAXJMP(0x428260); }
|
||||||
WRAPPER bool CGarages::IsPointWithinAnyGarage(CVector&) { EAXJMP(0x428320); }
|
WRAPPER bool CGarages::IsPointWithinAnyGarage(CVector&) { EAXJMP(0x428320); }
|
||||||
WRAPPER void CGarages::SetAllDoorsBackToOriginalHeight() { EAXJMP(0x4283D0); }
|
WRAPPER void CGarages::SetAllDoorsBackToOriginalHeight() { EAXJMP(0x4283D0); }
|
||||||
WRAPPER void CGarages::Save(uint8* buf, uint32* size) { EAXJMP(0x4284E0); }
|
WRAPPER void CGarages::Save(uint8 * buf, uint32 * size) { EAXJMP(0x4284E0); }
|
||||||
|
|
||||||
CStoredCar::CStoredCar(const CStoredCar& other)
|
CStoredCar::CStoredCar(const CStoredCar & other)
|
||||||
{
|
{
|
||||||
m_nModelIndex = other.m_nModelIndex;
|
m_nModelIndex = other.m_nModelIndex;
|
||||||
m_vecPos = other.m_vecPos;
|
m_vecPos = other.m_vecPos;
|
||||||
@ -1362,7 +1850,7 @@ CStoredCar::CStoredCar(const CStoredCar& other)
|
|||||||
m_nCarBombType = other.m_nCarBombType;
|
m_nCarBombType = other.m_nCarBombType;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER void CGarages::Load(uint8* buf, uint32 size) { EAXJMP(0x428940); }
|
WRAPPER void CGarages::Load(uint8 * buf, uint32 size) { EAXJMP(0x428940); }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CGarages::IsModelIndexADoor(uint32 id)
|
CGarages::IsModelIndexADoor(uint32 id)
|
||||||
@ -1404,9 +1892,9 @@ CGarages::IsModelIndexADoor(uint32 id)
|
|||||||
|
|
||||||
|
|
||||||
STARTPATCHES
|
STARTPATCHES
|
||||||
InjectHook(0x421C60, CGarages::Init, PATCH_JUMP);
|
InjectHook(0x421C60, CGarages::Init, PATCH_JUMP);
|
||||||
#ifndef PS2
|
#ifndef PS2
|
||||||
InjectHook(0x421E10, CGarages::Shutdown, PATCH_JUMP);
|
InjectHook(0x421E10, CGarages::Shutdown, PATCH_JUMP);
|
||||||
#endif
|
#endif
|
||||||
InjectHook(0x421E40, CGarages::Update, PATCH_JUMP);
|
InjectHook(0x421E40, CGarages::Update, PATCH_JUMP);
|
||||||
ENDPATCHES
|
ENDPATCHES
|
@ -45,7 +45,8 @@ enum eGarageType : int8
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TOTAL_COLLECTCARS_GARAGES = GARAGE_COLLECTCARS_3 - GARAGE_COLLECTCARS_1 + 1
|
TOTAL_COLLECTCARS_GARAGES = GARAGE_COLLECTCARS_3 - GARAGE_COLLECTCARS_1 + 1,
|
||||||
|
TOTAL_COLLECTCARS_CARS = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
class CStoredCar
|
class CStoredCar
|
||||||
@ -151,7 +152,7 @@ public:
|
|||||||
bool IsAnyCarBlockingDoor();
|
bool IsAnyCarBlockingDoor();
|
||||||
void CenterCarInGarage(CVehicle*);
|
void CenterCarInGarage(CVehicle*);
|
||||||
bool DoesCraigNeedThisCar(int32);
|
bool DoesCraigNeedThisCar(int32);
|
||||||
void MarkThisCarAsCollectedForCraig(int32);
|
bool MarkThisCarAsCollectedForCraig(int32);
|
||||||
bool HasCraigCollectedThisCar(int32);
|
bool HasCraigCollectedThisCar(int32);
|
||||||
bool IsGarageEmpty();
|
bool IsGarageEmpty();
|
||||||
void UpdateCrusherShake(float, float);
|
void UpdateCrusherShake(float, float);
|
||||||
@ -181,7 +182,7 @@ public:
|
|||||||
static int32 &CrushedCarId;
|
static int32 &CrushedCarId;
|
||||||
static uint32 &LastTimeHelpMessage;
|
static uint32 &LastTimeHelpMessage;
|
||||||
static int32 &MessageNumberInString;
|
static int32 &MessageNumberInString;
|
||||||
static const char *MessageIDString;
|
static char(&MessageIDString)[8];
|
||||||
static int32 &MessageNumberInString2;
|
static int32 &MessageNumberInString2;
|
||||||
static uint32 &MessageStartTime;
|
static uint32 &MessageStartTime;
|
||||||
static uint32 &MessageEndTime;
|
static uint32 &MessageEndTime;
|
||||||
|
Loading…
Reference in New Issue
Block a user