mirror of
https://github.com/halpz/re3.git
synced 2025-06-30 09:06:19 +00:00
Restored beta police system(disabled), fixes from miami, debug info for CFO crash (#639)
This commit is contained in:
@ -381,7 +381,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
if (flatSpeed < SQR(0.018f) && CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nAntiReverseTimer > 2000){
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_REVERSE;
|
||||
if (pVehicle->AutoPilot.m_nCarMission != MISSION_NONE &&
|
||||
pVehicle->AutoPilot.m_nCarMission != MISSION_CRUISE || pVehicle->VehicleCreatedBy == RANDOM_VEHICLE)
|
||||
pVehicle->AutoPilot.m_nCarMission != MISSION_CRUISE || pVehicle->VehicleCreatedBy == MISSION_VEHICLE)
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1500;
|
||||
else
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 750;
|
||||
@ -406,7 +406,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 400;
|
||||
}
|
||||
}
|
||||
if (pVehicle->GetUp().z < 0.7f){
|
||||
if (pVehicle->GetUp().z < -0.7f){
|
||||
pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
|
||||
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000;
|
||||
}
|
||||
|
@ -34,15 +34,14 @@ CPed *CPhoneInfo::pCallBackPed; // ped who picking up the phone (reset after pic
|
||||
after 60 seconds of last phone pick-up.
|
||||
*/
|
||||
|
||||
#ifdef TOGGLEABLE_BETA_FEATURES
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
CPed* crimeReporters[NUMPHONES] = {};
|
||||
bool
|
||||
isPhoneAvailable(int m_phoneId)
|
||||
{
|
||||
return gPhoneInfo.m_aPhones[m_phoneId].m_nState == PHONE_STATE_FREE &&
|
||||
(crimeReporters[m_phoneId] == nil || !crimeReporters[m_phoneId]->IsPointerValid() || !crimeReporters[m_phoneId]->bRunningToPhone || crimeReporters[m_phoneId]->m_objective > OBJECTIVE_IDLE ||
|
||||
return crimeReporters[m_phoneId] == nil || !crimeReporters[m_phoneId]->IsPointerValid() || crimeReporters[m_phoneId]->m_objective > OBJECTIVE_IDLE ||
|
||||
crimeReporters[m_phoneId]->m_nLastPedState != PED_SEEK_POS &&
|
||||
(crimeReporters[m_phoneId]->m_nPedState != PED_MAKE_CALL && crimeReporters[m_phoneId]->m_nPedState != PED_FACE_PHONE && crimeReporters[m_phoneId]->m_nPedState != PED_SEEK_POS));
|
||||
(crimeReporters[m_phoneId]->m_nPedState != PED_MAKE_CALL && crimeReporters[m_phoneId]->m_nPedState != PED_FACE_PHONE && crimeReporters[m_phoneId]->m_nPedState != PED_SEEK_POS);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -162,13 +161,14 @@ CPhoneInfo::FindNearestFreePhone(CVector *pos)
|
||||
int nearestPhoneId = -1;
|
||||
float nearestPhoneDist = 60.0f;
|
||||
|
||||
for (int phoneId = 0; phoneId < m_nMax; phoneId++) {
|
||||
for (int phoneId = 0; phoneId < m_nMax; phoneId++) {
|
||||
|
||||
if (gPhoneInfo.m_aPhones[phoneId].m_nState == PHONE_STATE_FREE
|
||||
#ifdef TOGGLEABLE_BETA_FEATURES
|
||||
&& isPhoneAvailable(phoneId)
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
if (isPhoneAvailable(phoneId))
|
||||
#else
|
||||
if (gPhoneInfo.m_aPhones[phoneId].m_nState == PHONE_STATE_FREE)
|
||||
#endif
|
||||
) {
|
||||
{
|
||||
float phoneDist = (m_aPhones[phoneId].m_vecPos - *pos).Magnitude2D();
|
||||
|
||||
if (phoneDist < nearestPhoneDist) {
|
||||
@ -213,8 +213,42 @@ void
|
||||
CPhoneInfo::Load(uint8 *buf, uint32 size)
|
||||
{
|
||||
INITSAVEBUF
|
||||
m_nMax = ReadSaveBuf<int32>(buf);
|
||||
m_nScriptPhonesMax = ReadSaveBuf<int32>(buf);
|
||||
int max = ReadSaveBuf<int32>(buf);
|
||||
int scriptPhonesMax = ReadSaveBuf<int32>(buf);
|
||||
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
m_nMax = Min(NUMPHONES, max);
|
||||
m_nScriptPhonesMax = 0;
|
||||
|
||||
bool ignoreOtherPhones = false;
|
||||
|
||||
// We can do it without touching saves. We'll only load script phones, others are already loaded in Initialise
|
||||
for (int i = 0; i < 50; i++) {
|
||||
CPhone phoneToLoad = ReadSaveBuf<CPhone>(buf);
|
||||
|
||||
if (ignoreOtherPhones)
|
||||
continue;
|
||||
|
||||
if (i < scriptPhonesMax) {
|
||||
if (i >= m_nMax) {
|
||||
assert(0 && "Number of phones used by script exceeds the NUMPHONES or the stored phones in save file. Ignoring some phones");
|
||||
ignoreOtherPhones = true;
|
||||
continue;
|
||||
}
|
||||
SwapPhone(phoneToLoad.m_vecPos.x, phoneToLoad.m_vecPos.y, i);
|
||||
|
||||
m_aPhones[i] = phoneToLoad;
|
||||
// It's saved as building pool index in save file, convert it to true entity
|
||||
if (m_aPhones[i].m_pEntity) {
|
||||
m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1);
|
||||
}
|
||||
} else
|
||||
ignoreOtherPhones = true;
|
||||
}
|
||||
#else
|
||||
m_nMax = max;
|
||||
m_nScriptPhonesMax = scriptPhonesMax;
|
||||
|
||||
for (int i = 0; i < NUMPHONES; i++) {
|
||||
m_aPhones[i] = ReadSaveBuf<CPhone>(buf);
|
||||
// It's saved as building pool index in save file, convert it to true entity
|
||||
@ -222,6 +256,7 @@ INITSAVEBUF
|
||||
m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
VALIDATESAVEBUF(size)
|
||||
}
|
||||
|
||||
@ -259,6 +294,31 @@ CPhoneInfo::SetPhoneMessage_Repeatedly(int phoneId, wchar *msg1, wchar *msg2, wc
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
void
|
||||
CPhoneInfo::SwapPhone(float xPos, float yPos, int into)
|
||||
{
|
||||
// "into" should be in 0 - m_nScriptPhonesMax range
|
||||
int nearestPhoneId = -1;
|
||||
CVector pos(xPos, yPos, 0.0f);
|
||||
float nearestPhoneDist = 1.0f;
|
||||
|
||||
for (int phoneId = m_nScriptPhonesMax; phoneId < m_nMax; phoneId++) {
|
||||
float phoneDistance = (m_aPhones[phoneId].m_vecPos - pos).Magnitude2D();
|
||||
if (phoneDistance < nearestPhoneDist) {
|
||||
nearestPhoneDist = phoneDistance;
|
||||
nearestPhoneId = phoneId;
|
||||
}
|
||||
}
|
||||
m_aPhones[nearestPhoneId].m_nState = PHONE_STATE_MESSAGE_REMOVED;
|
||||
|
||||
CPhone oldPhone = m_aPhones[into];
|
||||
m_aPhones[into] = m_aPhones[nearestPhoneId];
|
||||
m_aPhones[nearestPhoneId] = oldPhone;
|
||||
m_nScriptPhonesMax++;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
CPhoneInfo::GrabPhone(float xPos, float yPos)
|
||||
{
|
||||
@ -300,6 +360,7 @@ CPhoneInfo::Initialise(void)
|
||||
CBuilding *building = pool->GetSlot(i);
|
||||
if (building) {
|
||||
if (building->GetModelIndex() == MI_PHONEBOOTH1) {
|
||||
assert(m_nMax < ARRAY_SIZE(m_aPhones) && "NUMPHONES should be increased");
|
||||
CPhone *maxPhone = &m_aPhones[m_nMax];
|
||||
maxPhone->m_nState = PHONE_STATE_FREE;
|
||||
maxPhone->m_vecPos = building->GetPosition();
|
||||
@ -317,7 +378,11 @@ CPhoneInfo::Save(uint8 *buf, uint32 *size)
|
||||
INITSAVEBUF
|
||||
WriteSaveBuf(buf, m_nMax);
|
||||
WriteSaveBuf(buf, m_nScriptPhonesMax);
|
||||
for(int phoneId = 0; phoneId < NUMPHONES; phoneId++) {
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
for (int phoneId = 0; phoneId < 50; phoneId++) { // We can do it without touching saves
|
||||
#else
|
||||
for (int phoneId = 0; phoneId < NUMPHONES; phoneId++) {
|
||||
#endif
|
||||
CPhone* phone = WriteSaveBuf(buf, m_aPhones[phoneId]);
|
||||
|
||||
// Convert entity pointer to building pool index while saving
|
||||
|
@ -61,6 +61,9 @@ public:
|
||||
void Initialise(void);
|
||||
void Shutdown(void);
|
||||
void Update(void);
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
void SwapPhone(float xPos, float yPos, int into);
|
||||
#endif
|
||||
};
|
||||
|
||||
extern CPhoneInfo gPhoneInfo;
|
||||
@ -68,7 +71,7 @@ extern CPhoneInfo gPhoneInfo;
|
||||
void PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg);
|
||||
void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg);
|
||||
|
||||
#ifdef TOGGLEABLE_BETA_FEATURES
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
extern CPed *crimeReporters[NUMPHONES];
|
||||
bool isPhoneAvailable(int);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -3297,7 +3297,12 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
|
||||
ped->ClearAll();
|
||||
int8 path = ScriptParams[1];
|
||||
if (ScriptParams[1] < 0 || ScriptParams[1] > 7)
|
||||
// Max number GetRandomNumberInRange returns is max-1
|
||||
#ifdef FIX_BUGS
|
||||
path = CGeneral::GetRandomNumberInRange(0, 8);
|
||||
#else
|
||||
path = CGeneral::GetRandomNumberInRange(0, 7);
|
||||
#endif
|
||||
ped->SetWanderPath(path);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user