summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-07-09 18:50:35 +0200
committeraap <aap@papnet.eu>2019-07-09 18:50:35 +0200
commita65dd41da736a12866526abc1405cbaa154771a8 (patch)
tree387f8103d69d373341e67a6373f681a454aa06db /src/vehicles
parentmore CAutomobile (diff)
downloadre3-a65dd41da736a12866526abc1405cbaa154771a8.tar
re3-a65dd41da736a12866526abc1405cbaa154771a8.tar.gz
re3-a65dd41da736a12866526abc1405cbaa154771a8.tar.bz2
re3-a65dd41da736a12866526abc1405cbaa154771a8.tar.lz
re3-a65dd41da736a12866526abc1405cbaa154771a8.tar.xz
re3-a65dd41da736a12866526abc1405cbaa154771a8.tar.zst
re3-a65dd41da736a12866526abc1405cbaa154771a8.zip
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/Automobile.cpp117
-rw-r--r--src/vehicles/Automobile.h2
-rw-r--r--src/vehicles/Vehicle.h12
3 files changed, 124 insertions, 7 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 267e901a..54557dc2 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -4,15 +4,22 @@
#include "ModelIndices.h"
#include "VisibilityPlugins.h"
#include "DMAudio.h"
+#include "Camera.h"
+#include "Darkel.h"
+#include "Fire.h"
+#include "Explosion.h"
#include "World.h"
#include "SurfaceTable.h"
#include "HandlingMgr.h"
#include "CarCtrl.h"
#include "PathFind.h"
#include "Ped.h"
+#include "PlayerPed.h"
#include "Object.h"
#include "Automobile.h"
+RwObject *GetCurrentAtomicObjectCB(RwObject *object, void *data);
+
bool &CAutomobile::m_sAllTaxiLights = *(bool*)0x95CD21;
WRAPPER CAutomobile* CAutomobile::ctor(int, uint8) { EAXJMP(0x52C6B0); }
@@ -357,7 +364,88 @@ CAutomobile::RemoveRefsToVehicle(CEntity *ent)
m_aGroundPhysical[i] = nil;
}
-WRAPPER void CAutomobile::BlowUpCar(CEntity *ent) { EAXJMP(0x53BC60); }
+void
+CAutomobile::BlowUpCar(CEntity *culprit)
+{
+ int i;
+ RpAtomic *atomic;
+
+ if(!bCanBeDamaged)
+ return;
+
+ // explosion pushes vehicle up
+ m_vecMoveSpeed.z += 0.13f;
+ m_status = STATUS_WRECKED;
+ bRenderScorched = true;
+ m_nTimeOfDeath = CTimer::GetTimeInMilliseconds();
+ Damage.FuckCarCompletely();
+
+ if(GetModelIndex() != MI_RCBANDIT){
+ SetBumperDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT);
+ SetBumperDamage(CAR_BUMP_REAR, VEHBUMPER_REAR);
+ SetDoorDamage(CAR_BONNET, DOOR_BONNET);
+ SetDoorDamage(CAR_BOOT, DOOR_BOOT);
+ SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT);
+ SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT);
+ SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT);
+ SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT);
+ SpawnFlyingComponent(CAR_WHEEL_LF, COMPGROUP_WHEEL);
+ RwFrameForAllObjects(m_aCarNodes[CAR_WHEEL_LF], GetCurrentAtomicObjectCB, &atomic);
+ if(atomic)
+ RpAtomicSetFlags(atomic, 0);
+ }
+
+ m_fHealth = 0.0f;
+ m_nBombTimer = 0;
+ m_auto_flagA1 = false;
+ m_auto_flagA2 = false;
+ m_auto_flagA4 = false;
+
+ TheCamera.CamShake(0.7f, GetPosition().x, GetPosition().y, GetPosition().z);
+
+ // kill driver and passengers
+ if(pDriver){
+ CDarkel::RegisterKillByPlayer(pDriver, WEAPONTYPE_EXPLOSION);
+ if(pDriver->GetPedState() == PED_DRIVING){
+ pDriver->SetDead();
+ if(!pDriver->IsPlayer())
+ pDriver->FlagToDestroyWhenNextProcessed();
+ }else
+ pDriver->SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
+ }
+ for(i = 0; i < m_nNumMaxPassengers; i++){
+ if(pPassengers[i]){
+ CDarkel::RegisterKillByPlayer(pPassengers[i], WEAPONTYPE_EXPLOSION);
+ if(pPassengers[i]->GetPedState() == PED_DRIVING){
+ pPassengers[i]->SetDead();
+ if(!pPassengers[i]->IsPlayer())
+ pPassengers[i]->FlagToDestroyWhenNextProcessed();
+ }else
+ pPassengers[i]->SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
+ }
+ }
+
+ bEngineOn = false;
+ bLightsOn = false;
+ m_bSirenOrAlarm = false;
+ bTaxiLight = false;
+ if(bIsAmbulanceOnDuty){
+ bIsAmbulanceOnDuty = false;
+ CCarCtrl::NumAmbulancesOnDuty--;
+ }
+ if(bIsFireTruckOnDuty){
+ bIsFireTruckOnDuty = false;
+ CCarCtrl::NumFiretrucksOnDuty--;
+ }
+ ChangeLawEnforcerState(false);
+
+ gFireManager.StartFire(this, culprit, 0.8f, 1); // TODO
+ CDarkel::RegisterCarBlownUpByPlayer(this);
+ if(GetModelIndex() == MI_RCBANDIT)
+ CExplosion::AddExplosion(this, culprit, EXPLOSION_4, GetPosition(), 0); // TODO
+ else
+ CExplosion::AddExplosion(this, culprit, EXPLOSION_3, GetPosition(), 0); // TODO
+}
bool
CAutomobile::SetUpWheelColModel(CColModel *colModel)
@@ -516,6 +604,31 @@ CAutomobile::SetupSuspensionLines(void)
}
}
+// called on police cars
+void
+CAutomobile::ScanForCrimes(void)
+{
+ if(FindPlayerVehicle() && FindPlayerVehicle()->IsCar())
+ if(FindPlayerVehicle()->m_nAlarmState != -1)
+ // if player's alarm is on, increase wanted level
+ if((FindPlayerVehicle()->GetPosition() - GetPosition()).MagnitudeSqr() < sq(20.0f))
+ CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetWantedLevelNoDrop(1);
+}
+
+void
+CAutomobile::BlowUpCarsInPath(void)
+{
+ int i;
+
+ if(m_vecMoveSpeed.Magnitude() > 0.1f)
+ for(i = 0; i < m_nCollisionRecords; i++)
+ if(m_aCollisionRecords[i] &&
+ m_aCollisionRecords[i]->IsVehicle() &&
+ m_aCollisionRecords[i]->GetModelIndex() != MI_RHINO &&
+ !m_aCollisionRecords[i]->bRenderScorched)
+ ((CVehicle*)m_aCollisionRecords[i])->BlowUpCar(this);
+}
+
bool
CAutomobile::HasCarStoppedBecauseOfLight(void)
{
@@ -1014,12 +1127,14 @@ STARTPATCHES
InjectHook(0x52EFD0, &CAutomobile_::IsDoorClosed_, PATCH_JUMP);
InjectHook(0x52F000, &CAutomobile_::IsDoorMissing_, PATCH_JUMP);
InjectHook(0x53BF40, &CAutomobile_::RemoveRefsToVehicle_, PATCH_JUMP);
+ InjectHook(0x53BC60, &CAutomobile_::BlowUpCar_, PATCH_JUMP);
InjectHook(0x53BF70, &CAutomobile_::SetUpWheelColModel_, PATCH_JUMP);
InjectHook(0x53C0E0, &CAutomobile_::BurstTyre_, PATCH_JUMP);
InjectHook(0x437690, &CAutomobile_::GetHeightAboveRoad_, PATCH_JUMP);
InjectHook(0x53C450, &CAutomobile_::PlayCarHorn_, PATCH_JUMP);
InjectHook(0x5353A0, &CAutomobile::ResetSuspension, PATCH_JUMP);
InjectHook(0x52D210, &CAutomobile::SetupSuspensionLines, PATCH_JUMP);
+ InjectHook(0x53E000, &CAutomobile::BlowUpCarsInPath, PATCH_JUMP);
InjectHook(0x42E220, &CAutomobile::HasCarStoppedBecauseOfLight, PATCH_JUMP);
InjectHook(0x53D320, &CAutomobile::SetBusDoorTimer, PATCH_JUMP);
InjectHook(0x53D370, &CAutomobile::ProcessAutoBusDoors, PATCH_JUMP);
diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h
index fc859f92..0e9bd945 100644
--- a/src/vehicles/Automobile.h
+++ b/src/vehicles/Automobile.h
@@ -91,6 +91,8 @@ public:
void PlayHornIfNecessary(void);
void ResetSuspension(void);
void SetupSuspensionLines(void);
+ void ScanForCrimes(void);
+ void BlowUpCarsInPath(void);
bool HasCarStoppedBecauseOfLight(void);
void SetBusDoorTimer(uint32 timer, uint8 type);
void ProcessAutoBusDoors(void);
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index 5aa0a770..cd877da5 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -150,19 +150,19 @@ public:
uint8 m_veh_flagB80 : 1;
uint8 m_veh_flagC1 : 1;
- uint8 bIsDamaged : 1;
+ uint8 bIsDamaged : 1; // This vehicle has been damaged and is displaying all its components
uint8 m_veh_flagC4 : 1;
uint8 m_veh_flagC8 : 1;
uint8 m_veh_flagC10 : 1;
uint8 m_veh_flagC20 : 1;
- uint8 m_veh_flagC40 : 1;
+ uint8 bCanBeDamaged : 1; // Set to FALSE during cut scenes to avoid explosions
uint8 m_veh_flagC80 : 1;
uint8 m_veh_flagD1 : 1;
uint8 m_veh_flagD2 : 1;
- uint8 bVehicleColProcessed : 1;
- uint8 bIsCarParkVehicle : 1;
- uint8 bHasAlreadyBeenRecorded : 1;
+ uint8 bVehicleColProcessed : 1;// Has ProcessEntityCollision been processed for this car?
+ uint8 bIsCarParkVehicle : 1; // Car has been created using the special CAR_PARK script command
+ uint8 bHasAlreadyBeenRecorded : 1; // Used for replays
uint8 m_veh_flagD20 : 1;
uint8 m_veh_flagD40 : 1;
uint8 m_veh_flagD80 : 1;
@@ -189,7 +189,7 @@ public:
int8 field_22B;
uint8 m_nCarHornTimer;
int8 field_22D;
- uint8 m_nSirenOrAlarm;
+ bool m_bSirenOrAlarm;
int8 field_22F;
// TODO: this is an array
CStoredCollPoly m_frontCollPoly; // poly which is under front part of car