1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-07-03 08:47:07 +00:00

revisit processVehicle

This commit is contained in:
Roman Masanin 2020-09-15 22:06:18 +03:00
parent 97550b4fd9
commit 2d3d5d67ee
2 changed files with 144 additions and 127 deletions

View file

@ -697,113 +697,129 @@ const bool hornPatternsArray[8][44] = {
false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false}, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false},
}; };
void cAudioManager::ProcessVehicle(CVehicle* veh)
void
cAudioManager::ProcessVehicle(CVehicle *veh)
{ {
tHandlingData *handling = veh->pHandling; CPlayerPed* player;
float velChange; CVehicle* playerVeh;
CEntity* attachedTo;
cVehicleParams params; cVehicleParams params;
CBike* bike;
CAutomobile* automobile;
float gasPedal;
//44-58
player = FindPlayerPed();
playerVeh = FindPlayerVehicle();
if (playerVeh == NULL && player != NULL) {
attachedTo = player->m_attachedTo;
if (attachedTo != NULL && attachedTo->GetType() == ENTITY_TYPE_VEHICLE)
playerVeh = (CVehicle*)attachedTo;
}
if (playerVeh == veh
|| CGame::currArea == AREA_OVALRING
|| CGame::currArea == AREA_BLOOD
|| CGame::currArea == AREA_DIRT
|| CGame::currArea == AREA_EVERYWHERE
|| CGame::currArea == AREA_MALL
|| CGame::currArea == AREA_MAIN_MAP) {
//62-84
m_sQueueSample.m_vecPos = veh->GetPosition(); m_sQueueSample.m_vecPos = veh->GetPosition();
float gas;
float gasPedalAudio;
float tmp;
params.m_bDistanceCalculated = false; params.m_bDistanceCalculated = false;
params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
params.m_pVehicle = veh; params.m_pVehicle = veh;
params.m_pTransmission = nil; params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
params.m_nIndex = 0; params.m_pTransmission = veh->pHandling != NULL ? &veh->pHandling->Transmission : NULL;
params.m_fVelocityChange = 0.0f; params.m_nIndex = veh->m_modelIndex - MI_FIRST_VEHICLE;
if (veh->GetStatus() == STATUS_SIMPLE)
if (handling != nil) params.m_fVelocityChange = veh->AutoPilot.m_fMaxTrafficSpeed * 0.02f;
params.m_pTransmission = &handling->Transmission;
params.m_nIndex = veh->GetModelIndex() - MI_FIRST_VEHICLE;
if (params.m_pVehicle->GetStatus() == STATUS_SIMPLE)
velChange = params.m_pVehicle->AutoPilot.m_fMaxTrafficSpeed * 0.02f;
else else
velChange = DotProduct(params.m_pVehicle->m_vecMoveSpeed, params.m_pVehicle->GetForward()); params.m_fVelocityChange = DotProduct(veh->m_vecMoveSpeed, veh->GetForward());
params.m_fVelocityChange = velChange; params.m_VehicleType = veh->m_vehType;
params.m_VehicleType = params.m_pVehicle->m_vehType;
switch (params.m_pVehicle->m_vehType) {
case VEHICLE_TYPE_CAR:
UpdateGasPedalAudio((CAutomobile *)veh);
if (params.m_nIndex == RCBANDIT) {
ProcessModelCarEngine(&params);
ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange;
break;
}
if (params.m_nIndex == DODO) { if (CGame::currArea == AREA_MALL && playerVeh != veh) {
if (!ProcessVehicleRoadNoise(&params)) {
ProcessVehicleOneShots(&params); ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; ProcessVehicleSirenOrAlarm(&params);
break; ProcessEngineDamage(&params);
return;
} }
if (CWeather::WetRoads > 0.f) //104-
ProcessWetRoadNoise(&params); switch (params.m_VehicleType) {
ProcessVehicleSkidding(&params); case VEHICLE_TYPE_CAR://done
automobile = (CAutomobile*)veh;
UpdateGasPedalAudio(&automobile->m_fGasPedalAudio, automobile->m_fGasPedal);
if (veh->m_modelIndex == MI_RCBANDIT || veh->m_modelIndex == MI_RCBARON) {
ProcessModelCarEngine(&params);//recheck
ProcessEngineDamage(&params);
} else if (veh->m_modelIndex == MI_RCRAIDER || veh->m_modelIndex == MI_RCGOBLIN) {
//ProcessModelHeliVehicle(this, &params);
ProcessEngineDamage(&params);
} else { } else {
if (!ProcessVehicleRoadNoise(&params)) { switch (veh->GetVehicleAppearance()) {
ProcessVehicleOneShots(&params); case VEHICLE_APPEARANCE_HELI:
((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; ProcessHelicopter(&params);
//ProcessVehicleFlatTyre(&params);
ProcessEngineDamage(&params);
break; break;
} case VEHICLE_APPEARANCE_BOAT:
case VEHICLE_APPEARANCE_PLANE:
break;
default:
if (ProcessVehicleRoadNoise(&params)) {
ProcessReverseGear(&params); ProcessReverseGear(&params);
if (CWeather::WetRoads > 0.f) if (CWeather::WetRoads > 0.0)
ProcessWetRoadNoise(&params); ProcessWetRoadNoise(&params);
ProcessVehicleSkidding(&params); ProcessVehicleSkidding(&params);
//ProcessVehicleFlatTyre(params);
ProcessVehicleHorn(&params); ProcessVehicleHorn(&params);
ProcessVehicleSirenOrAlarm(&params); ProcessVehicleSirenOrAlarm(&params);
if (UsesReverseWarning(params.m_nIndex)) if (UsesReverseWarning(params.m_nIndex))
ProcessVehicleReverseWarning(&params); ProcessVehicleReverseWarning(&params);
if(HasAirBrakes(params.m_nIndex)) if(HasAirBrakes(params.m_nIndex))
ProcessAirBrakes(&params); ProcessAirBrakes(&params);
}
ProcessCarBombTick(&params); ProcessCarBombTick(&params);
ProcessVehicleEngine(&params); ProcessVehicleEngine(&params);
ProcessEngineDamage(&params); ProcessEngineDamage(&params);
ProcessVehicleDoors(&params); ProcessVehicleDoors(&params);
}
ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange;
break; break;
case VEHICLE_TYPE_BOAT: }
}
ProcessVehicleOneShots(&params);
automobile->m_fVelocityChangeForAudio = params.m_fVelocityChange;
break;
case VEHICLE_TYPE_BOAT://done
if (veh->m_modelIndex == MI_SKIMMER)
ProcessHelicopter(&params);
else
ProcessBoatEngine(&params); ProcessBoatEngine(&params);
ProcessBoatMovingOverWater(&params); ProcessBoatMovingOverWater(&params);
ProcessVehicleOneShots(&params); ProcessVehicleOneShots(&params);
break; break;
#ifdef GTA_TRAIN case VEHICLE_TYPE_HELI: //done
case VEHICLE_TYPE_TRAIN: ProcessHelicopter(&params); //TODO recheck
ProcessTrainNoise(&params);
ProcessVehicleOneShots(&params); ProcessVehicleOneShots(&params);
break; break;
#endif case VEHICLE_TYPE_PLANE://done
case VEHICLE_TYPE_HELI: switch (params.m_nIndex) {
ProcessHelicopter(&params); case AIRTRAIN:
ProcessVehicleOneShots(&params); ProcessJumbo(&params);//recheck
break; break;
case VEHICLE_TYPE_PLANE: case DEADDODO:
ProcessPlane(&params); ProcessCesna(&params);//recheck
ProcessVehicleOneShots(&params); break;
default:
break; break;
case VEHICLE_TYPE_BIKE:
gas = fabs(params.m_pVehicle->m_fGasPedal);
gasPedalAudio = ((CBike*)params.m_pVehicle)->m_fGasPedalAudio;
if (gas <= gasPedalAudio) {
tmp = gasPedalAudio = 0.07f;
if (tmp <= gas)
tmp = gas;
} else {
tmp = gasPedalAudio + 0.09f;
if (tmp < gas)
tmp = gas;
} }
((CBike*)params.m_pVehicle)->m_fGasPedalAudio = tmp; ProcessVehicleOneShots(&params);
//ProcessVehicleFlatType(&params);
break;
case VEHICLE_TYPE_BIKE: //done
bike = (CBike*)veh;
//gasPedal = fabs(veh->m_fGasPedal);
//if (gasPedal <= bike->m_fGasPedalAudio)
// bike->m_fGasPedalAudio = Max(bike->m_fGasPedalAudio - 0.07f, gasPedal);
//else
// bike->m_fGasPedalAudio = Min(bike->m_fGasPedalAudio + 0.09f, gasPedal);
UpdateGasPedalAudio(&bike->m_fGasPedalAudio, bike->m_fGasPedal);
if (ProcessVehicleRoadNoise(&params)) { if (ProcessVehicleRoadNoise(&params)) {
if (CWeather::WetRoads > 0.0f) if (CWeather::WetRoads > 0.0f)
ProcessWetRoadNoise(&params); ProcessWetRoadNoise(&params);
@ -816,13 +832,14 @@ cAudioManager::ProcessVehicle(CVehicle *veh)
//ProcessVehicleFlatTyre(); //ProcessVehicleFlatTyre();
} }
ProcessVehicleOneShots(&params); ProcessVehicleOneShots(&params);
((CBike*)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; bike->m_fVelocityChangeForAudio = params.m_fVelocityChange;
break; break;
default: default:
break; break;
} }
ProcessRainOnVehicle(&params); ProcessRainOnVehicle(&params);
} }
}
void void
cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) cAudioManager::ProcessRainOnVehicle(cVehicleParams *params)
@ -1227,15 +1244,14 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params)
} }
void void
cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile) cAudioManager::UpdateGasPedalAudio(float* gasPedalAudio, float vehGasPedal)
{ {
float gasPedal = Abs(automobile->m_fGasPedal); float gasPedal = Abs(vehGasPedal);
float gasPedalAudio = automobile->m_fGasPedalAudio;
if (gasPedalAudio < gasPedal) if (*gasPedalAudio < gasPedal)
automobile->m_fGasPedalAudio = Min(gasPedalAudio + 0.09f, gasPedal); *gasPedalAudio = Min(*gasPedalAudio + 0.09f, gasPedal);
else else
automobile->m_fGasPedalAudio = Max(gasPedalAudio - 0.07f, gasPedal); *gasPedalAudio = Max(*gasPedalAudio - 0.07f, gasPedal);
} }
void void
@ -2072,7 +2088,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params)
bool bool
cAudioManager::UsesReverseWarning(int32 model) const cAudioManager::UsesReverseWarning(int32 model) const
{ {
return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; return model == LINERUN || model == FIRETRUK || model == BUS || model == COACH || model == PACKER || model == FLATBED;
} }
bool bool
@ -2204,7 +2220,8 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params)
bool bool
cAudioManager::HasAirBrakes(int32 model) const cAudioManager::HasAirBrakes(int32 model) const
{ {
return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == BARRACKS
|| model == COACH || model == PACKER || model == FLATBED;
} }
bool bool

View file

@ -359,6 +359,7 @@ public:
void ProcessVehicle(CVehicle *vehicle); void ProcessVehicle(CVehicle *vehicle);
bool ProcessVehicleDoors(cVehicleParams *params); bool ProcessVehicleDoors(cVehicleParams *params);
void ProcessVehicleEngine(cVehicleParams *params); void ProcessVehicleEngine(cVehicleParams *params);
void UpdateGasPedalAudio(float* gasPedalAudio, float vehGasPedal);
void ProcessVehicleHorn(cVehicleParams *params); void ProcessVehicleHorn(cVehicleParams *params);
void ProcessVehicleOneShots(cVehicleParams *params); void ProcessVehicleOneShots(cVehicleParams *params);
bool ProcessVehicleReverseWarning(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params);
@ -411,7 +412,6 @@ public:
void Terminate(); void Terminate();
void TranslateEntity(Const CVector *v1, CVector *v2) const; void TranslateEntity(Const CVector *v1, CVector *v2) const;
void UpdateGasPedalAudio(CAutomobile *automobile);
void UpdateReflections(); void UpdateReflections();
bool UsesReverseWarning(int32 model) const; bool UsesReverseWarning(int32 model) const;
bool UsesSiren(int32 model) const; bool UsesSiren(int32 model) const;