2020-10-18 13:26:20 +00:00
|
|
|
|
#include "common.h"
|
2019-07-18 19:41:20 +00:00
|
|
|
|
#include "main.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
#include "General.h"
|
2019-07-19 09:57:12 +00:00
|
|
|
|
#include "RwHelper.h"
|
2019-07-11 10:48:49 +00:00
|
|
|
|
#include "Pad.h"
|
2019-07-08 19:37:47 +00:00
|
|
|
|
#include "ModelIndices.h"
|
2019-07-08 06:46:42 +00:00
|
|
|
|
#include "VisibilityPlugins.h"
|
2019-07-08 19:37:47 +00:00
|
|
|
|
#include "DMAudio.h"
|
2019-07-28 11:14:08 +00:00
|
|
|
|
#include "Clock.h"
|
2019-07-31 15:54:18 +00:00
|
|
|
|
#include "Timecycle.h"
|
2019-08-02 15:43:40 +00:00
|
|
|
|
#include "ZoneCull.h"
|
2019-07-09 16:50:35 +00:00
|
|
|
|
#include "Camera.h"
|
|
|
|
|
#include "Darkel.h"
|
2019-07-17 21:58:06 +00:00
|
|
|
|
#include "Rubbish.h"
|
2019-07-09 16:50:35 +00:00
|
|
|
|
#include "Fire.h"
|
|
|
|
|
#include "Explosion.h"
|
2019-07-18 13:41:09 +00:00
|
|
|
|
#include "Particle.h"
|
2019-07-24 21:06:48 +00:00
|
|
|
|
#include "ParticleObject.h"
|
2020-05-27 20:32:33 +00:00
|
|
|
|
#include "Glass.h"
|
2019-07-28 11:14:08 +00:00
|
|
|
|
#include "Antennas.h"
|
|
|
|
|
#include "Skidmarks.h"
|
2020-05-31 15:05:49 +00:00
|
|
|
|
#include "WindModifiers.h"
|
2019-07-28 11:14:08 +00:00
|
|
|
|
#include "Shadows.h"
|
|
|
|
|
#include "PointLights.h"
|
|
|
|
|
#include "Coronas.h"
|
|
|
|
|
#include "SpecialFX.h"
|
2019-07-26 12:27:13 +00:00
|
|
|
|
#include "WaterCannon.h"
|
2019-07-24 21:06:48 +00:00
|
|
|
|
#include "WaterLevel.h"
|
|
|
|
|
#include "Floater.h"
|
2019-07-08 19:37:47 +00:00
|
|
|
|
#include "World.h"
|
2019-07-08 15:07:34 +00:00
|
|
|
|
#include "SurfaceTable.h"
|
2019-07-26 16:48:14 +00:00
|
|
|
|
#include "Weather.h"
|
2019-07-08 06:46:42 +00:00
|
|
|
|
#include "HandlingMgr.h"
|
2019-07-17 11:19:20 +00:00
|
|
|
|
#include "Record.h"
|
|
|
|
|
#include "Remote.h"
|
|
|
|
|
#include "Population.h"
|
2019-07-08 19:37:47 +00:00
|
|
|
|
#include "CarCtrl.h"
|
2019-07-17 11:19:20 +00:00
|
|
|
|
#include "CarAI.h"
|
2020-05-27 20:32:33 +00:00
|
|
|
|
#include "Stats.h"
|
2019-07-17 11:19:20 +00:00
|
|
|
|
#include "Garages.h"
|
2019-07-09 07:57:44 +00:00
|
|
|
|
#include "PathFind.h"
|
2020-05-31 15:05:49 +00:00
|
|
|
|
#include "Replay.h"
|
2019-07-23 14:39:30 +00:00
|
|
|
|
#include "AnimManager.h"
|
|
|
|
|
#include "RpAnimBlend.h"
|
2020-03-28 14:47:52 +00:00
|
|
|
|
#include "AnimBlendAssociation.h"
|
2019-07-08 19:37:47 +00:00
|
|
|
|
#include "Ped.h"
|
2019-07-09 16:50:35 +00:00
|
|
|
|
#include "PlayerPed.h"
|
2019-07-08 19:37:47 +00:00
|
|
|
|
#include "Object.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
|
#include "Automobile.h"
|
2020-11-19 23:18:37 +00:00
|
|
|
|
#include "Bike.h"
|
2019-06-24 22:42:23 +00:00
|
|
|
|
|
2020-08-20 11:20:48 +00:00
|
|
|
|
//--MIAMI: file done
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
|
|
|
|
bool bAllCarCheat;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
2019-07-09 16:50:35 +00:00
|
|
|
|
RwObject *GetCurrentAtomicObjectCB(RwObject *object, void *data);
|
|
|
|
|
|
2020-04-17 05:54:14 +00:00
|
|
|
|
bool CAutomobile::m_sAllTaxiLights;
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2020-05-02 15:02:17 +00:00
|
|
|
|
const uint32 CAutomobile::nSaveStructSize =
|
|
|
|
|
#ifdef COMPATIBLE_SAVES
|
2020-10-17 15:50:16 +00:00
|
|
|
|
1500;
|
2020-05-02 15:02:17 +00:00
|
|
|
|
#else
|
|
|
|
|
sizeof(CAutomobile);
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-19 09:57:12 +00:00
|
|
|
|
CAutomobile::CAutomobile(int32 id, uint8 CreatedBy)
|
|
|
|
|
: CVehicle(CreatedBy)
|
2019-06-30 10:59:55 +00:00
|
|
|
|
{
|
2019-07-19 09:57:12 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
m_vehType = VEHICLE_TYPE_CAR;
|
|
|
|
|
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id);
|
|
|
|
|
m_fFireBlowUpTimer = 0.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_doingBurnout = 0;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
bTaxiLight = m_sAllTaxiLights;
|
2019-10-27 09:51:09 +00:00
|
|
|
|
bFixedColour = false;
|
|
|
|
|
bBigWheels = false;
|
2019-07-24 21:06:48 +00:00
|
|
|
|
bWaterTight = false;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
|
2020-11-01 10:30:23 +00:00
|
|
|
|
SetModelIndex(id);
|
2019-07-19 09:57:12 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
// Already done in CVehicle...
|
|
|
|
|
switch(GetModelIndex()){
|
|
|
|
|
case MI_HUNTER:
|
|
|
|
|
case MI_ANGEL:
|
|
|
|
|
case MI_FREEWAY:
|
|
|
|
|
m_nRadioStation = V_ROCK;
|
|
|
|
|
break;
|
|
|
|
|
case MI_RCBARON:
|
|
|
|
|
case MI_RCBANDIT:
|
|
|
|
|
case MI_RCRAIDER:
|
|
|
|
|
case MI_RCGOBLIN:
|
|
|
|
|
case MI_TOPFUN:
|
|
|
|
|
case MI_CADDY:
|
|
|
|
|
case MI_BAGGAGE:
|
|
|
|
|
m_nRadioStation = RADIO_OFF;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-24 15:15:51 +00:00
|
|
|
|
pHandling = mod_HandlingManager.GetHandlingData((tVehicleType)mi->m_handlingId);
|
|
|
|
|
pFlyingHandling = mod_HandlingManager.GetFlyingPointer((tVehicleType)mi->m_handlingId);
|
2019-07-19 09:57:12 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_auto_unused1 = 20.0f;
|
|
|
|
|
m_auto_unused2 = 0;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
|
|
|
|
|
mi->ChooseVehicleColour(m_currentColour1, m_currentColour2);
|
|
|
|
|
|
|
|
|
|
bIsVan = !!(pHandling->Flags & HANDLING_IS_VAN);
|
|
|
|
|
bIsBig = !!(pHandling->Flags & HANDLING_IS_BIG);
|
|
|
|
|
bIsBus = !!(pHandling->Flags & HANDLING_IS_BUS);
|
|
|
|
|
bLowVehicle = !!(pHandling->Flags & HANDLING_IS_LOW);
|
|
|
|
|
|
|
|
|
|
// Doors
|
|
|
|
|
if(bIsBus){
|
|
|
|
|
Doors[DOOR_FRONT_LEFT].Init(-HALFPI, 0.0f, 0, 2);
|
|
|
|
|
Doors[DOOR_FRONT_RIGHT].Init(0.0f, HALFPI, 1, 2);
|
|
|
|
|
}else{
|
|
|
|
|
Doors[DOOR_FRONT_LEFT].Init(-PI*0.4f, 0.0f, 0, 2);
|
|
|
|
|
Doors[DOOR_FRONT_RIGHT].Init(0.0f, PI*0.4f, 1, 2);
|
|
|
|
|
}
|
|
|
|
|
if(bIsVan){
|
|
|
|
|
Doors[DOOR_REAR_LEFT].Init(-HALFPI, 0.0f, 1, 2);
|
|
|
|
|
Doors[DOOR_REAR_RIGHT].Init(0.0f, HALFPI, 0, 2);
|
|
|
|
|
}else{
|
|
|
|
|
Doors[DOOR_REAR_LEFT].Init(-PI*0.4f, 0.0f, 0, 2);
|
|
|
|
|
Doors[DOOR_REAR_RIGHT].Init(0.0f, PI*0.4f, 1, 2);
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_REV_BONNET)
|
|
|
|
|
Doors[DOOR_BONNET].Init(-PI*0.3f, 0.0f, 1, 0);
|
|
|
|
|
else
|
|
|
|
|
Doors[DOOR_BONNET].Init(0.0f, PI*0.3f, 1, 0);
|
|
|
|
|
if(pHandling->Flags & HANDLING_HANGING_BOOT)
|
2020-05-14 13:03:01 +00:00
|
|
|
|
Doors[DOOR_BOOT].Init(-PI*0.4f, 0.0f, 0, 0);
|
2019-07-19 09:57:12 +00:00
|
|
|
|
else if(pHandling->Flags & HANDLING_TAILGATE_BOOT)
|
|
|
|
|
Doors[DOOR_BOOT].Init(0.0, HALFPI, 1, 0);
|
|
|
|
|
else
|
|
|
|
|
Doors[DOOR_BOOT].Init(-PI*0.3f, 0.0f, 1, 0);
|
|
|
|
|
if(pHandling->Flags & HANDLING_NO_DOORS){
|
|
|
|
|
Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_MISSING);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_MISSING);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_REAR_LEFT, DOOR_STATUS_MISSING);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_REAR_RIGHT, DOOR_STATUS_MISSING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 6; i++)
|
|
|
|
|
m_randomValues[i] = CGeneral::GetRandomNumberInRange(-0.15f, 0.15f);
|
|
|
|
|
|
|
|
|
|
m_fMass = pHandling->fMass;
|
|
|
|
|
m_fTurnMass = pHandling->fTurnMass;
|
|
|
|
|
m_vecCentreOfMass = pHandling->CentreOfMass;
|
|
|
|
|
m_fAirResistance = pHandling->Dimension.x*pHandling->Dimension.z/m_fMass;
|
|
|
|
|
m_fElasticity = 0.05f;
|
|
|
|
|
m_fBuoyancy = pHandling->fBuoyancy;
|
|
|
|
|
|
2020-08-16 15:39:11 +00:00
|
|
|
|
m_fOrientation = m_fPlaneSteer = 0.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
2019-07-19 09:57:12 +00:00
|
|
|
|
m_nBusDoorTimerEnd = 0;
|
|
|
|
|
m_nBusDoorTimerStart = 0;
|
|
|
|
|
|
|
|
|
|
m_fSteerAngle = 0.0f;
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
m_fBrakePedal = 0.0f;
|
|
|
|
|
m_pSetOnFireEntity = nil;
|
2019-10-12 14:06:15 +00:00
|
|
|
|
m_fGasPedalAudio = 0.0f;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
bNotDamagedUpsideDown = false;
|
|
|
|
|
bMoreResistantToDamage = false;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bTankDetonateCars = true;
|
|
|
|
|
bStuckInSand = false;
|
|
|
|
|
bHeliDestroyed = false;
|
2019-07-31 21:57:18 +00:00
|
|
|
|
m_fVelocityChangeForAudio = 0.0f;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
m_hydraulicState = 0;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
m_aGroundPhysical[i] = nil;
|
|
|
|
|
m_aGroundOffset[i] = CVector(0.0f, 0.0f, 0.0f);
|
2020-06-02 21:35:20 +00:00
|
|
|
|
m_aSuspensionSpringRatioPrev[i] = m_aSuspensionSpringRatio[i] = 1.0f;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
m_aWheelTimer[i] = 0.0f;
|
|
|
|
|
m_aWheelRotation[i] = 0.0f;
|
|
|
|
|
m_aWheelSpeed[i] = 0.0f;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
m_aWheelState[i] = WHEEL_STATE_NORMAL;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelSkidmarkType[i] = SKIDMARK_NORMAL;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
m_aWheelSkidmarkBloody[i] = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_nWheelsOnGround = 0;
|
|
|
|
|
m_nDriveWheelsOnGround = 0;
|
|
|
|
|
m_nDriveWheelsOnGroundPrev = 0;
|
|
|
|
|
m_fHeightAboveRoad = 0.0f;
|
|
|
|
|
m_fTraction = 1.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_fTireTemperature = 1.0f;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
|
|
|
|
|
CColModel *colModel = mi->GetColModel();
|
|
|
|
|
if(colModel->lines == nil){
|
|
|
|
|
colModel->lines = (CColLine*)RwMalloc(4*sizeof(CColLine));
|
|
|
|
|
colModel->numLines = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetupSuspensionLines();
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
SetStatus(STATUS_SIMPLE);
|
2019-07-19 09:57:12 +00:00
|
|
|
|
bUseCollisionRecords = true;
|
|
|
|
|
|
|
|
|
|
m_nNumPassengers = 0;
|
|
|
|
|
|
|
|
|
|
if(m_nDoorLock == CARLOCK_UNLOCKED &&
|
|
|
|
|
(id == MI_POLICE || id == MI_ENFORCER || id == MI_RHINO))
|
|
|
|
|
m_nDoorLock = CARLOCK_LOCKED_INITIALLY;
|
|
|
|
|
|
|
|
|
|
m_fCarGunLR = 0.0f;
|
|
|
|
|
m_fCarGunUD = 0.05f;
|
2019-07-27 09:53:51 +00:00
|
|
|
|
m_fPropellerRotation = 0.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_fHeliOrientation = -1.0f;
|
2019-07-23 14:39:30 +00:00
|
|
|
|
m_weaponDoorTimerLeft = 0.0f;
|
|
|
|
|
m_weaponDoorTimerRight = m_weaponDoorTimerLeft;
|
2019-07-19 09:57:12 +00:00
|
|
|
|
|
|
|
|
|
if(GetModelIndex() == MI_DODO){
|
2020-04-09 14:35:24 +00:00
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LF]), 0);
|
2019-07-19 09:57:12 +00:00
|
|
|
|
CMatrix mat1;
|
|
|
|
|
mat1.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF]));
|
|
|
|
|
CMatrix mat2(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF]));
|
|
|
|
|
mat1.GetPosition() += CVector(mat2.GetPosition().x + 0.1f, 0.0f, mat2.GetPosition().z);
|
|
|
|
|
mat1.UpdateRW();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(GetModelIndex() == MI_HUNTER){
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LB]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RB]), 0);
|
2020-05-10 18:51:29 +00:00
|
|
|
|
}else if(IsRealHeli()){
|
2020-04-09 14:35:24 +00:00
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LF]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RF]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LB]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RB]), 0);
|
2019-07-19 09:57:12 +00:00
|
|
|
|
}else if(GetModelIndex() == MI_RHINO){
|
|
|
|
|
bExplosionProof = true;
|
|
|
|
|
bBulletProof = true;
|
|
|
|
|
}
|
2019-06-30 10:59:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 06:46:42 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetModelIndex(uint32 id)
|
|
|
|
|
{
|
|
|
|
|
CVehicle::SetModelIndex(id);
|
|
|
|
|
SetupModelNodes();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
#define SAND_SLOWDOWN (0.01f)
|
|
|
|
|
float CAR_BALANCE_MULT = 0.3f;
|
|
|
|
|
CVector vecSeaSparrowGunPos(-0.5f, 2.4f, -0.785f);
|
|
|
|
|
CVector vecHunterGunPos(0.0f, 4.8f, -1.3f);
|
|
|
|
|
CVector vecHunterRocketPos(2.5f, 1.0f, -0.5f);
|
2019-07-18 13:41:09 +00:00
|
|
|
|
CVector vecDAMAGE_ENGINE_POS_SMALL(-0.1f, -0.1f, 0.0f);
|
|
|
|
|
CVector vecDAMAGE_ENGINE_POS_BIG(-0.5f, -0.3f, 0.0f);
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::ProcessControl(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2020-06-04 15:38:41 +00:00
|
|
|
|
float wheelRot;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
CColModel *colModel;
|
|
|
|
|
|
2019-07-27 11:02:49 +00:00
|
|
|
|
if(bUsingSpecialColModel)
|
2019-07-16 17:48:50 +00:00
|
|
|
|
colModel = &CWorld::Players[CWorld::PlayerInFocus].m_ColModel;
|
|
|
|
|
else
|
|
|
|
|
colModel = GetColModel();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bool drivingInSand = false;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
bWarnedPeds = false;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_doingBurnout = 0;
|
|
|
|
|
bStuckInSand = false;
|
|
|
|
|
bRestingOnPhysical = false;
|
|
|
|
|
|
|
|
|
|
bool carHasNitro = bAllTaxisHaveNitro && GetStatus() == STATUS_PLAYER && IsTaxi();
|
|
|
|
|
|
|
|
|
|
if(CReplay::IsPlayingBack())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Heli wind
|
|
|
|
|
if(IsRealHeli())
|
|
|
|
|
if((GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PHYSICS) && m_aWheelSpeed[1] > 0.075f ||
|
|
|
|
|
GetStatus() == STATUS_SIMPLE)
|
|
|
|
|
CWindModifiers::RegisterOne(GetPosition(), 1);
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
2020-06-09 13:50:00 +00:00
|
|
|
|
UpdatePassengerList();
|
|
|
|
|
|
2019-07-17 11:19:20 +00:00
|
|
|
|
// Improve grip of vehicles in certain cases
|
|
|
|
|
bool strongGrip1 = false;
|
|
|
|
|
bool strongGrip2 = false;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(FindPlayerVehicle() && this != FindPlayerVehicle() &&
|
|
|
|
|
(AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE ||
|
|
|
|
|
AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE)){
|
|
|
|
|
if(FindPlayerSpeed().Magnitude() > 0.3f){
|
|
|
|
|
strongGrip1 = true;
|
|
|
|
|
if(FindPlayerSpeed().Magnitude() > 0.4f &&
|
|
|
|
|
m_vecMoveSpeed.Magnitude() < 0.3f)
|
|
|
|
|
strongGrip2 = true;
|
|
|
|
|
else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
|
|
|
|
|
strongGrip2 = true;
|
2019-07-17 11:19:20 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(GetModelIndex() == MI_RCBANDIT && GetStatus() != STATUS_PLAYER_REMOTE)
|
|
|
|
|
strongGrip1 = true;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
|
|
|
|
if(bIsBus)
|
|
|
|
|
ProcessAutoBusDoors();
|
|
|
|
|
|
|
|
|
|
ProcessCarAlarm();
|
|
|
|
|
|
2020-04-07 14:48:49 +00:00
|
|
|
|
// Scan if this car sees the player committing any crimes
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() != STATUS_ABANDONED && GetStatus() != STATUS_WRECKED &&
|
2020-05-31 15:05:49 +00:00
|
|
|
|
GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PLAYER_DISABLED){
|
2019-07-16 17:48:50 +00:00
|
|
|
|
switch(GetModelIndex())
|
2020-05-31 15:05:49 +00:00
|
|
|
|
case MI_FBIRANCH:
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case MI_POLICE:
|
|
|
|
|
case MI_ENFORCER:
|
|
|
|
|
case MI_SECURICA:
|
|
|
|
|
case MI_RHINO:
|
|
|
|
|
case MI_BARRACKS:
|
|
|
|
|
ScanForCrimes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process driver
|
2020-05-27 05:43:38 +00:00
|
|
|
|
if(pDriver)
|
|
|
|
|
if(IsUpsideDown() && CanPedEnterCar()){
|
|
|
|
|
if(!pDriver->IsPlayer() &&
|
|
|
|
|
!(pDriver->m_leader && pDriver->m_leader->bInVehicle) &&
|
|
|
|
|
pDriver->CharCreatedBy != MISSION_CHAR)
|
2020-06-22 01:02:44 +00:00
|
|
|
|
pDriver->SetObjective(OBJECTIVE_LEAVE_CAR, this);
|
2020-05-27 05:43:38 +00:00
|
|
|
|
}
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
2020-05-24 13:14:27 +00:00
|
|
|
|
ActivateBombWhenEntered();
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
|
|
|
|
// Process passengers
|
|
|
|
|
if(m_nNumPassengers != 0 && IsUpsideDown() && CanPedEnterCar()){
|
|
|
|
|
for(i = 0; i < m_nNumMaxPassengers; i++)
|
|
|
|
|
if(pPassengers[i])
|
|
|
|
|
if(!pPassengers[i]->IsPlayer() &&
|
|
|
|
|
!(pPassengers[i]->m_leader && pPassengers[i]->m_leader->bInVehicle) &&
|
|
|
|
|
pPassengers[i]->CharCreatedBy != MISSION_CHAR)
|
2020-06-22 01:02:44 +00:00
|
|
|
|
pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_CAR, this);
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 21:58:06 +00:00
|
|
|
|
CRubbish::StirUp(this);
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
2020-05-24 13:14:27 +00:00
|
|
|
|
UpdateClumpAlpha();
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
2019-08-25 13:47:22 +00:00
|
|
|
|
AutoPilot.m_bSlowedDownBecauseOfCars = false;
|
2019-08-11 17:11:54 +00:00
|
|
|
|
AutoPilot.m_bSlowedDownBecauseOfPeds = false;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
|
|
|
|
// Set Center of Mass to make car more stable
|
2019-07-17 11:19:20 +00:00
|
|
|
|
if(strongGrip1 || bCheat3)
|
2019-08-16 18:17:15 +00:00
|
|
|
|
m_vecCentreOfMass.z = 0.3f*m_aSuspensionSpringLength[0] + -1.0f*m_fHeightAboveRoad;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
else if(pHandling->Flags & HANDLING_NONPLAYER_STABILISER && GetStatus() == STATUS_PHYSICS)
|
2019-07-17 11:19:20 +00:00
|
|
|
|
m_vecCentreOfMass.z = pHandling->CentreOfMass.z - 0.2f*pHandling->Dimension.z;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
else
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_vecCentreOfMass = pHandling->CentreOfMass;
|
|
|
|
|
|
|
|
|
|
// Park car
|
|
|
|
|
if(bCanPark && !bParking && VehicleCreatedBy != MISSION_VEHICLE && AutoPilot.m_nCarMission == MISSION_CRUISE &&
|
|
|
|
|
((CTimer::GetFrameCounter() + m_randomSeed)&0xF) == 0 && !IsTaxi()){
|
|
|
|
|
CVector parkPosition = GetPosition() + 3.0f*GetRight() + 10.0f*GetForward();
|
|
|
|
|
CEntity *ent = nil;
|
|
|
|
|
CColPoint colpoint;
|
|
|
|
|
if(!CWorld::ProcessLineOfSight(GetPosition(), parkPosition, colpoint, ent, true, true, true, false, false, false) ||
|
|
|
|
|
ent == this)
|
|
|
|
|
CCarAI::GetCarToParkAtCoors(this, &parkPosition);
|
|
|
|
|
}
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
|
|
|
|
// Process depending on status
|
|
|
|
|
|
2019-07-17 11:19:20 +00:00
|
|
|
|
bool playerRemote = false;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
switch(GetStatus()){
|
2019-07-17 11:19:20 +00:00
|
|
|
|
case STATUS_PLAYER_REMOTE:
|
2020-05-17 18:43:11 +00:00
|
|
|
|
if(CPad::GetPad(0)->WeaponJustDown() && !bDisableRemoteDetonation){
|
2019-07-17 11:19:20 +00:00
|
|
|
|
BlowUpCar(FindPlayerPed());
|
|
|
|
|
CRemote::TakeRemoteControlledCarFromPlayer();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetModelIndex() == MI_RCBANDIT && !bDisableRemoteDetonationOnContact){
|
|
|
|
|
//CVector pos = GetPosition();
|
2019-07-17 11:19:20 +00:00
|
|
|
|
// FindPlayerCoors unused
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(RcbanditCheckHitWheels() || bIsInWater){
|
2019-07-17 11:19:20 +00:00
|
|
|
|
CRemote::TakeRemoteControlledCarFromPlayer();
|
|
|
|
|
BlowUpCar(FindPlayerPed());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle == this)
|
|
|
|
|
playerRemote = true;
|
|
|
|
|
// fall through
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case STATUS_PLAYER:
|
2019-07-17 11:19:20 +00:00
|
|
|
|
if(playerRemote ||
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pDriver && pDriver->GetPedState() != PED_EXIT_CAR && pDriver->GetPedState() != PED_DRAG_FROM_CAR && pDriver->GetPedState() != PED_ARRESTED){
|
2019-07-17 11:19:20 +00:00
|
|
|
|
// process control input if controlled by player
|
|
|
|
|
if(playerRemote || pDriver->m_nPedType == PEDTYPE_PLAYER1)
|
|
|
|
|
ProcessControlInputs(0);
|
|
|
|
|
|
|
|
|
|
PruneReferences();
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER && !CRecordDataForChase::IsRecording())
|
2019-07-17 11:19:20 +00:00
|
|
|
|
DoDriveByShootings();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
|
|
|
|
// Tweak center on mass when driving on two wheels
|
|
|
|
|
int twoWheelTime = CWorld::Players[CWorld::PlayerInFocus].m_nTimeNotFullyOnGround;
|
|
|
|
|
if(twoWheelTime > 500 && !IsRealHeli() && !IsRealPlane()){
|
|
|
|
|
float tweak = Min(twoWheelTime-500, 1000)/500.0f;
|
|
|
|
|
if(GetUp().z > 0.0f){
|
|
|
|
|
// positive when on left wheels, negative on right wheels
|
|
|
|
|
if(GetRight().z <= 0.0f)
|
|
|
|
|
tweak *= -1.0f;
|
|
|
|
|
m_vecCentreOfMass.z = pHandling->CentreOfMass.z +
|
|
|
|
|
CPad::GetPad(0)->GetSteeringLeftRight()/128.0f *
|
|
|
|
|
CAR_BALANCE_MULT * tweak * colModel->boundingBox.max.z;
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
m_vecCentreOfMass.z = pHandling->CentreOfMass.z;
|
|
|
|
|
|
|
|
|
|
if(bHoverCheat)
|
|
|
|
|
DoHoverSuspensionRatios();
|
|
|
|
|
|
|
|
|
|
if(m_aSuspensionSpringRatio[0] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[0].surfaceB) == ADHESIVE_SAND ||
|
|
|
|
|
m_aSuspensionSpringRatio[1] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[1].surfaceB) == ADHESIVE_SAND ||
|
|
|
|
|
m_aSuspensionSpringRatio[2] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[2].surfaceB) == ADHESIVE_SAND ||
|
|
|
|
|
m_aSuspensionSpringRatio[3] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[3].surfaceB) == ADHESIVE_SAND){
|
|
|
|
|
if(GetModelIndex() != MI_RCBANDIT && GetModelIndex() != MI_RHINO){
|
|
|
|
|
float slowdown;
|
2020-06-06 22:01:48 +00:00
|
|
|
|
CVector parallelSpeed = m_vecMoveSpeed - DotProduct(m_vecMoveSpeed, GetUp())*GetUp();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
float fSpeed = parallelSpeed.MagnitudeSqr();
|
2020-06-04 15:38:41 +00:00
|
|
|
|
if(fSpeed > SQR(0.3f)){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
fSpeed = Sqrt(fSpeed);
|
|
|
|
|
parallelSpeed *= 0.3f / fSpeed;
|
|
|
|
|
slowdown = SAND_SLOWDOWN * Max(1.0f - 2.0f*fSpeed, 0.2f);
|
|
|
|
|
}else{
|
|
|
|
|
bStuckInSand = true;
|
|
|
|
|
slowdown = SAND_SLOWDOWN;
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_GOOD_INSAND)
|
|
|
|
|
slowdown *= 0.5f;
|
|
|
|
|
if(CWeather::WetRoads > 0.2f)
|
|
|
|
|
slowdown *= (1.2f - CWeather::WetRoads);
|
|
|
|
|
ApplyMoveForce(parallelSpeed * -CTimer::GetTimeStep()*slowdown*m_fMass);
|
|
|
|
|
drivingInSand = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if(pDriver && pDriver->IsPlayer() &&
|
|
|
|
|
(pDriver->GetPedState() == PED_ARRESTED ||
|
|
|
|
|
pDriver->GetPedState() == PED_DRAG_FROM_CAR ||
|
2020-06-22 01:02:44 +00:00
|
|
|
|
(pDriver->GetPedState() == PED_EXIT_CAR || pDriver->m_objective == OBJECTIVE_LEAVE_CAR) && !CanPedJumpOutCar())){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bIsHandbrakeOn = true;
|
|
|
|
|
m_fBrakePedal = 1.0f;
|
|
|
|
|
m_fGasPedal = 0.0f;
|
2019-07-17 11:19:20 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(CPad::GetPad(0)->WeaponJustDown())
|
|
|
|
|
ActivateBomb();
|
2019-07-17 11:19:20 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case STATUS_SIMPLE:
|
2019-07-17 11:19:20 +00:00
|
|
|
|
CCarAI::UpdateCarAI(this);
|
|
|
|
|
CPhysical::ProcessControl();
|
|
|
|
|
CCarCtrl::UpdateCarOnRails(this);
|
|
|
|
|
|
|
|
|
|
m_nWheelsOnGround = 4;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
m_nDriveWheelsOnGroundPrev = m_nDriveWheelsOnGround;
|
|
|
|
|
m_nDriveWheelsOnGround = 4;
|
2019-07-17 11:19:20 +00:00
|
|
|
|
|
|
|
|
|
pHandling->Transmission.CalculateGearForSimpleCar(AutoPilot.m_fMaxTrafficSpeed/50.0f, m_nCurrentGear);
|
|
|
|
|
|
2020-06-04 15:38:41 +00:00
|
|
|
|
wheelRot = ProcessWheelRotation(WHEEL_STATE_NORMAL, GetForward(), m_vecMoveSpeed, 0.35f);
|
2019-07-17 11:19:20 +00:00
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
m_aWheelRotation[i] += wheelRot;
|
|
|
|
|
|
|
|
|
|
PlayHornIfNecessary();
|
|
|
|
|
ReduceHornCounter();
|
|
|
|
|
bVehicleColProcessed = false;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bAudioChangingGear = false;
|
2019-07-17 11:19:20 +00:00
|
|
|
|
// that's all we do for simple vehicles
|
|
|
|
|
return;
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case STATUS_PHYSICS:
|
2019-07-17 11:19:20 +00:00
|
|
|
|
CCarAI::UpdateCarAI(this);
|
|
|
|
|
CCarCtrl::SteerAICarWithPhysics(this);
|
|
|
|
|
PlayHornIfNecessary();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
|
|
|
|
if(bIsBeingCarJacked){
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
m_fBrakePedal = 1.0f;
|
|
|
|
|
bIsHandbrakeOn = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_aSuspensionSpringRatio[0] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[0].surfaceB) == ADHESIVE_SAND ||
|
|
|
|
|
m_aSuspensionSpringRatio[1] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[1].surfaceB) == ADHESIVE_SAND ||
|
|
|
|
|
m_aSuspensionSpringRatio[2] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[2].surfaceB) == ADHESIVE_SAND ||
|
|
|
|
|
m_aSuspensionSpringRatio[3] < 1.0f && CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[3].surfaceB) == ADHESIVE_SAND){
|
|
|
|
|
if(GetModelIndex() != MI_RCBANDIT && GetModelIndex() != MI_SANDKING && GetModelIndex() != MI_BFINJECT){
|
|
|
|
|
bStuckInSand = true;
|
|
|
|
|
if(CWeather::WetRoads > 0.0f)
|
|
|
|
|
ApplyMoveForce(m_vecMoveSpeed * -CTimer::GetTimeStep()*SAND_SLOWDOWN*m_fMass * (1.0f-CWeather::WetRoads));
|
|
|
|
|
else
|
|
|
|
|
ApplyMoveForce(m_vecMoveSpeed * -CTimer::GetTimeStep()*SAND_SLOWDOWN*m_fMass);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-17 11:19:20 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case STATUS_ABANDONED:
|
2020-06-04 15:38:41 +00:00
|
|
|
|
if(m_vecMoveSpeed.MagnitudeSqr() < SQR(0.1f))
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_fBrakePedal = 0.2f;
|
|
|
|
|
else
|
|
|
|
|
m_fBrakePedal = 0.0f;
|
2019-07-17 11:19:20 +00:00
|
|
|
|
bIsHandbrakeOn = false;
|
|
|
|
|
|
|
|
|
|
m_fSteerAngle = 0.0f;
|
|
|
|
|
m_fGasPedal = 0.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!IsAlarmOn())
|
|
|
|
|
m_nCarHornTimer = 0;
|
|
|
|
|
|
|
|
|
|
if(bIsBeingCarJacked){
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
m_fBrakePedal = 1.0f;
|
|
|
|
|
bIsHandbrakeOn = true;
|
|
|
|
|
}
|
2019-07-17 11:19:20 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case STATUS_WRECKED:
|
2019-07-17 11:19:20 +00:00
|
|
|
|
m_fBrakePedal = 0.05f;
|
|
|
|
|
bIsHandbrakeOn = true;
|
|
|
|
|
|
|
|
|
|
m_fSteerAngle = 0.0f;
|
|
|
|
|
m_fGasPedal = 0.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!IsAlarmOn())
|
|
|
|
|
m_nCarHornTimer = 0;
|
2019-07-17 11:19:20 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case STATUS_PLAYER_DISABLED:
|
2020-06-04 15:38:41 +00:00
|
|
|
|
if(m_vecMoveSpeed.MagnitudeSqr() < SQR(0.1f) ||
|
2020-05-31 15:05:49 +00:00
|
|
|
|
(pDriver && pDriver->IsPlayer() &&
|
|
|
|
|
(pDriver->GetPedState() == PED_ARRESTED ||
|
|
|
|
|
pDriver->GetPedState() == PED_DRAG_FROM_CAR ||
|
2020-06-22 01:02:44 +00:00
|
|
|
|
(pDriver->GetPedState() == PED_EXIT_CAR || pDriver->m_objective == OBJECTIVE_LEAVE_CAR) && !CanPedJumpOutCar()))){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bIsHandbrakeOn = true;
|
|
|
|
|
m_fBrakePedal = 1.0f;
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
}else{
|
|
|
|
|
m_fBrakePedal = 0.0f;
|
|
|
|
|
bIsHandbrakeOn = false;
|
|
|
|
|
}
|
2019-07-17 11:19:20 +00:00
|
|
|
|
|
|
|
|
|
m_fSteerAngle = 0.0f;
|
|
|
|
|
m_fGasPedal = 0.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!IsAlarmOn())
|
|
|
|
|
m_nCarHornTimer = 0;
|
2019-07-17 11:19:20 +00:00
|
|
|
|
break;
|
2020-05-11 23:24:57 +00:00
|
|
|
|
default: break;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 21:58:06 +00:00
|
|
|
|
// Skip physics if object is found to have been static recently
|
2019-07-16 17:48:50 +00:00
|
|
|
|
bool skipPhysics = false;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(!bIsStuck && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED)){
|
2019-07-17 21:58:06 +00:00
|
|
|
|
bool makeStatic = false;
|
|
|
|
|
float moveSpeedLimit, turnSpeedLimit, distanceLimit;
|
|
|
|
|
|
|
|
|
|
if(!bVehicleColProcessed &&
|
|
|
|
|
m_vecMoveSpeed.IsZero() &&
|
|
|
|
|
// BUG? m_aSuspensionSpringRatioPrev[3] is checked twice in the game. also, why 3?
|
|
|
|
|
m_aSuspensionSpringRatioPrev[3] != 1.0f)
|
|
|
|
|
makeStatic = true;
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_WRECKED){
|
2019-07-17 21:58:06 +00:00
|
|
|
|
moveSpeedLimit = 0.006f;
|
|
|
|
|
turnSpeedLimit = 0.0015f;
|
|
|
|
|
distanceLimit = 0.015f;
|
|
|
|
|
}else{
|
|
|
|
|
moveSpeedLimit = 0.003f;
|
|
|
|
|
turnSpeedLimit = 0.0009f;
|
|
|
|
|
distanceLimit = 0.005f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_vecMoveSpeedAvg = (m_vecMoveSpeedAvg + m_vecMoveSpeed)/2.0f;
|
|
|
|
|
m_vecTurnSpeedAvg = (m_vecTurnSpeedAvg + m_vecTurnSpeed)/2.0f;
|
|
|
|
|
|
|
|
|
|
if(m_vecMoveSpeedAvg.MagnitudeSqr() <= sq(moveSpeedLimit*CTimer::GetTimeStep()) &&
|
|
|
|
|
m_vecTurnSpeedAvg.MagnitudeSqr() <= sq(turnSpeedLimit*CTimer::GetTimeStep()) &&
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_fDistanceTravelled < distanceLimit &&
|
|
|
|
|
!(m_fDamageImpulse > 0.0f && m_pDamageEntity && m_pDamageEntity->IsPed()) ||
|
2019-07-17 21:58:06 +00:00
|
|
|
|
makeStatic){
|
|
|
|
|
m_nStaticFrames++;
|
|
|
|
|
|
|
|
|
|
if(m_nStaticFrames > 10 || makeStatic)
|
|
|
|
|
if(!CCarCtrl::MapCouldMoveInThisArea(GetPosition().x, GetPosition().y)){
|
|
|
|
|
if(!makeStatic || m_nStaticFrames > 10)
|
|
|
|
|
m_nStaticFrames = 10;
|
|
|
|
|
|
|
|
|
|
skipPhysics = true;
|
|
|
|
|
|
|
|
|
|
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
m_nStaticFrames = 0;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(IsRealHeli() && m_aWheelSpeed[1] > 0.0f){
|
|
|
|
|
skipPhysics = false;
|
|
|
|
|
m_nStaticFrames = 0;
|
|
|
|
|
}
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Postpone
|
|
|
|
|
for(i = 0; i < 4; i++)
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_aGroundPhysical[i]){
|
|
|
|
|
bRestingOnPhysical = true;
|
|
|
|
|
if(!CWorld::bForceProcessControl && m_aGroundPhysical[i]->bIsInSafePosition){
|
|
|
|
|
bWasPostponed = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(bRestingOnPhysical){
|
|
|
|
|
skipPhysics = false;
|
|
|
|
|
m_nStaticFrames = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 19:41:20 +00:00
|
|
|
|
VehicleDamage(0.0f, 0);
|
2019-07-16 17:48:50 +00:00
|
|
|
|
|
|
|
|
|
// special control
|
|
|
|
|
switch(GetModelIndex()){
|
|
|
|
|
case MI_FIRETRUCK:
|
2019-07-17 21:58:06 +00:00
|
|
|
|
FireTruckControl();
|
|
|
|
|
break;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
case MI_RHINO:
|
2019-07-17 21:58:06 +00:00
|
|
|
|
TankControl();
|
|
|
|
|
BlowUpCarsInPath();
|
|
|
|
|
break;
|
2020-05-07 09:33:20 +00:00
|
|
|
|
case MI_VOODOO:
|
2019-07-17 21:58:06 +00:00
|
|
|
|
HydraulicControl();
|
|
|
|
|
break;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
default:
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(CVehicle::bCheat3 || carHasNitro){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
// Make vehicle jump when horn is sounded
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER && m_vecMoveSpeed.MagnitudeSqr() > sq(0.2f) &&
|
2019-07-18 13:41:09 +00:00
|
|
|
|
// BUG: game checks [0] four times, instead of all wheels
|
|
|
|
|
m_aSuspensionSpringRatio[0] < 1.0f &&
|
|
|
|
|
CPad::GetPad(0)->HornJustDown()){
|
|
|
|
|
|
2019-07-26 12:27:13 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_1, 0.0f);
|
2019-07-18 13:41:09 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_JUMP, 1.0f);
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM,
|
|
|
|
|
m_aWheelColPoints[0].point + 0.5f*GetUp(),
|
|
|
|
|
1.3f*m_vecMoveSpeed, nil, 2.5f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE,
|
|
|
|
|
m_aWheelColPoints[0].point + 0.5f*GetUp(),
|
|
|
|
|
1.2f*m_vecMoveSpeed, nil, 2.0f);
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM,
|
|
|
|
|
m_aWheelColPoints[2].point + 0.5f*GetUp(),
|
|
|
|
|
1.3f*m_vecMoveSpeed, nil, 2.5f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE,
|
|
|
|
|
m_aWheelColPoints[2].point + 0.5f*GetUp(),
|
|
|
|
|
1.2f*m_vecMoveSpeed, nil, 2.0f);
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM,
|
|
|
|
|
m_aWheelColPoints[0].point + 0.5f*GetUp() - GetForward(),
|
|
|
|
|
1.3f*m_vecMoveSpeed, nil, 2.5f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE,
|
|
|
|
|
m_aWheelColPoints[0].point + 0.5f*GetUp() - GetForward(),
|
|
|
|
|
1.2f*m_vecMoveSpeed, nil, 2.0f);
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM,
|
|
|
|
|
m_aWheelColPoints[2].point + 0.5f*GetUp() - GetForward(),
|
|
|
|
|
1.3f*m_vecMoveSpeed, nil, 2.5f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE,
|
|
|
|
|
m_aWheelColPoints[2].point + 0.5f*GetUp() - GetForward(),
|
|
|
|
|
1.2f*m_vecMoveSpeed, nil, 2.0f);
|
|
|
|
|
|
|
|
|
|
ApplyMoveForce(CVector(0.0f, 0.0f, 1.0f)*m_fMass*0.4f);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
ApplyTurnForce(GetUp()*m_fTurnMass*0.01f, GetForward()*1.0f);
|
2019-07-18 13:41:09 +00:00
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetStatus() == STATUS_PHYSICS || GetStatus() == STATUS_SIMPLE)
|
|
|
|
|
if(AutoPilot.m_nCarMission == MISSION_HELI_FLYTOCOORS ||
|
|
|
|
|
AutoPilot.m_nCarMission == MISSION_PLANE_FLYTOCOORS)
|
|
|
|
|
skipPhysics = true;
|
|
|
|
|
|
2019-07-18 13:41:09 +00:00
|
|
|
|
float brake;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
if(skipPhysics){
|
|
|
|
|
bHasContacted = false;
|
|
|
|
|
bIsInSafePosition = false;
|
|
|
|
|
bWasPostponed = false;
|
|
|
|
|
bHasHitWall = false;
|
|
|
|
|
m_nCollisionRecords = 0;
|
|
|
|
|
bHasCollided = false;
|
|
|
|
|
bVehicleColProcessed = false;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bAudioChangingGear = false;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
m_nDamagePieceType = 0;
|
|
|
|
|
m_fDamageImpulse = 0.0f;
|
|
|
|
|
m_pDamageEntity = nil;
|
|
|
|
|
m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
m_vecMoveFriction = CVector(0.0f, 0.0f, 0.0f);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_fTireTemperature = 1.0f;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
// This has to be done if ProcessEntityCollision wasn't called
|
|
|
|
|
if(!bVehicleColProcessed){
|
|
|
|
|
CMatrix mat(GetMatrix());
|
|
|
|
|
bIsStuck = false;
|
|
|
|
|
bHasContacted = false;
|
|
|
|
|
bIsInSafePosition = false;
|
|
|
|
|
bWasPostponed = false;
|
|
|
|
|
bHasHitWall = false;
|
|
|
|
|
m_fDistanceTravelled = 0.0f;
|
2020-04-19 04:14:13 +00:00
|
|
|
|
m_bIsVehicleBeingShifted = false;
|
2020-04-30 15:58:15 +00:00
|
|
|
|
bSkipLineCol = false;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
ApplyMoveSpeed();
|
|
|
|
|
ApplyTurnSpeed();
|
|
|
|
|
for(i = 0; CheckCollision() && i < 5; i++){
|
|
|
|
|
GetMatrix() = mat;
|
|
|
|
|
ApplyMoveSpeed();
|
|
|
|
|
ApplyTurnSpeed();
|
|
|
|
|
}
|
|
|
|
|
bIsInSafePosition = true;
|
|
|
|
|
bIsStuck = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CPhysical::ProcessControl();
|
|
|
|
|
|
|
|
|
|
ProcessBuoyancy();
|
|
|
|
|
|
|
|
|
|
// Rescale spring ratios, i.e. subtract wheel radius
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
// wheel radius in relation to suspension line
|
|
|
|
|
float wheelRadius = 1.0f - m_aSuspensionSpringLength[i]/m_aSuspensionLineLength[i];
|
|
|
|
|
// rescale such that 0.0 is fully compressed and 1.0 is fully extended
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (m_aSuspensionSpringRatio[i]-wheelRadius)/(1.0f-wheelRadius);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
float fwdSpeed = Abs(DotProduct(m_vecMoveSpeed, GetForward()));
|
2019-07-16 17:48:50 +00:00
|
|
|
|
CVector contactPoints[4]; // relative to model
|
|
|
|
|
CVector contactSpeeds[4]; // speed at contact points
|
|
|
|
|
CVector springDirections[4]; // normalized, in model space
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
// Set spring under certain circumstances
|
|
|
|
|
if(Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
else if(Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST){
|
|
|
|
|
// wheel more bumpy the faster we are
|
|
|
|
|
if(CGeneral::GetRandomNumberInRange(0, (uint16)(40*fwdSpeed) + 98) < 100){
|
|
|
|
|
m_aSuspensionSpringRatio[i] += 0.3f*(m_aSuspensionLineLength[i]-m_aSuspensionSpringLength[i])/m_aSuspensionSpringLength[i];
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(CSurfaceTable::GetAdhesionGroup(m_aWheelColPoints[i].surfaceB) == ADHESIVE_SAND &&
|
|
|
|
|
GetModelIndex() != MI_RHINO){
|
|
|
|
|
fwdSpeed *= 0.7f;
|
|
|
|
|
float f = 1.0f - fwdSpeed/0.3f - 0.7f*CWeather::WetRoads;
|
|
|
|
|
f = Max(f, 0.4f);
|
2020-06-06 22:01:48 +00:00
|
|
|
|
m_aSuspensionSpringRatio[i] += 0.35f*f*(m_aSuspensionLineLength[i]-m_aSuspensionSpringLength[i])/m_aSuspensionSpringLength[i];
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get points and directions if spring is compressed
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
|
|
|
|
contactPoints[i] = m_aWheelColPoints[i].point - GetPosition();
|
|
|
|
|
springDirections[i] = Multiply3x3(GetMatrix(), colModel->lines[i].p1 - colModel->lines[i].p0);
|
|
|
|
|
springDirections[i].Normalise();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make springs push up vehicle
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
2019-07-17 11:19:20 +00:00
|
|
|
|
float bias = pHandling->fSuspensionBias;
|
2020-06-04 15:38:41 +00:00
|
|
|
|
if(i == CARWHEEL_REAR_LEFT || i == CARWHEEL_REAR_RIGHT)
|
2019-07-16 17:48:50 +00:00
|
|
|
|
bias = 1.0f - bias;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
ApplySpringCollisionAlt(pHandling->fSuspensionForceLevel,
|
2019-07-16 17:48:50 +00:00
|
|
|
|
springDirections[i], contactPoints[i],
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aSuspensionSpringRatio[i], bias, m_aWheelColPoints[i].normal);
|
|
|
|
|
|
|
|
|
|
m_aWheelSkidmarkUnk[i] = false;
|
|
|
|
|
if(m_aWheelColPoints[i].surfaceB == SURFACE_GRASS ||
|
|
|
|
|
m_aWheelColPoints[i].surfaceB == SURFACE_MUD_DRY)
|
|
|
|
|
m_aWheelSkidmarkType[i] = SKIDMARK_MUDDY;
|
|
|
|
|
else if(m_aWheelColPoints[i].surfaceB == SURFACE_SAND ||
|
|
|
|
|
m_aWheelColPoints[i].surfaceB == SURFACE_SAND_BEACH){
|
|
|
|
|
m_aWheelSkidmarkType[i] = SKIDMARK_SANDY;
|
|
|
|
|
m_aWheelSkidmarkUnk[i] = true;
|
|
|
|
|
}else
|
|
|
|
|
m_aWheelSkidmarkType[i] = SKIDMARK_NORMAL;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}else{
|
|
|
|
|
contactPoints[i] = Multiply3x3(GetMatrix(), colModel->lines[i].p1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get speed at contact points
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
contactSpeeds[i] = GetSpeed(contactPoints[i]);
|
|
|
|
|
if(m_aGroundPhysical[i]){
|
|
|
|
|
// subtract movement of physical we're standing on
|
|
|
|
|
contactSpeeds[i] -= m_aGroundPhysical[i]->GetSpeed(m_aGroundOffset[i]);
|
|
|
|
|
#ifndef FIX_BUGS
|
|
|
|
|
// this shouldn't be reset because we still need it below
|
|
|
|
|
m_aGroundPhysical[i] = nil;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f && m_aWheelColPoints[i].normal.z > 0.35f)
|
|
|
|
|
springDirections[i] = -m_aWheelColPoints[i].normal;
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dampen springs
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f)
|
2019-07-17 11:19:20 +00:00
|
|
|
|
ApplySpringDampening(pHandling->fSuspensionDampingLevel,
|
2019-07-16 17:48:50 +00:00
|
|
|
|
springDirections[i], contactPoints[i], contactSpeeds[i]);
|
|
|
|
|
|
|
|
|
|
// Get speed at contact points again
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
contactSpeeds[i] = GetSpeed(contactPoints[i]);
|
|
|
|
|
if(m_aGroundPhysical[i]){
|
|
|
|
|
// subtract movement of physical we're standing on
|
|
|
|
|
contactSpeeds[i] -= m_aGroundPhysical[i]->GetSpeed(m_aGroundOffset[i]);
|
|
|
|
|
m_aGroundPhysical[i] = nil;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 21:58:06 +00:00
|
|
|
|
bool gripCheat = true;
|
|
|
|
|
fwdSpeed = DotProduct(m_vecMoveSpeed, GetForward());
|
|
|
|
|
if(!strongGrip1 && !CVehicle::bCheat3)
|
|
|
|
|
gripCheat = false;
|
|
|
|
|
float acceleration = pHandling->Transmission.CalculateDriveAcceleration(m_fGasPedal, m_nCurrentGear, m_fChangeGearTime, fwdSpeed, gripCheat);
|
2020-04-12 22:02:11 +00:00
|
|
|
|
acceleration /= m_fForceMultiplier;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(IsRealHeli() || IsRealPlane())
|
2019-07-17 21:58:06 +00:00
|
|
|
|
acceleration = 0.0f;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(bAudioChangingGear && m_fGasPedal > 0.4f && m_fBrakePedal < 0.1f && fwdSpeed > 0.15f &&
|
|
|
|
|
this == FindPlayerVehicle() && TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_1STPERSON){
|
|
|
|
|
if(GetStatus() == STATUS_PLAYER && pHandling->Flags & HANDLING_IS_BUS){
|
|
|
|
|
if(m_nBusDoorTimerEnd == 0)
|
|
|
|
|
m_nBusDoorTimerEnd = 1000;
|
2020-06-01 18:51:18 +00:00
|
|
|
|
else if(m_nBusDoorTimerEnd > CTimer::GetTimeStepInMilliseconds())
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_nBusDoorTimerEnd -= CTimer::GetTimeStepInMilliseconds();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-08 17:34:59 +00:00
|
|
|
|
if((m_aSuspensionSpringRatio[0] < 1.0f || m_aSuspensionSpringRatio[2] < 1.0f) &&
|
|
|
|
|
(m_aSuspensionSpringRatio[1] < 1.0f || m_aSuspensionSpringRatio[3] < 1.0f))
|
2020-06-01 08:56:15 +00:00
|
|
|
|
ApplyTurnForce(-GRAVITY*Min(m_fTurnMass, 2500.0f)*GetUp(), -1.0f*GetForward());
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 13:41:09 +00:00
|
|
|
|
brake = m_fBrakePedal * pHandling->fBrakeDeceleration * CTimer::GetTimeStep();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bool neutralHandling = GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && (pHandling->Flags & HANDLING_NEUTRALHANDLING);
|
2019-07-17 21:58:06 +00:00
|
|
|
|
float brakeBiasFront = neutralHandling ? 1.0f : 2.0f*pHandling->fBrakeBias;
|
|
|
|
|
float brakeBiasRear = neutralHandling ? 1.0f : 2.0f*(1.0f-pHandling->fBrakeBias);
|
|
|
|
|
float tractionBiasFront = neutralHandling ? 1.0f : 2.0f*pHandling->fTractionBias;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
float tractionBiasRear = neutralHandling ? 1.0f : 2.0f-tractionBiasFront;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
|
|
|
|
// Count how many wheels are touching the ground
|
|
|
|
|
|
|
|
|
|
m_nWheelsOnGround = 0;
|
|
|
|
|
m_nDriveWheelsOnGroundPrev = m_nDriveWheelsOnGround;
|
|
|
|
|
m_nDriveWheelsOnGround = 0;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f)
|
|
|
|
|
m_aWheelTimer[i] = 4.0f;
|
|
|
|
|
else
|
2020-04-19 16:34:08 +00:00
|
|
|
|
m_aWheelTimer[i] = Max(m_aWheelTimer[i]-CTimer::GetTimeStep(), 0.0f);
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[i] > 0.0f){
|
|
|
|
|
m_nWheelsOnGround++;
|
|
|
|
|
switch(pHandling->Transmission.nDriveType){
|
|
|
|
|
case '4':
|
|
|
|
|
m_nDriveWheelsOnGround++;
|
|
|
|
|
break;
|
|
|
|
|
case 'F':
|
|
|
|
|
if(i == CARWHEEL_FRONT_LEFT || i == CARWHEEL_FRONT_RIGHT)
|
|
|
|
|
m_nDriveWheelsOnGround++;
|
|
|
|
|
break;
|
|
|
|
|
case 'R':
|
|
|
|
|
if(i == CARWHEEL_REAR_LEFT || i == CARWHEEL_REAR_RIGHT)
|
|
|
|
|
m_nDriveWheelsOnGround++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float traction;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PHYSICS)
|
2019-07-17 21:58:06 +00:00
|
|
|
|
traction = 0.004f * m_fTraction;
|
|
|
|
|
else
|
|
|
|
|
traction = 0.004f;
|
|
|
|
|
traction *= pHandling->fTractionMultiplier / 4.0f;
|
2020-04-12 22:02:11 +00:00
|
|
|
|
traction /= m_fForceMultiplier;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
if(CVehicle::bCheat3)
|
|
|
|
|
traction *= 4.0f;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(FindPlayerVehicle() != this && (strongGrip1 || CVehicle::bCheat3)){
|
2019-07-17 21:58:06 +00:00
|
|
|
|
traction *= 1.2f;
|
|
|
|
|
acceleration *= 1.4f;
|
|
|
|
|
if(strongGrip2 || CVehicle::bCheat3){
|
|
|
|
|
traction *= 1.3f;
|
|
|
|
|
acceleration *= 1.4f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float fThrust;
|
|
|
|
|
static tWheelState WheelState[4];
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bool rearWheelsFirst = !!(pHandling->Flags & HANDLING_REARWHEEL_1ST);
|
|
|
|
|
|
|
|
|
|
// Process front wheels on ground - first try
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!rearWheelsFirst){
|
2019-07-17 21:58:06 +00:00
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f || m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
|
|
|
|
|
float s = Sin(m_fSteerAngle);
|
|
|
|
|
float c = Cos(m_fSteerAngle);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
|
|
|
|
CVector wheelFwd, wheelRight, tmp;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
|
|
|
|
|
fThrust = 0.0f;
|
|
|
|
|
else
|
|
|
|
|
fThrust = acceleration;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
wheelFwd = GetForward();
|
|
|
|
|
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal;
|
|
|
|
|
wheelFwd.Normalise();
|
|
|
|
|
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal);
|
|
|
|
|
wheelRight.Normalise();
|
|
|
|
|
tmp = c*wheelFwd - s*wheelRight;
|
|
|
|
|
wheelRight = s*wheelFwd + c*wheelRight;
|
|
|
|
|
wheelFwd = tmp;
|
|
|
|
|
|
2020-05-26 09:34:20 +00:00
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceA = SURFACE_WHEELBASE;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_LEFT])*traction;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER)
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB);
|
|
|
|
|
WheelState[CARWHEEL_FRONT_LEFT] = m_aWheelState[CARWHEEL_FRONT_LEFT];
|
|
|
|
|
|
|
|
|
|
if(Damage.GetWheelStatus(VEHWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_LEFT], contactPoints[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront*Damage.m_fWheelDamageEffect,
|
|
|
|
|
CARWHEEL_FRONT_LEFT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
WHEEL_STATUS_BURST);
|
|
|
|
|
else
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_LEFT], contactPoints[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront,
|
|
|
|
|
CARWHEEL_FRONT_LEFT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
WHEEL_STATUS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
|
|
|
|
|
fThrust = 0.0f;
|
|
|
|
|
else
|
|
|
|
|
fThrust = acceleration;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
wheelFwd = GetForward();
|
|
|
|
|
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal;
|
|
|
|
|
wheelFwd.Normalise();
|
|
|
|
|
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal);
|
|
|
|
|
wheelRight.Normalise();
|
|
|
|
|
tmp = c*wheelFwd - s*wheelRight;
|
|
|
|
|
wheelRight = s*wheelFwd + c*wheelRight;
|
|
|
|
|
wheelFwd = tmp;
|
|
|
|
|
|
2020-05-26 09:34:20 +00:00
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceA = SURFACE_WHEELBASE;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT])*traction;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER)
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB);
|
|
|
|
|
WheelState[CARWHEEL_FRONT_RIGHT] = m_aWheelState[CARWHEEL_FRONT_RIGHT];
|
|
|
|
|
|
|
|
|
|
if(Damage.GetWheelStatus(VEHWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_RIGHT], contactPoints[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront*Damage.m_fWheelDamageEffect,
|
|
|
|
|
CARWHEEL_FRONT_RIGHT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
WHEEL_STATUS_BURST);
|
|
|
|
|
else
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_RIGHT], contactPoints[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront,
|
|
|
|
|
CARWHEEL_FRONT_RIGHT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
WHEEL_STATUS_OK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process front wheels off ground
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!IsRealHeli()){
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
|
|
|
|
|
else{
|
|
|
|
|
if(acceleration > 0.0f){
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] < 2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] -= 0.2f;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] > -2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] += 0.1f;
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelRotation[CARWHEEL_FRONT_LEFT] += m_aWheelSpeed[CARWHEEL_FRONT_LEFT];
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] <= 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
|
|
|
|
|
else{
|
|
|
|
|
if(acceleration > 0.0f){
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] < 2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] -= 0.2f;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] > -2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] += 0.1f;
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelRotation[CARWHEEL_FRONT_RIGHT] += m_aWheelSpeed[CARWHEEL_FRONT_RIGHT];
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process rear wheels
|
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f || m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
|
|
|
|
|
CVector wheelFwd = GetForward();
|
|
|
|
|
CVector wheelRight = GetRight();
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
float rearBrake = brake;
|
|
|
|
|
float rearTraction = traction;
|
|
|
|
|
if(bIsHandbrakeOn){
|
2020-05-18 14:55:38 +00:00
|
|
|
|
#ifdef FIX_BUGS
|
2020-05-31 15:05:49 +00:00
|
|
|
|
// Not sure if this is needed, but brake usually has timestep as a factor
|
|
|
|
|
rearBrake = 20000.0f * CTimer::GetTimeStepFix();
|
2020-05-18 14:55:38 +00:00
|
|
|
|
#else
|
2020-05-31 15:05:49 +00:00
|
|
|
|
rearBrake = 20000.0f;
|
2020-05-18 14:55:38 +00:00
|
|
|
|
#endif
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(fwdSpeed > 0.1f && pHandling->Flags & HANDLING_HANDBRAKE_TYRE){
|
|
|
|
|
m_fTireTemperature += 0.005*CTimer::GetTimeStep();
|
|
|
|
|
if(m_fTireTemperature > 2.0f)
|
|
|
|
|
m_fTireTemperature = 2.0f;
|
|
|
|
|
}
|
|
|
|
|
}else if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier)){
|
|
|
|
|
rearBrake = 0.0f;
|
|
|
|
|
rearTraction = 0.0f;
|
2020-06-04 15:38:41 +00:00
|
|
|
|
// BUG: missing timestep
|
2020-05-31 15:05:49 +00:00
|
|
|
|
ApplyTurnForce(contactPoints[CARWHEEL_REAR_LEFT], -0.001f*m_fTurnMass*m_fSteerAngle*GetRight());
|
|
|
|
|
}else if(m_fTireTemperature > 1.0f){
|
|
|
|
|
rearTraction *= m_fTireTemperature;
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
|
|
|
|
|
fThrust = 0.0f;
|
|
|
|
|
else
|
|
|
|
|
fThrust = acceleration;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
wheelFwd = GetForward();
|
|
|
|
|
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal)*m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal;
|
|
|
|
|
wheelFwd.Normalise();
|
|
|
|
|
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal);
|
|
|
|
|
wheelRight.Normalise();
|
|
|
|
|
|
2020-05-26 09:34:20 +00:00
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceA = SURFACE_WHEELBASE;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_LEFT])*rearTraction;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER)
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB);
|
|
|
|
|
WheelState[CARWHEEL_REAR_LEFT] = m_aWheelState[CARWHEEL_REAR_LEFT];
|
|
|
|
|
|
|
|
|
|
if(Damage.GetWheelStatus(VEHWHEEL_REAR_LEFT) == WHEEL_STATUS_BURST)
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_REAR_LEFT], contactPoints[CARWHEEL_REAR_LEFT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
rearBrake*brakeBiasRear,
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion*tractionBiasRear*Damage.m_fWheelDamageEffect,
|
|
|
|
|
CARWHEEL_REAR_LEFT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_REAR_LEFT],
|
|
|
|
|
&WheelState[CARWHEEL_REAR_LEFT],
|
|
|
|
|
WHEEL_STATUS_BURST);
|
|
|
|
|
else
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_REAR_LEFT], contactPoints[CARWHEEL_REAR_LEFT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
rearBrake*brakeBiasRear,
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion*tractionBiasRear,
|
|
|
|
|
CARWHEEL_REAR_LEFT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_REAR_LEFT],
|
|
|
|
|
&WheelState[CARWHEEL_REAR_LEFT],
|
|
|
|
|
WHEEL_STATUS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
#ifdef FIX_BUGS
|
|
|
|
|
// Shouldn't we reset these after the left wheel?
|
|
|
|
|
wheelFwd = GetForward();
|
|
|
|
|
wheelRight = GetRight();
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-17 21:58:06 +00:00
|
|
|
|
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
|
|
|
|
|
fThrust = 0.0f;
|
|
|
|
|
else
|
|
|
|
|
fThrust = acceleration;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
wheelFwd = GetForward();
|
|
|
|
|
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal;
|
|
|
|
|
wheelFwd.Normalise();
|
|
|
|
|
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal);
|
|
|
|
|
wheelRight.Normalise();
|
|
|
|
|
|
2020-05-26 09:34:20 +00:00
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceA = SURFACE_WHEELBASE;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_RIGHT])*rearTraction;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER)
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB);
|
|
|
|
|
WheelState[CARWHEEL_REAR_RIGHT] = m_aWheelState[CARWHEEL_REAR_RIGHT];
|
|
|
|
|
|
|
|
|
|
if(Damage.GetWheelStatus(VEHWHEEL_REAR_RIGHT) == WHEEL_STATUS_BURST)
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_REAR_RIGHT], contactPoints[CARWHEEL_REAR_RIGHT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
rearBrake*brakeBiasRear,
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion*tractionBiasRear*Damage.m_fWheelDamageEffect,
|
|
|
|
|
CARWHEEL_REAR_RIGHT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_REAR_RIGHT],
|
|
|
|
|
&WheelState[CARWHEEL_REAR_RIGHT],
|
|
|
|
|
WHEEL_STATUS_BURST);
|
|
|
|
|
else
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_REAR_RIGHT], contactPoints[CARWHEEL_REAR_RIGHT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
rearBrake*brakeBiasRear,
|
2019-07-17 21:58:06 +00:00
|
|
|
|
adhesion*tractionBiasRear,
|
|
|
|
|
CARWHEEL_REAR_RIGHT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_REAR_RIGHT],
|
|
|
|
|
&WheelState[CARWHEEL_REAR_RIGHT],
|
|
|
|
|
WHEEL_STATUS_OK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) &&
|
2020-06-04 15:38:41 +00:00
|
|
|
|
(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING || m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING)){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_fTireTemperature += 0.001f*CTimer::GetTimeStep();
|
|
|
|
|
if(m_fTireTemperature > 3.0f)
|
|
|
|
|
m_fTireTemperature = 3.0f;
|
|
|
|
|
}else if(m_fTireTemperature > 1.0f){
|
|
|
|
|
m_fTireTemperature = (m_fTireTemperature - 1.0f)*Pow(0.995f, CTimer::GetTimeStep()) + 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 21:58:06 +00:00
|
|
|
|
// Process rear wheels off ground
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!IsRealHeli()){
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] <= 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_REAR_LEFT] *= 0.95f;
|
|
|
|
|
else{
|
|
|
|
|
if(acceleration > 0.0f){
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] < 2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_REAR_LEFT] -= 0.2f;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] > -2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_REAR_LEFT] += 0.1f;
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelRotation[CARWHEEL_REAR_LEFT] += m_aWheelSpeed[CARWHEEL_REAR_LEFT];
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] <= 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] *= 0.95f;
|
|
|
|
|
else{
|
|
|
|
|
if(acceleration > 0.0f){
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] < 2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] -= 0.2f;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] > -2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] += 0.1f;
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelRotation[CARWHEEL_REAR_RIGHT] += m_aWheelSpeed[CARWHEEL_REAR_RIGHT];
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process front wheels on ground - second try
|
|
|
|
|
|
|
|
|
|
if(rearWheelsFirst){
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f || m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
|
|
|
|
|
float s = Sin(m_fSteerAngle);
|
|
|
|
|
float c = Cos(m_fSteerAngle);
|
|
|
|
|
|
|
|
|
|
CVector wheelFwd, wheelRight, tmp;
|
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
|
|
|
|
|
fThrust = 0.0f;
|
|
|
|
|
else
|
|
|
|
|
fThrust = acceleration;
|
|
|
|
|
|
|
|
|
|
wheelFwd = GetForward();
|
|
|
|
|
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal;
|
|
|
|
|
wheelFwd.Normalise();
|
|
|
|
|
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal);
|
|
|
|
|
wheelRight.Normalise();
|
|
|
|
|
tmp = c*wheelFwd - s*wheelRight;
|
|
|
|
|
wheelRight = s*wheelFwd + c*wheelRight;
|
|
|
|
|
wheelFwd = tmp;
|
|
|
|
|
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceA = SURFACE_WHEELBASE;
|
|
|
|
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_LEFT])*traction;
|
|
|
|
|
if(GetStatus() == STATUS_PLAYER)
|
|
|
|
|
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB);
|
|
|
|
|
WheelState[CARWHEEL_FRONT_LEFT] = m_aWheelState[CARWHEEL_FRONT_LEFT];
|
|
|
|
|
|
|
|
|
|
if(Damage.GetWheelStatus(VEHWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_LEFT], contactPoints[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront*Damage.m_fWheelDamageEffect,
|
|
|
|
|
CARWHEEL_FRONT_LEFT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
WHEEL_STATUS_BURST);
|
|
|
|
|
else
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_LEFT], contactPoints[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront,
|
|
|
|
|
CARWHEEL_FRONT_LEFT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_LEFT],
|
|
|
|
|
WHEEL_STATUS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
|
|
|
|
|
fThrust = 0.0f;
|
|
|
|
|
else
|
|
|
|
|
fThrust = acceleration;
|
|
|
|
|
|
|
|
|
|
wheelFwd = GetForward();
|
|
|
|
|
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal;
|
|
|
|
|
wheelFwd.Normalise();
|
|
|
|
|
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal);
|
|
|
|
|
wheelRight.Normalise();
|
|
|
|
|
tmp = c*wheelFwd - s*wheelRight;
|
|
|
|
|
wheelRight = s*wheelFwd + c*wheelRight;
|
|
|
|
|
wheelFwd = tmp;
|
|
|
|
|
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceA = SURFACE_WHEELBASE;
|
|
|
|
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT])*traction;
|
|
|
|
|
if(GetStatus() == STATUS_PLAYER)
|
|
|
|
|
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB);
|
|
|
|
|
WheelState[CARWHEEL_FRONT_RIGHT] = m_aWheelState[CARWHEEL_FRONT_RIGHT];
|
|
|
|
|
|
|
|
|
|
if(Damage.GetWheelStatus(VEHWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_RIGHT], contactPoints[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront*Damage.m_fWheelDamageEffect,
|
|
|
|
|
CARWHEEL_FRONT_RIGHT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
WHEEL_STATUS_BURST);
|
|
|
|
|
else
|
|
|
|
|
ProcessWheel(wheelFwd, wheelRight,
|
|
|
|
|
contactSpeeds[CARWHEEL_FRONT_RIGHT], contactPoints[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
m_nWheelsOnGround, fThrust,
|
|
|
|
|
brake*brakeBiasFront,
|
|
|
|
|
adhesion*tractionBiasFront,
|
|
|
|
|
CARWHEEL_FRONT_RIGHT,
|
|
|
|
|
&m_aWheelSpeed[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
&WheelState[CARWHEEL_FRONT_RIGHT],
|
|
|
|
|
WHEEL_STATUS_OK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process front wheels off ground
|
|
|
|
|
|
2020-09-28 23:29:10 +00:00
|
|
|
|
if (!IsRealHeli()) {
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
|
|
|
|
|
else{
|
|
|
|
|
if(acceleration > 0.0f){
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] < 2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] -= 0.2f;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] > -2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] += 0.1f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_aWheelRotation[CARWHEEL_FRONT_LEFT] += m_aWheelSpeed[CARWHEEL_FRONT_LEFT];
|
|
|
|
|
}
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] <= 0.0f){
|
|
|
|
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
|
|
|
|
|
else{
|
|
|
|
|
if(acceleration > 0.0f){
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] < 2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] -= 0.2f;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] > -2.0f)
|
|
|
|
|
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] += 0.1f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_aWheelRotation[CARWHEEL_FRONT_RIGHT] += m_aWheelSpeed[CARWHEEL_FRONT_RIGHT];
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
float wheelPos = colModel->lines[i].p0.z;
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 0.0f)
|
2019-07-18 13:41:09 +00:00
|
|
|
|
wheelPos -= m_aSuspensionSpringRatio[i]*m_aSuspensionSpringLength[i];
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetModelIndex() == MI_VOODOO && bUsingSpecialColModel)
|
|
|
|
|
m_aWheelPosition[i] = wheelPos;
|
|
|
|
|
else
|
|
|
|
|
m_aWheelPosition[i] += (wheelPos - m_aWheelPosition[i])*0.75f;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
m_aWheelState[i] = WheelState[i];
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_fGasPedal < 0.0f){
|
|
|
|
|
if(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING)
|
|
|
|
|
m_aWheelState[CARWHEEL_REAR_LEFT] = WHEEL_STATE_NORMAL;
|
|
|
|
|
if(m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING)
|
|
|
|
|
m_aWheelState[CARWHEEL_REAR_RIGHT] = WHEEL_STATE_NORMAL;
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
|
|
|
|
|
// Process horn
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() != STATUS_PLAYER){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!IsAlarmOn())
|
|
|
|
|
ReduceHornCounter();
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}else{
|
2020-07-08 14:26:23 +00:00
|
|
|
|
if(UsesSiren()){
|
2019-07-17 21:58:06 +00:00
|
|
|
|
if(Pads[0].bHornHistory[Pads[0].iCurrHornHistory]){
|
|
|
|
|
if(Pads[0].bHornHistory[(Pads[0].iCurrHornHistory+4) % 5] &&
|
|
|
|
|
Pads[0].bHornHistory[(Pads[0].iCurrHornHistory+3) % 5])
|
|
|
|
|
m_nCarHornTimer = 1;
|
|
|
|
|
else
|
|
|
|
|
m_nCarHornTimer = 0;
|
|
|
|
|
}else if(Pads[0].bHornHistory[(Pads[0].iCurrHornHistory+4) % 5] &&
|
|
|
|
|
!Pads[0].bHornHistory[(Pads[0].iCurrHornHistory+1) % 5]){
|
|
|
|
|
m_nCarHornTimer = 0;
|
|
|
|
|
m_bSirenOrAlarm = !m_bSirenOrAlarm;
|
|
|
|
|
}else
|
|
|
|
|
m_nCarHornTimer = 0;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(GetModelIndex() != MI_VOODOO && !CVehicle::bCheat3 && !carHasNitro){
|
|
|
|
|
if(!IsAlarmOn()){
|
|
|
|
|
if(Pads[0].GetHorn())
|
|
|
|
|
m_nCarHornTimer = 1;
|
|
|
|
|
else
|
|
|
|
|
m_nCarHornTimer = 0;
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Flying
|
|
|
|
|
|
2020-06-04 15:38:41 +00:00
|
|
|
|
bool playRotorSound = false;
|
2020-09-30 23:20:09 +00:00
|
|
|
|
bool isPlane = GetModelIndex() == MI_DODO || bAllDodosCheat;
|
|
|
|
|
#ifdef FIX_BUGS
|
|
|
|
|
isPlane = isPlane && !IsRealHeli();
|
|
|
|
|
#endif
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PHYSICS){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(IsRealHeli()){
|
|
|
|
|
bEngineOn = false;
|
|
|
|
|
m_aWheelSpeed[1] = Max(m_aWheelSpeed[1]-0.0005f, 0.0f);
|
|
|
|
|
if(GetModelIndex() != MI_RCRAIDER && GetModelIndex() != MI_RCGOBLIN)
|
|
|
|
|
if(m_aWheelSpeed[1] < 0.154f && m_aWheelSpeed[1] > 0.0044f)
|
2020-06-04 15:38:41 +00:00
|
|
|
|
playRotorSound = true;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}
|
2020-09-30 23:20:09 +00:00
|
|
|
|
}else if(isPlane && m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetModelIndex() == MI_DODO)
|
2020-04-25 18:25:14 +00:00
|
|
|
|
FlyingControl(FLIGHT_MODEL_DODO);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
else
|
|
|
|
|
FlyingControl(FLIGHT_MODEL_PLANE);
|
2020-05-07 09:33:20 +00:00
|
|
|
|
}else if(GetModelIndex() == MI_RCBARON){
|
2019-11-09 15:17:54 +00:00
|
|
|
|
FlyingControl(FLIGHT_MODEL_RCPLANE);
|
2020-05-10 18:51:29 +00:00
|
|
|
|
}else if(IsRealHeli() || bAllCarCheat){
|
2020-09-28 23:29:10 +00:00
|
|
|
|
#ifdef RESTORE_ALLCARSHELI_CHEAT
|
|
|
|
|
if (bAllCarCheat)
|
|
|
|
|
FlyingControl(FLIGHT_MODEL_HELI);
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
// Speed up rotor
|
|
|
|
|
if (m_aWheelSpeed[1] < 0.22f && !bIsInWater) {
|
|
|
|
|
if (GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN)
|
|
|
|
|
m_aWheelSpeed[1] += 0.003f;
|
|
|
|
|
else
|
|
|
|
|
m_aWheelSpeed[1] += 0.001f;
|
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
2020-09-28 23:29:10 +00:00
|
|
|
|
// Fly
|
|
|
|
|
if (m_aWheelSpeed[1] > 0.15f) {
|
|
|
|
|
if (GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN)
|
|
|
|
|
FlyingControl(FLIGHT_MODEL_RCHELI);
|
|
|
|
|
else if (m_nWheelsOnGround < 4 && !(GetModelIndex() == MI_SEASPAR && bTouchingWater) ||
|
|
|
|
|
CPad::GetPad(0)->GetAccelerate() != 0 || CPad::GetPad(0)->GetCarGunUpDown() > 1.0f ||
|
|
|
|
|
Abs(m_vecMoveSpeed.x) > 0.02f ||
|
|
|
|
|
Abs(m_vecMoveSpeed.y) > 0.02f ||
|
|
|
|
|
Abs(m_vecMoveSpeed.z) > 0.02f)
|
|
|
|
|
FlyingControl(FLIGHT_MODEL_HELI);
|
|
|
|
|
}
|
2020-04-25 18:25:14 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
|
|
|
|
// Blade collision
|
|
|
|
|
if(m_aWheelSpeed[1] > 0.015f && m_aCarNodes[CAR_BONNET]){
|
|
|
|
|
CMatrix mat;
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET]));
|
|
|
|
|
if(GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN)
|
|
|
|
|
DoBladeCollision(mat.GetPosition(), GetMatrix(), ROTOR_TOP, 0.72f, 0.9f);
|
|
|
|
|
else if(GetModelIndex() == MI_SPARROW || GetModelIndex() == MI_SEASPAR)
|
|
|
|
|
DoBladeCollision(mat.GetPosition(), GetMatrix(), ROTOR_TOP, 5.15f, 0.8f);
|
|
|
|
|
else if(GetModelIndex() == MI_HUNTER)
|
|
|
|
|
DoBladeCollision(mat.GetPosition(), GetMatrix(), ROTOR_TOP, 6.15f, 0.5f);
|
|
|
|
|
else
|
|
|
|
|
DoBladeCollision(mat.GetPosition(), GetMatrix(), ROTOR_TOP, 6.15f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Heli weapons
|
|
|
|
|
if(GetModelIndex() == MI_HUNTER && GetStatus() == STATUS_PLAYER){
|
|
|
|
|
// Hunter rockets
|
|
|
|
|
if(CPad::GetPad(0)->CarGunJustDown() && CTimer::GetTimeInMilliseconds() > m_nGunFiringTime+350){
|
|
|
|
|
CWeapon gun(WEAPONTYPE_ROCKETLAUNCHER, 100);
|
|
|
|
|
CVector source = vecHunterRocketPos;
|
|
|
|
|
source = GetMatrix()*source + Max(DotProduct(m_vecMoveSpeed, GetForward()), 0.0f)*GetForward()*CTimer::GetTimeStep();
|
|
|
|
|
gun.FireProjectile(this, &source, 0.0f);
|
|
|
|
|
|
|
|
|
|
source = vecHunterRocketPos;
|
|
|
|
|
source.x = -source.x;
|
|
|
|
|
source = GetMatrix()*source + Max(DotProduct(m_vecMoveSpeed, GetForward()), 0.0f)*GetForward()*CTimer::GetTimeStep();
|
|
|
|
|
gun.FireProjectile(this, &source, 0.0f);
|
|
|
|
|
|
|
|
|
|
CStats::RoundsFiredByPlayer++;
|
2020-06-03 13:16:31 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_nGunFiringTime = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
// Hunter gun
|
|
|
|
|
}else if(CPad::GetPad(0)->GetHandBrake() && CTimer::GetTimeInMilliseconds() > m_nGunFiringTime+60){
|
|
|
|
|
CWeapon gun(WEAPONTYPE_HELICANNON, 5000);
|
|
|
|
|
CVector source = vecHunterGunPos;
|
|
|
|
|
source = GetMatrix()*source + m_vecMoveSpeed*CTimer::GetTimeStep();
|
|
|
|
|
gun.FireInstantHit(this, &source);
|
|
|
|
|
gun.AddGunshell(this, source, CVector2D(0.0f, 0.1f), 0.025f);
|
|
|
|
|
CStats::RoundsFiredByPlayer++;
|
2020-06-03 13:16:31 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_nGunFiringTime = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
}
|
|
|
|
|
}else if(GetModelIndex() == MI_SEASPAR && GetStatus() == STATUS_PLAYER){
|
|
|
|
|
// Sea sparrow gun
|
|
|
|
|
if(CPad::GetPad(0)->GetHandBrake() && CTimer::GetTimeInMilliseconds() > m_nGunFiringTime+40){
|
|
|
|
|
CWeapon gun(WEAPONTYPE_M4, 5000);
|
|
|
|
|
CVector source = vecSeaSparrowGunPos;
|
|
|
|
|
source = GetMatrix()*source + m_vecMoveSpeed*CTimer::GetTimeStep();
|
|
|
|
|
gun.FireInstantHit(this, &source);
|
|
|
|
|
gun.AddGunshell(this, source, CVector2D(0.0f, 0.1f), 0.025f);
|
|
|
|
|
CStats::RoundsFiredByPlayer++;
|
2020-06-03 13:16:31 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_nGunFiringTime = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(GetModelIndex() != MI_RCRAIDER && GetModelIndex() != MI_RCGOBLIN)
|
|
|
|
|
if(m_aWheelSpeed[1] < 0.154f && m_aWheelSpeed[1] > 0.0044f)
|
2020-06-04 15:38:41 +00:00
|
|
|
|
playRotorSound = true;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
2020-06-04 15:38:41 +00:00
|
|
|
|
// Play rotor sound
|
|
|
|
|
if(playRotorSound && m_aCarNodes[CAR_BONNET]){
|
|
|
|
|
CVector camDist = TheCamera.GetPosition() - GetPosition();
|
|
|
|
|
float distSq = camDist.MagnitudeSqr();
|
|
|
|
|
if(distSq < SQR(20.0f) && Abs(m_fPropellerRotation - m_aWheelRotation[1]) > DEGTORAD(30.0f)){
|
|
|
|
|
CMatrix mat;
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET]));
|
|
|
|
|
CVector blade = mat.GetRight();
|
2020-09-26 01:10:00 +00:00
|
|
|
|
blade = Multiply3x3(blade, GetMatrix());
|
2020-06-04 15:38:41 +00:00
|
|
|
|
camDist /= Max(Sqrt(distSq), 0.01f);
|
|
|
|
|
if(Abs(DotProduct(camDist, blade)) > 0.95f){
|
2020-10-25 21:11:04 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_HELI_BLADE, 0.0f);
|
2020-06-04 15:38:41 +00:00
|
|
|
|
m_fPropellerRotation = m_aWheelRotation[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 13:41:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Process car on fire
|
|
|
|
|
// A similar calculation of damagePos is done elsewhere for smoke
|
|
|
|
|
|
|
|
|
|
uint8 engineStatus = Damage.GetEngineStatus();
|
|
|
|
|
CVector damagePos = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->m_positions[CAR_POS_HEADLIGHTS];
|
|
|
|
|
|
|
|
|
|
switch(Damage.GetDoorStatus(DOOR_BONNET)){
|
|
|
|
|
case DOOR_STATUS_OK:
|
|
|
|
|
case DOOR_STATUS_SMASHED:
|
|
|
|
|
// Bonnet is still there, smoke comes out at the edge
|
|
|
|
|
damagePos += vecDAMAGE_ENGINE_POS_SMALL;
|
|
|
|
|
break;
|
|
|
|
|
case DOOR_STATUS_SWINGING:
|
|
|
|
|
case DOOR_STATUS_MISSING:
|
|
|
|
|
// Bonnet is gone, smoke comes out at the engine
|
|
|
|
|
damagePos += vecDAMAGE_ENGINE_POS_BIG;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// move fire forward if in first person
|
|
|
|
|
if(this == FindPlayerVehicle() && TheCamera.GetLookingForwardFirstPerson())
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(m_fHealth < 250.0f && GetStatus() != STATUS_WRECKED){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(GetModelIndex() == MI_FIRETRUCK)
|
|
|
|
|
damagePos += CVector(0.0f, 3.0f, -0.2f);
|
|
|
|
|
else
|
|
|
|
|
damagePos += CVector(0.0f, 1.2f, -0.8f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
damagePos = GetMatrix()*damagePos;
|
|
|
|
|
damagePos.z += 0.15f;
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(m_fHealth < 250.0f && GetStatus() != STATUS_WRECKED){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
// Car is on fire
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CARFLAME, damagePos,
|
|
|
|
|
CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.01125f, 0.09f)),
|
2020-05-31 15:05:49 +00:00
|
|
|
|
nil, 0.63f);
|
2019-07-18 13:41:09 +00:00
|
|
|
|
|
|
|
|
|
CVector coors = damagePos;
|
|
|
|
|
coors.x += CGeneral::GetRandomNumberInRange(-0.5625f, 0.5625f),
|
|
|
|
|
coors.y += CGeneral::GetRandomNumberInRange(-0.5625f, 0.5625f),
|
|
|
|
|
coors.z += CGeneral::GetRandomNumberInRange(0.5625f, 2.25f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CARFLAME_SMOKE, coors, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE2, damagePos, CVector(0.0f, 0.0f, 0.0f), nil, 0.5f);
|
|
|
|
|
|
|
|
|
|
// Blow up car after 5 seconds
|
|
|
|
|
m_fFireBlowUpTimer += CTimer::GetTimeStepInMilliseconds();
|
2020-06-05 13:09:45 +00:00
|
|
|
|
if(m_fFireBlowUpTimer > 5000.0f)
|
2019-07-18 13:41:09 +00:00
|
|
|
|
BlowUpCar(m_pSetOnFireEntity);
|
|
|
|
|
}else
|
|
|
|
|
m_fFireBlowUpTimer = 0.0f;
|
|
|
|
|
|
|
|
|
|
// Decrease car health if engine is damaged badly
|
2019-07-18 19:41:20 +00:00
|
|
|
|
if(engineStatus > ENGINE_STATUS_ON_FIRE && m_fHealth > 250.0f)
|
2019-07-18 13:41:09 +00:00
|
|
|
|
m_fHealth -= 2.0f;
|
|
|
|
|
|
|
|
|
|
ProcessDelayedExplosion();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(m_bSirenOrAlarm && (CTimer::GetFrameCounter()&7) == 5 &&
|
2020-07-08 14:26:23 +00:00
|
|
|
|
UsesSiren() && GetModelIndex() != MI_MRWHOOP)
|
2019-07-18 13:41:09 +00:00
|
|
|
|
CCarAI::MakeWayForCarWithSiren(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find out how much to shake the pad depending on suspension and ground surface
|
|
|
|
|
|
|
|
|
|
float suspShake = 0.0f;
|
|
|
|
|
float surfShake = 0.0f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
float speedsq = m_vecMoveSpeed.MagnitudeSqr();
|
2019-07-18 13:41:09 +00:00
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
float suspChange = m_aSuspensionSpringRatioPrev[i] - m_aSuspensionSpringRatio[i];
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(suspChange > 0.3f && !drivingInSand && speedsq > 0.04f){
|
2020-06-04 15:38:41 +00:00
|
|
|
|
if(Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_JUMP_2, suspChange);
|
|
|
|
|
else
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_JUMP, suspChange);
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(suspChange > suspShake)
|
|
|
|
|
suspShake = suspChange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8 surf = m_aWheelColPoints[i].surfaceB;
|
2020-05-26 09:34:20 +00:00
|
|
|
|
if(surf == SURFACE_GRAVEL || surf == SURFACE_WATER || surf == SURFACE_HEDGE){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(surfShake < 0.2f)
|
|
|
|
|
surfShake = 0.3f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(surf == SURFACE_MUD_DRY){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(surfShake < 0.1f)
|
|
|
|
|
surfShake = 0.2f;
|
|
|
|
|
}else if(surf == SURFACE_GRASS){
|
|
|
|
|
if(surfShake < 0.05f)
|
|
|
|
|
surfShake = 0.1f;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(this == FindPlayerVehicle())
|
|
|
|
|
// BUG: this only observes one of the wheels
|
2020-06-04 22:24:42 +00:00
|
|
|
|
TheCamera.m_bVehicleSuspenHigh = Abs(suspChange) > 0.05f;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
2019-07-18 13:41:09 +00:00
|
|
|
|
m_aSuspensionSpringRatioPrev[i] = m_aSuspensionSpringRatio[i];
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shake pad
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!drivingInSand && (suspShake > 0.0f || surfShake > 0.0f) && GetStatus() == STATUS_PLAYER){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
float speed = m_vecMoveSpeed.MagnitudeSqr();
|
|
|
|
|
if(speed > sq(0.1f)){
|
|
|
|
|
speed = Sqrt(speed);
|
|
|
|
|
if(suspShake > 0.0f){
|
2020-04-19 16:34:08 +00:00
|
|
|
|
uint8 freq = Min(200.0f*suspShake*speed*2000.0f/m_fMass + 100.0f, 250.0f);
|
2019-07-18 13:41:09 +00:00
|
|
|
|
CPad::GetPad(0)->StartShake(20000.0f*CTimer::GetTimeStep()/freq, freq);
|
|
|
|
|
}else{
|
2020-05-31 15:05:49 +00:00
|
|
|
|
uint8 freq = Min(200.0f*surfShake*speed*2000.0f/m_fMass + 40.0f, 150.0f);
|
2019-07-18 13:41:09 +00:00
|
|
|
|
CPad::GetPad(0)->StartShake(5000.0f*CTimer::GetTimeStep()/freq, freq);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bVehicleColProcessed = false;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bAudioChangingGear = false;
|
2019-07-18 13:41:09 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!bWarnedPeds && GetVehicleAppearance() != VEHICLE_APPEARANCE_HELI && GetVehicleAppearance() != VEHICLE_APPEARANCE_PLANE)
|
2019-07-18 13:41:09 +00:00
|
|
|
|
CCarCtrl::ScanForPedDanger(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Turn around at the edge of the world
|
|
|
|
|
// TODO: make the numbers defines
|
|
|
|
|
|
|
|
|
|
float heading;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetPosition().x > 1950.0f-400.0f){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(m_vecMoveSpeed.x > 0.0f)
|
|
|
|
|
m_vecMoveSpeed.x *= -1.0f;
|
|
|
|
|
heading = GetForward().Heading();
|
|
|
|
|
if(heading > 0.0f) // going west
|
|
|
|
|
SetHeading(-heading);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(GetPosition().x < -1950.0f-400.0f){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(m_vecMoveSpeed.x < 0.0f)
|
|
|
|
|
m_vecMoveSpeed.x *= -1.0f;
|
|
|
|
|
heading = GetForward().Heading();
|
|
|
|
|
if(heading < 0.0f) // going east
|
|
|
|
|
SetHeading(-heading);
|
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetPosition().y > 1950.0f){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(m_vecMoveSpeed.y > 0.0f)
|
|
|
|
|
m_vecMoveSpeed.y *= -1.0f;
|
|
|
|
|
heading = GetForward().Heading();
|
|
|
|
|
if(heading < HALFPI && heading > 0.0f)
|
|
|
|
|
SetHeading(PI-heading);
|
|
|
|
|
else if(heading > -HALFPI && heading < 0.0f)
|
|
|
|
|
SetHeading(-PI-heading);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(GetPosition().y < -1950.0f){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(m_vecMoveSpeed.y < 0.0f)
|
|
|
|
|
m_vecMoveSpeed.y *= -1.0f;
|
|
|
|
|
heading = GetForward().Heading();
|
|
|
|
|
if(heading > HALFPI)
|
|
|
|
|
SetHeading(PI-heading);
|
|
|
|
|
else if(heading < -HALFPI)
|
|
|
|
|
SetHeading(-PI-heading);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bInfiniteMass){
|
|
|
|
|
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
m_vecMoveFriction = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
}else if(!skipPhysics &&
|
2020-04-30 13:45:45 +00:00
|
|
|
|
(m_fGasPedal == 0.0f && brake == 0.0f || GetStatus() == STATUS_WRECKED)){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(Abs(m_vecMoveSpeed.x) < 0.005f &&
|
|
|
|
|
Abs(m_vecMoveSpeed.y) < 0.005f &&
|
2020-05-31 15:05:49 +00:00
|
|
|
|
Abs(m_vecMoveSpeed.z) < 0.005f &&
|
|
|
|
|
!(m_fDamageImpulse > 0.0f && m_pDamageEntity == FindPlayerPed()) &&
|
|
|
|
|
(m_aSuspensionSpringRatioPrev[0] < 1.0f && m_aSuspensionSpringRatioPrev[1] < 1.0f &&
|
|
|
|
|
m_aSuspensionSpringRatioPrev[2] < 1.0f && m_aSuspensionSpringRatioPrev[3] < 1.0f)){
|
2019-07-18 13:41:09 +00:00
|
|
|
|
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
m_vecTurnSpeed.z = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
|
|
|
|
if(IsRealHeli() && bHeliDestroyed && !bRenderScorched){
|
|
|
|
|
ApplyMoveForce(0.0f, 0.0f, -2.0f*CTimer::GetTimeStep());
|
|
|
|
|
m_vecTurnSpeed.z += -0.002f*CTimer::GetTimeStep();
|
|
|
|
|
m_vecTurnSpeed.x += -0.0002f*CTimer::GetTimeStep();
|
|
|
|
|
|
|
|
|
|
RwRGBA col = { 84, 84, 84, 255 };
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE, GetMatrix()*CVector(0.0f, 0.0f, -10.0f),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f), nil, 0.7f, col, 0, 0, 0, 3000);
|
|
|
|
|
|
|
|
|
|
if(CWorld::TestSphereAgainstWorld(GetPosition(), 10.0f, this, true, false, false, false, false, false) ||
|
|
|
|
|
GetPosition().z < 6.0f)
|
|
|
|
|
if(!bRenderScorched){ // we already know this is true...
|
|
|
|
|
CExplosion::AddExplosion(this, nil, EXPLOSION_CAR, GetPosition(), 0);
|
|
|
|
|
bRenderScorched = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
2019-07-08 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::Teleport(CVector pos)
|
|
|
|
|
{
|
|
|
|
|
CWorld::Remove(this);
|
|
|
|
|
|
2020-05-02 12:28:19 +00:00
|
|
|
|
SetPosition(pos);
|
2019-07-08 19:37:47 +00:00
|
|
|
|
SetOrientation(0.0f, 0.0f, 0.0f);
|
|
|
|
|
SetMoveSpeed(0.0f, 0.0f, 0.0f);
|
|
|
|
|
SetTurnSpeed(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
ResetSuspension();
|
|
|
|
|
|
|
|
|
|
CWorld::Add(this);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 11:14:08 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::PreRender(void)
|
|
|
|
|
{
|
|
|
|
|
int i, j, n;
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetModelIndex() == MI_RHINO && m_aCarNodes[CAR_BONNET]){
|
|
|
|
|
// Rotate Rhino turret
|
|
|
|
|
CMatrix m;
|
|
|
|
|
CVector p;
|
|
|
|
|
m.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET]));
|
|
|
|
|
p = m.GetPosition();
|
|
|
|
|
m.SetRotateZ(m_fCarGunLR);
|
|
|
|
|
m.Translate(p);
|
|
|
|
|
m.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(GetModelIndex() == MI_RCBANDIT){
|
|
|
|
|
CVector pos = GetMatrix() * CVector(0.218f, -0.444f, 0.391f);
|
|
|
|
|
CAntennas::RegisterOne((uintptr)this, GetUp(), pos, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float fwdSpeed = DotProduct(m_vecMoveSpeed, GetForward())*180.0f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wheel particles
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetModelIndex() == MI_DODO || GetVehicleAppearance() != VEHICLE_APPEARANCE_CAR){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
; // nothing
|
|
|
|
|
}else if(GetModelIndex() == MI_RCBANDIT){
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
// Game has same code three times here
|
|
|
|
|
switch(m_aWheelState[i]){
|
|
|
|
|
case WHEEL_STATE_SPINNING:
|
|
|
|
|
case WHEEL_STATE_SKIDDING:
|
|
|
|
|
case WHEEL_STATE_FIXED:
|
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[i].point + CVector(0.0f, 0.0f, 0.05f),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f), nil, 0.1f);
|
|
|
|
|
break;
|
2020-05-11 23:24:57 +00:00
|
|
|
|
default: break;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_SIMPLE){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
CMatrix mat;
|
|
|
|
|
CVector pos;
|
|
|
|
|
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RB]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
pos.z = 1.5f*m_aWheelPosition[CARWHEEL_REAR_RIGHT];
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].point = GetMatrix() * pos;
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB = SURFACE_DEFAULT;
|
|
|
|
|
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LB]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
pos.z = 1.5f*m_aWheelPosition[CARWHEEL_REAR_LEFT];
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].point = GetMatrix() * pos;
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB = SURFACE_DEFAULT;
|
|
|
|
|
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
pos.z = 1.5f*m_aWheelPosition[CARWHEEL_FRONT_RIGHT];
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].point = GetMatrix() * pos;
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB = SURFACE_DEFAULT;
|
|
|
|
|
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
pos.z = 1.5f*m_aWheelPosition[CARWHEEL_FRONT_LEFT];
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].point = GetMatrix() * pos;
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB = SURFACE_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int drawParticles = Abs(fwdSpeed) < 90.0f;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_SIMPLE || GetStatus() == STATUS_PHYSICS ||
|
2020-05-31 15:05:49 +00:00
|
|
|
|
GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PLAYER_PLAYBACKFROMBUFFER){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
bool rearSkidding = false;
|
|
|
|
|
if(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SKIDDING ||
|
|
|
|
|
m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SKIDDING)
|
|
|
|
|
rearSkidding = true;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_aSuspensionSpringRatioPrev[i] < 1.0f && m_aWheelColPoints[i].surfaceB != SURFACE_WATER)
|
2019-07-28 11:14:08 +00:00
|
|
|
|
switch(m_aWheelState[i]){
|
|
|
|
|
case WHEEL_STATE_SPINNING:
|
|
|
|
|
if(AddWheelDirtAndWater(&m_aWheelColPoints[i], drawParticles)){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_BURNINGRUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[i].point + CVector(0.0f, 0.0f, 0.25f),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_BURNINGRUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[i].point + CVector(0.0f, 0.0f, 0.25f),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.05f));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[i].point + CVector(0.0f, 0.0f, 0.25f),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[i] > 0.0f)
|
|
|
|
|
CSkidmarks::RegisterOne((uintptr)this + i, m_aWheelColPoints[i].point,
|
|
|
|
|
GetForward().x, GetForward().y,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelSkidmarkType[i], &m_aWheelSkidmarkBloody[i]);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WHEEL_STATE_SKIDDING:
|
|
|
|
|
if(i == CARWHEEL_REAR_LEFT || i == CARWHEEL_REAR_RIGHT || rearSkidding){
|
|
|
|
|
// same as below
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(Abs(fwdSpeed) > 5.0f){
|
|
|
|
|
AddWheelDirtAndWater(&m_aWheelColPoints[i], drawParticles);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[i].point + CVector(0.0f, 0.0f, 0.25f),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[i] > 0.0f)
|
|
|
|
|
CSkidmarks::RegisterOne((uintptr)this + i, m_aWheelColPoints[i].point,
|
|
|
|
|
GetForward().x, GetForward().y,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelSkidmarkType[i], &m_aWheelSkidmarkBloody[i]);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WHEEL_STATE_FIXED:
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(Abs(fwdSpeed) > 5.0f){
|
|
|
|
|
AddWheelDirtAndWater(&m_aWheelColPoints[i], drawParticles);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[i].point + CVector(0.0f, 0.0f, 0.25f),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[i] > 0.0f)
|
|
|
|
|
CSkidmarks::RegisterOne((uintptr)this + i, m_aWheelColPoints[i].point,
|
|
|
|
|
GetForward().x, GetForward().y,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelSkidmarkType[i], &m_aWheelSkidmarkBloody[i]);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if(Abs(fwdSpeed) > 0.5f)
|
|
|
|
|
AddWheelDirtAndWater(&m_aWheelColPoints[i], drawParticles);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if((m_aWheelSkidmarkBloody[i] || m_aWheelSkidmarkUnk[i]) && m_aWheelTimer[i] > 0.0f)
|
2019-07-28 11:14:08 +00:00
|
|
|
|
CSkidmarks::RegisterOne((uintptr)this + i, m_aWheelColPoints[i].point,
|
|
|
|
|
GetForward().x, GetForward().y,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelSkidmarkType[i], &m_aWheelSkidmarkBloody[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sparks for friction of burst wheels
|
|
|
|
|
if(Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST && m_aSuspensionSpringRatioPrev[i] < 1.0f){
|
|
|
|
|
static float speedSq;
|
|
|
|
|
speedSq = m_vecMoveSpeed.MagnitudeSqr();
|
2020-06-06 22:01:48 +00:00
|
|
|
|
if(speedSq > SQR(0.1f) &&
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelColPoints[i].surfaceB != SURFACE_GRASS &&
|
|
|
|
|
m_aWheelColPoints[i].surfaceB != SURFACE_MUD_DRY &&
|
|
|
|
|
m_aWheelColPoints[i].surfaceB != SURFACE_SAND &&
|
|
|
|
|
m_aWheelColPoints[i].surfaceB != SURFACE_SAND_BEACH &&
|
|
|
|
|
m_aWheelColPoints[i].surfaceB != SURFACE_WATER){
|
|
|
|
|
CVector normalSpeed = m_aWheelColPoints[i].normal * DotProduct(m_aWheelColPoints[i].normal, m_vecMoveSpeed);
|
|
|
|
|
CVector frictionSpeed = m_vecMoveSpeed - normalSpeed;
|
|
|
|
|
if(i == CARWHEEL_FRONT_LEFT || i == CARWHEEL_REAR_LEFT)
|
|
|
|
|
frictionSpeed -= 0.05f*GetRight();
|
|
|
|
|
else
|
|
|
|
|
frictionSpeed += 0.05f*GetRight();
|
|
|
|
|
CVector unusedRight = 0.15f*GetRight();
|
|
|
|
|
CVector sparkDir = 0.25f*frictionSpeed;
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, m_aWheelColPoints[i].point, sparkDir);
|
|
|
|
|
|
|
|
|
|
if(speedSq > 0.04f)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, m_aWheelColPoints[i].point, sparkDir);
|
|
|
|
|
if(speedSq > 0.16f){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, m_aWheelColPoints[i].point, sparkDir);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, m_aWheelColPoints[i].point, sparkDir);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_aCarNodes[CAR_WHEEL_RM]){
|
|
|
|
|
// assume middle wheels are two units before rear ones
|
|
|
|
|
CVector offset = GetForward()*2.0f;
|
|
|
|
|
|
|
|
|
|
switch(m_aWheelState[CARWHEEL_REAR_LEFT]){
|
|
|
|
|
// Game has same code three times here
|
|
|
|
|
case WHEEL_STATE_SPINNING:
|
|
|
|
|
case WHEEL_STATE_SKIDDING:
|
|
|
|
|
case WHEEL_STATE_FIXED:
|
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].point + CVector(0.0f, 0.0f, 0.25f) + offset,
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f)
|
|
|
|
|
CSkidmarks::RegisterOne((uintptr)this + CARWHEEL_REAR_LEFT,
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].point + offset,
|
|
|
|
|
GetForward().x, GetForward().y,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelSkidmarkType[CARWHEEL_REAR_LEFT], &m_aWheelSkidmarkBloody[CARWHEEL_REAR_LEFT]);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
break;
|
2020-05-11 23:24:57 +00:00
|
|
|
|
default: break;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(m_aWheelState[CARWHEEL_REAR_RIGHT]){
|
|
|
|
|
// Game has same code three times here
|
|
|
|
|
case WHEEL_STATE_SPINNING:
|
|
|
|
|
case WHEEL_STATE_SKIDDING:
|
|
|
|
|
case WHEEL_STATE_FIXED:
|
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE,
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].point + CVector(0.0f, 0.0f, 0.25f) + offset,
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
|
|
|
|
|
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f)
|
|
|
|
|
CSkidmarks::RegisterOne((uintptr)this + CARWHEEL_REAR_RIGHT,
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].point + offset,
|
|
|
|
|
GetForward().x, GetForward().y,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
m_aWheelSkidmarkType[CARWHEEL_REAR_RIGHT], &m_aWheelSkidmarkBloody[CARWHEEL_REAR_RIGHT]);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
break;
|
2020-05-11 23:24:57 +00:00
|
|
|
|
default: break;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Rain on roof
|
|
|
|
|
if(!CCullZones::CamNoRain() && !CCullZones::PlayerNoRain() &&
|
|
|
|
|
Abs(fwdSpeed) < 20.0f && CWeather::Rain > 0.02f){
|
|
|
|
|
CColModel *colModel = GetColModel();
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < colModel->numTriangles; i++){
|
|
|
|
|
CVector p1, p2, p3, c;
|
|
|
|
|
|
|
|
|
|
colModel->GetTrianglePoint(p1, colModel->triangles[i].a);
|
|
|
|
|
p1 = GetMatrix() * p1;
|
|
|
|
|
colModel->GetTrianglePoint(p2, colModel->triangles[i].b);
|
|
|
|
|
p2 = GetMatrix() * p2;
|
|
|
|
|
colModel->GetTrianglePoint(p3, colModel->triangles[i].c);
|
|
|
|
|
p3 = GetMatrix() * p3;
|
|
|
|
|
c = (p1 + p2 + p3)/3.0f;
|
|
|
|
|
|
|
|
|
|
n = 6.0f*CWeather::Rain;
|
|
|
|
|
for(j = 0; j <= n; j++)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
c + CVector(CGeneral::GetRandomNumberInRange(-0.4f, 0.4f), CGeneral::GetRandomNumberInRange(-0.4f, 0.4f), 0.0f),
|
2019-07-28 11:14:08 +00:00
|
|
|
|
CVector(0.0f, 0.0f, 0.0f),
|
|
|
|
|
nil, 0.0f, 0, 0, CGeneral::GetRandomNumber() & 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddDamagedVehicleParticles();
|
|
|
|
|
|
|
|
|
|
// Exhaust smoke
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(bEngineOn && !(pHandling->Flags & HANDLING_NO_EXHAUST) && fwdSpeed < 130.0f){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
CVector exhaustPos = mi->m_positions[CAR_POS_EXHAUST];
|
2020-05-31 15:05:49 +00:00
|
|
|
|
CVector pos1, pos2, dir1, dir2;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
if(exhaustPos != CVector(0.0f, 0.0f, 0.0f)){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
dir1.z = 0.0f;
|
|
|
|
|
dir2.z = 0.0f;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(fwdSpeed < 10.0f){
|
|
|
|
|
CVector steerFwd(-Sin(m_fSteerAngle), Cos(m_fSteerAngle), 0.0f);
|
|
|
|
|
steerFwd = Multiply3x3(GetMatrix(), steerFwd);
|
|
|
|
|
float r = CGeneral::GetRandomNumberInRange(-0.06f, -0.03f);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
dir1.x = steerFwd.x * r;
|
|
|
|
|
dir1.y = steerFwd.y * r;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}else{
|
2020-05-31 15:05:49 +00:00
|
|
|
|
dir1.x = m_vecMoveSpeed.x;
|
|
|
|
|
dir1.y = m_vecMoveSpeed.y;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dblExhaust = false;
|
|
|
|
|
pos1 = GetMatrix() * exhaustPos;
|
|
|
|
|
if(pHandling->Flags & HANDLING_DBL_EXHAUST){
|
|
|
|
|
dblExhaust = true;
|
|
|
|
|
pos2 = exhaustPos;
|
|
|
|
|
pos2.x = -pos2.x;
|
|
|
|
|
pos2 = GetMatrix() * pos2;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
dir2 = dir1;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
static float fumesLimit = 2.0f;
|
|
|
|
|
if(CGeneral::GetRandomNumberInRange(1.0f, 3.0f)*(m_fGasPedal+1.1f) > fumesLimit)
|
|
|
|
|
for(i = 0; i < 4;){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_EXHAUST_FUMES, pos1, dir1);
|
|
|
|
|
if(pHandling->Flags & HANDLING_DBL_EXHAUST)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_EXHAUST_FUMES, pos2, dir2);
|
|
|
|
|
|
|
|
|
|
static float extraFumesLimit = 0.5f;
|
|
|
|
|
if(m_fGasPedal > extraFumesLimit && m_nCurrentGear < 3){
|
|
|
|
|
if(CGeneral::GetRandomNumber() & 1)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_EXHAUST_FUMES, pos1, dir1);
|
|
|
|
|
else if(pHandling->Flags & HANDLING_DBL_EXHAUST)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_EXHAUST_FUMES, pos2, dir2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fire on Cuban hermes
|
|
|
|
|
if(GetModelIndex() == MI_CUBAN && i == 1 && m_fGasPedal > 0.9f){
|
|
|
|
|
if(m_nCurrentGear == 1 || m_nCurrentGear == 3 && (CTimer::GetTimeInMilliseconds()%1500) > 750){
|
|
|
|
|
if(CGeneral::GetRandomNumber() & 1){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos1, dir1, nil, 0.05f, 0, 0, 2, 200);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos1, dir1, nil, 0.05f, 0, 0, 2, 200);
|
|
|
|
|
}else{
|
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos2, dir2, nil, 0.05f, 0, 0, 2, 200);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_FIREBALL, pos2, dir2, nil, 0.05f, 0, 0, 2, 200);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(GetStatus() == STATUS_PLAYER && (CTimer::GetFrameCounter()&3) == 0 &&
|
|
|
|
|
CWeather::Rain == 0.0f && i == 0){
|
|
|
|
|
CVector camDist = GetPosition() - TheCamera.GetPosition();
|
|
|
|
|
if(DotProduct(GetForward(), camDist) > 0.0f ||
|
|
|
|
|
TheCamera.GetLookDirection() == LOOKING_LEFT ||
|
|
|
|
|
TheCamera.GetLookDirection() == LOOKING_RIGHT){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_HEATHAZE, pos1, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
if(pHandling->Flags & HANDLING_DBL_EXHAUST)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_HEATHAZE, pos2, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_HEATHAZE, pos1, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
if(pHandling->Flags & HANDLING_DBL_EXHAUST)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_HEATHAZE, pos2, CVector(0.0f, 0.0f, 0.0f));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(GetModelIndex() == MI_CUBAN && i < 1){
|
|
|
|
|
i = 1;
|
|
|
|
|
pos1 = GetMatrix() * CVector(1.134f, -1.276f, -0.56f);
|
|
|
|
|
pos2 = GetMatrix() * CVector(-1.134f, -1.276f, -0.56f);
|
|
|
|
|
dir1 += 0.05f*GetRight();
|
|
|
|
|
dir2 -= 0.05f*GetRight();
|
|
|
|
|
}else
|
|
|
|
|
i = 99;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Siren and taxi lights
|
|
|
|
|
switch(GetModelIndex()){
|
|
|
|
|
case MI_FIRETRUCK:
|
|
|
|
|
case MI_AMBULAN:
|
|
|
|
|
case MI_POLICE:
|
|
|
|
|
case MI_ENFORCER:
|
|
|
|
|
if(m_bSirenOrAlarm){
|
|
|
|
|
CVector pos1, pos2;
|
|
|
|
|
uint8 r1, g1, b1;
|
|
|
|
|
uint8 r2, g2, b2;
|
|
|
|
|
uint8 r, g, b;
|
|
|
|
|
|
|
|
|
|
switch(GetModelIndex()){
|
|
|
|
|
case MI_FIRETRUCK:
|
|
|
|
|
pos1 = CVector(1.1f, 1.7f, 2.0f);
|
|
|
|
|
pos2 = CVector(-1.1f, 1.7f, 2.0f);
|
|
|
|
|
r1 = 255; g1 = 0; b1 = 0;
|
|
|
|
|
r2 = 255; g2 = 255; b2 = 0;
|
|
|
|
|
break;
|
|
|
|
|
case MI_AMBULAN:
|
|
|
|
|
pos1 = CVector(1.1f, 0.9f, 1.6f);
|
|
|
|
|
pos2 = CVector(-1.1f, 0.9f, 1.6f);
|
|
|
|
|
r1 = 255; g1 = 0; b1 = 0;
|
|
|
|
|
r2 = 255; g2 = 255; b2 = 255;
|
|
|
|
|
break;
|
|
|
|
|
case MI_POLICE:
|
|
|
|
|
pos1 = CVector(0.7f, -0.4f, 1.0f);
|
|
|
|
|
pos2 = CVector(-0.7f, -0.4f, 1.0f);
|
|
|
|
|
r1 = 255; g1 = 0; b1 = 0;
|
|
|
|
|
r2 = 0; g2 = 0; b2 = 255;
|
|
|
|
|
break;
|
|
|
|
|
case MI_ENFORCER:
|
|
|
|
|
pos1 = CVector(1.1f, 0.8f, 1.2f);
|
|
|
|
|
pos2 = CVector(-1.1f, 0.8f, 1.2f);
|
|
|
|
|
r1 = 255; g1 = 0; b1 = 0;
|
|
|
|
|
r2 = 0; g2 = 0; b2 = 255;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32 t = CTimer::GetTimeInMilliseconds() & 0x3FF; // 1023
|
|
|
|
|
if(t < 512){
|
|
|
|
|
r = r1/6;
|
|
|
|
|
g = g1/6;
|
|
|
|
|
b = b1/6;
|
|
|
|
|
}else{
|
|
|
|
|
r = r2/6;
|
|
|
|
|
g = g2/6;
|
|
|
|
|
b = b2/6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t = CTimer::GetTimeInMilliseconds() & 0x1FF; // 511
|
|
|
|
|
if(t < 100){
|
|
|
|
|
float f = t/100.0f;
|
|
|
|
|
r *= f;
|
|
|
|
|
g *= f;
|
|
|
|
|
b *= f;
|
|
|
|
|
}else if(t > 412){
|
|
|
|
|
float f = (512-t)/100.0f;
|
|
|
|
|
r *= f;
|
|
|
|
|
g *= f;
|
|
|
|
|
b *= f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CVector pos = GetPosition();
|
|
|
|
|
float angle = (CTimer::GetTimeInMilliseconds() & 0x3FF)*TWOPI/0x3FF;
|
|
|
|
|
float s = 8.0f*Sin(angle);
|
|
|
|
|
float c = 8.0f*Cos(angle);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
//CShadows::StoreCarLightShadow(this, (uintptr)this + 21, gpShadowHeadLightsTex,
|
|
|
|
|
// &pos, c, s, s, -c, r, g, b, 8.0f);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT,
|
|
|
|
|
pos + GetUp()*2.0f, CVector(0.0f, 0.0f, 0.0f), 12.0f,
|
|
|
|
|
r*0.02f, g*0.02f, b*0.02f, CPointLights::FOG_NONE, true);
|
|
|
|
|
|
|
|
|
|
pos1 = GetMatrix() * pos1;
|
|
|
|
|
pos2 = GetMatrix() * pos2;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
uint8 sirenTimer = ((CTimer::GetTimeInMilliseconds() + (i<<6))>>8) & 3;
|
|
|
|
|
pos = (pos1*i + pos2*(3.0f-i))/3.0f;
|
|
|
|
|
|
|
|
|
|
switch(sirenTimer){
|
|
|
|
|
case 0:
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 21 + i,
|
|
|
|
|
r1, g1, b1, 255,
|
|
|
|
|
pos, 0.4f, 50.0f,
|
|
|
|
|
CCoronas::TYPE_STAR,
|
|
|
|
|
i == 1 ? CCoronas::FLARE_HEADLIGHTS : CCoronas::FLARE_NONE,
|
|
|
|
|
CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 21 + i,
|
|
|
|
|
r2, g2, b2, 255,
|
|
|
|
|
pos, 0.4f, 50.0f,
|
|
|
|
|
CCoronas::TYPE_STAR,
|
|
|
|
|
CCoronas::FLARE_NONE,
|
|
|
|
|
CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 21 + i, pos, 50.0f, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
case MI_FBIRANCH:
|
|
|
|
|
case MI_VICECHEE:
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(m_bSirenOrAlarm){
|
|
|
|
|
CVector pos = GetMatrix() * CVector(0.4f, 0.6f, 0.3f);
|
|
|
|
|
if(CTimer::GetTimeInMilliseconds() & 0x100 &&
|
|
|
|
|
DotProduct(GetForward(), GetPosition() - TheCamera.GetPosition()) < 0.0f)
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetModelIndex() == MI_VICECHEE)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 21,
|
|
|
|
|
255, 70, 70, 255,
|
|
|
|
|
pos, 0.4f, 50.0f,
|
|
|
|
|
CCoronas::TYPE_STAR,
|
|
|
|
|
CCoronas::FLARE_NONE,
|
|
|
|
|
CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
|
|
|
|
|
else
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 21,
|
|
|
|
|
0, 0, 255, 255,
|
|
|
|
|
pos, 0.4f, 50.0f,
|
|
|
|
|
CCoronas::TYPE_STAR,
|
|
|
|
|
CCoronas::FLARE_NONE,
|
|
|
|
|
CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
else
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 21, pos, 50.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MI_TAXI:
|
|
|
|
|
case MI_CABBIE:
|
2020-05-07 09:33:20 +00:00
|
|
|
|
case MI_ZEBRA:
|
|
|
|
|
case MI_KAUFMAN:
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(bTaxiLight){
|
|
|
|
|
CVector pos = GetPosition() + GetUp()*0.95f;
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 21,
|
|
|
|
|
128, 128, 0, 255,
|
|
|
|
|
pos, 0.8f, 50.0f,
|
|
|
|
|
CCoronas::TYPE_NORMAL,
|
|
|
|
|
CCoronas::FLARE_NONE,
|
|
|
|
|
CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
|
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT,
|
|
|
|
|
pos, CVector(0.0f, 0.0f, 0.0f), 10.0f,
|
|
|
|
|
1.0f, 1.0f, 0.5f, CPointLights::FOG_NONE, true);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetModelIndex() != MI_RCBANDIT && GetModelIndex() != MI_DODO &&
|
|
|
|
|
GetModelIndex() != MI_RHINO && GetModelIndex() != MI_RCBARON &&
|
|
|
|
|
GetVehicleAppearance() != VEHICLE_APPEARANCE_HELI) {
|
|
|
|
|
// Process lights
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
// Turn lights on/off
|
|
|
|
|
bool shouldLightsBeOn =
|
|
|
|
|
CClock::GetHours() > 20 ||
|
|
|
|
|
CClock::GetHours() > 19 && CClock::GetMinutes() > (m_randomSeed & 0x3F) ||
|
|
|
|
|
CClock::GetHours() < 7 ||
|
|
|
|
|
CClock::GetHours() < 8 && CClock::GetMinutes() < (m_randomSeed & 0x3F) ||
|
|
|
|
|
m_randomSeed/50000.0f < CWeather::Foggyness ||
|
|
|
|
|
m_randomSeed/50000.0f < CWeather::WetRoads;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(shouldLightsBeOn != bLightsOn && GetStatus() != STATUS_WRECKED){
|
|
|
|
|
if(GetStatus() == STATUS_ABANDONED){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
// Turn off lights on abandoned vehicles only when we they're far away
|
|
|
|
|
if(bLightsOn &&
|
|
|
|
|
Abs(TheCamera.GetPosition().x - GetPosition().x) + Abs(TheCamera.GetPosition().y - GetPosition().y) > 100.0f)
|
|
|
|
|
bLightsOn = false;
|
|
|
|
|
}else
|
|
|
|
|
bLightsOn = shouldLightsBeOn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Actually render the lights
|
|
|
|
|
bool alarmOn = false;
|
|
|
|
|
bool alarmOff = false;
|
|
|
|
|
if(IsAlarmOn()){
|
|
|
|
|
if(CTimer::GetTimeInMilliseconds() & 0x100)
|
|
|
|
|
alarmOn = true;
|
|
|
|
|
else
|
|
|
|
|
alarmOff = true;
|
|
|
|
|
}
|
|
|
|
|
if(bEngineOn && bLightsOn || alarmOn || alarmOff){
|
|
|
|
|
CVector lookVector = GetPosition() - TheCamera.GetPosition();
|
|
|
|
|
float camDist = lookVector.Magnitude();
|
|
|
|
|
if(camDist != 0.0f)
|
|
|
|
|
lookVector *= 1.0f/camDist;
|
|
|
|
|
else
|
|
|
|
|
lookVector = CVector(1.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
// 1.0 if directly behind car, -1.0 if in front
|
|
|
|
|
float behindness = DotProduct(lookVector, GetForward());
|
|
|
|
|
behindness = clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary
|
|
|
|
|
// 0.0 if behind car, PI if in front
|
|
|
|
|
// Abs not necessary
|
|
|
|
|
float angle = Abs(Acos(behindness));
|
|
|
|
|
|
|
|
|
|
// Headlights
|
|
|
|
|
|
|
|
|
|
CVector headLightPos = mi->m_positions[CAR_POS_HEADLIGHTS];
|
|
|
|
|
CVector lightR = GetMatrix() * headLightPos;
|
|
|
|
|
CVector lightL = lightR;
|
|
|
|
|
lightL -= GetRight()*2.0f*headLightPos.x;
|
|
|
|
|
|
|
|
|
|
// Headlight coronas
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(DotProduct(lightR-TheCamera.GetPosition(), GetForward()) < 0.0f &&
|
|
|
|
|
(TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_1STPERSON || this != FindPlayerVehicle())){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
// In front of car
|
|
|
|
|
float intensity = -0.5f*behindness + 0.3f;
|
|
|
|
|
float size = 1.0f - behindness;
|
|
|
|
|
|
|
|
|
|
if(behindness < -0.97f && camDist < 30.0f){
|
|
|
|
|
// Directly in front and not too far away
|
|
|
|
|
if(pHandling->Flags & HANDLING_HALOGEN_LIGHTS){
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 6, 150, 150, 195, 255,
|
|
|
|
|
lightL, 1.2f, 45.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_HEADLIGHT, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 7, 150, 150, 195, 255,
|
|
|
|
|
lightR, 1.2f, 45.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_HEADLIGHT, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, angle);
|
|
|
|
|
}else{
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 6, 160, 160, 140, 255,
|
|
|
|
|
lightL, 1.2f, 45.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_HEADLIGHT, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 7, 160, 160, 140, 255,
|
|
|
|
|
lightR, 1.2f, 45.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_HEADLIGHT, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, angle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(alarmOff){
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this, 0, 0, 0, 0,
|
|
|
|
|
lightL, size, 0.0f,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 1, 0, 0, 0, 0,
|
|
|
|
|
lightR, size, 0.0f,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
}else{
|
|
|
|
|
if(pHandling->Flags & HANDLING_HALOGEN_LIGHTS){
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this, 190*intensity, 190*intensity, 255*intensity, 255,
|
|
|
|
|
lightL, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 1, 190*intensity, 190*intensity, 255*intensity, 255,
|
|
|
|
|
lightR, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
}else{
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this, 210*intensity, 210*intensity, 195*intensity, 255,
|
|
|
|
|
lightL, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 1, 210*intensity, 210*intensity, 195*intensity, 255,
|
|
|
|
|
lightR, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
// Behind car
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this, lightL, 50.0f*TheCamera.LODDistMultiplier, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 1, lightR, 50.0f*TheCamera.LODDistMultiplier, angle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// bright lights
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK && !bNoBrightHeadLights)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightL, GetUp(), GetRight(), GetForward(), pHandling->FrontLights + BRIGHTLIGHT_FRONT);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK && !bNoBrightHeadLights)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightR, GetUp(), GetRight(), GetForward(), pHandling->FrontLights + BRIGHTLIGHT_FRONT);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
// Taillights
|
|
|
|
|
|
|
|
|
|
CVector tailLightPos = mi->m_positions[CAR_POS_TAILLIGHTS];
|
|
|
|
|
lightR = GetMatrix() * tailLightPos;
|
|
|
|
|
lightL = lightR;
|
|
|
|
|
lightL -= GetRight()*2.0f*tailLightPos.x;
|
|
|
|
|
|
|
|
|
|
// Taillight coronas
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(DotProduct(lightR-TheCamera.GetPosition(), GetForward()) > 0.0f){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
// Behind car
|
2019-08-16 18:17:15 +00:00
|
|
|
|
float intensity = 0.4f*behindness + 0.4f;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
float size = (behindness + 1.0f)/2.0f;
|
|
|
|
|
|
|
|
|
|
if(m_fGasPedal < 0.0f){
|
|
|
|
|
// reversing
|
|
|
|
|
intensity += 0.4f;
|
|
|
|
|
size += 0.3f;
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 2, 128*intensity, 128*intensity, 128*intensity, 255,
|
|
|
|
|
lightL, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 3, 128*intensity, 128*intensity, 128*intensity, 255,
|
|
|
|
|
lightR, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
}else{
|
2019-08-16 18:17:15 +00:00
|
|
|
|
if(m_fBrakePedal > 0.0f){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
intensity += 0.4f;
|
|
|
|
|
size += 0.3f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(alarmOff){
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 2, 0, 0, 0, 0,
|
|
|
|
|
lightL, size, 0.0f,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 3, 0, 0, 0, 0,
|
|
|
|
|
lightR, size, 0.0f,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
}else{
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 2, 128*intensity, 0, 0, 255,
|
|
|
|
|
lightL, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 3, 128*intensity, 0, 0, 255,
|
|
|
|
|
lightR, size, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
// In front of car
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 2, lightL, 50.0f*TheCamera.LODDistMultiplier, angle);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 3, lightR, 50.0f*TheCamera.LODDistMultiplier, angle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// bright lights
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightL, GetUp(), GetRight(), GetForward(), pHandling->RearLights + BRIGHTLIGHT_REAR);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightR, GetUp(), GetRight(), GetForward(), pHandling->RearLights + BRIGHTLIGHT_REAR);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
// Light shadows
|
|
|
|
|
if(!alarmOff){
|
|
|
|
|
CVector pos = GetPosition();
|
|
|
|
|
CVector2D fwd(GetForward());
|
|
|
|
|
fwd.Normalise();
|
|
|
|
|
float f = headLightPos.y + 6.0f;
|
|
|
|
|
pos += CVector(f*fwd.x, f*fwd.y, 2.0f);
|
|
|
|
|
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK ||
|
|
|
|
|
Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CShadows::StoreCarLightShadow(this, (uintptr)this + 22, gpShadowHeadLightsTex, &pos,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
7.0f*fwd.x, 7.0f*fwd.y, 5.5f*fwd.y, -5.5f*fwd.x, 45, 45, 45, 7.0f);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
|
|
|
|
f = (tailLightPos.y - 2.5f) - (headLightPos.y + 6.0f);
|
|
|
|
|
pos += CVector(f*fwd.x, f*fwd.y, 0.0f);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK ||
|
|
|
|
|
Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CShadows::StoreCarLightShadow(this, (uintptr)this + 25, gpShadowExplosionTex, &pos,
|
|
|
|
|
3.0f, 0.0f, 0.0f, -3.0f, 35, 0, 0, 4.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(this == FindPlayerVehicle() && !alarmOff){
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_FRONT_LEFT) == LIGHT_STATUS_OK ||
|
|
|
|
|
Damage.GetLightStatus(VEHLIGHT_FRONT_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_DIRECTIONAL, GetPosition(), GetForward(),
|
|
|
|
|
20.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
|
FindPlayerVehicle()->m_vecMoveSpeed.MagnitudeSqr2D() < sq(0.45f) ? CPointLights::FOG_NORMAL : CPointLights::FOG_NONE,
|
|
|
|
|
false);
|
|
|
|
|
CVector pos = GetPosition() - 4.0f*GetForward();
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK ||
|
2020-05-11 23:24:57 +00:00
|
|
|
|
Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) {
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(m_fBrakePedal > 0.0f)
|
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT, pos, CVector(0.0f, 0.0f, 0.0f),
|
|
|
|
|
10.0f, 1.0f, 0.0f, 0.0f,
|
|
|
|
|
CPointLights::FOG_NONE, false);
|
|
|
|
|
else
|
|
|
|
|
CPointLights::AddLight(CPointLights::LIGHT_POINT, pos, CVector(0.0f, 0.0f, 0.0f),
|
|
|
|
|
7.0f, 0.6f, 0.0f, 0.0f,
|
|
|
|
|
CPointLights::FOG_NONE, false);
|
2020-05-11 23:24:57 +00:00
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(GetStatus() != STATUS_ABANDONED && GetStatus() != STATUS_WRECKED){
|
2019-07-28 11:14:08 +00:00
|
|
|
|
// Lights off
|
|
|
|
|
|
|
|
|
|
CVector lightPos = mi->m_positions[CAR_POS_TAILLIGHTS];
|
|
|
|
|
CVector lightR = GetMatrix() * lightPos;
|
|
|
|
|
CVector lightL = lightR;
|
|
|
|
|
lightL -= GetRight()*2.0f*lightPos.x;
|
|
|
|
|
|
|
|
|
|
if(m_fBrakePedal > 0.0f || m_fGasPedal < 0.0f){
|
|
|
|
|
CVector lookVector = GetPosition() - TheCamera.GetPosition();
|
|
|
|
|
lookVector.Normalise();
|
|
|
|
|
float behindness = DotProduct(lookVector, GetForward());
|
|
|
|
|
if(behindness > 0.0f){
|
|
|
|
|
if(m_fGasPedal < 0.0f){
|
|
|
|
|
// reversing
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 2, 120, 120, 120, 255,
|
|
|
|
|
lightL, 1.2f, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 3, 120, 120, 120, 255,
|
|
|
|
|
lightR, 1.2f, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightL, GetUp(), GetRight(), GetForward(), pHandling->RearLights + BRIGHTLIGHT_FRONT);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightR, GetUp(), GetRight(), GetForward(), pHandling->RearLights + BRIGHTLIGHT_FRONT);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}else{
|
|
|
|
|
// braking
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 2, 120, 0, 0, 255,
|
|
|
|
|
lightL, 1.2f, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::RegisterCorona((uintptr)this + 3, 120, 0, 0, 255,
|
|
|
|
|
lightR, 1.2f, 50.0f*TheCamera.LODDistMultiplier,
|
|
|
|
|
CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
|
|
|
|
|
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightL, GetUp(), GetRight(), GetForward(), pHandling->RearLights + BRIGHTLIGHT_REAR);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
2020-04-07 14:48:49 +00:00
|
|
|
|
CBrightLights::RegisterOne(lightR, GetUp(), GetRight(), GetForward(), pHandling->RearLights + BRIGHTLIGHT_REAR);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 2, lightL, 50.0f*TheCamera.LODDistMultiplier, 0.0f);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 3, lightR, 50.0f*TheCamera.LODDistMultiplier, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 2, lightL, 50.0f*TheCamera.LODDistMultiplier, 0.0f);
|
|
|
|
|
if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK)
|
|
|
|
|
CCoronas::UpdateCoronaCoors((uintptr)this + 3, lightR, 50.0f*TheCamera.LODDistMultiplier, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-31 15:05:49 +00:00
|
|
|
|
// end of lights
|
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
|
2020-07-29 09:17:53 +00:00
|
|
|
|
if (IsRealHeli())
|
|
|
|
|
CShadows::StoreShadowForVehicle(this, VEH_SHD_TYPE_HELI);
|
|
|
|
|
else if ( GetModelIndex() == MI_RCBARON)
|
|
|
|
|
CShadows::StoreShadowForVehicle(this, VEH_SHD_TYPE_RCPLANE);
|
|
|
|
|
else
|
|
|
|
|
CShadows::StoreShadowForVehicle(this, VEH_SHD_TYPE_CAR);
|
2020-05-24 13:14:27 +00:00
|
|
|
|
|
|
|
|
|
DoSunGlare();
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
// Heli dust
|
|
|
|
|
if(IsRealHeli() && m_aWheelSpeed[1] > 0.1125f && GetPosition().z < 30.0f){
|
|
|
|
|
bool foundGround = false;
|
|
|
|
|
float waterZ = -1000.0f;
|
|
|
|
|
float groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, GetPosition().z, &foundGround);
|
|
|
|
|
if(!CWaterLevel::GetWaterLevel(GetPosition(), &waterZ, false))
|
|
|
|
|
waterZ = 0.0f;
|
|
|
|
|
groundZ = Max(groundZ, waterZ);
|
|
|
|
|
float rnd = (m_aWheelSpeed[1]-0.1125f)*((int)Max(16.0f-4.0f*CTimer::GetTimeStep(),2.0f))*400.0f/43.0f;
|
|
|
|
|
float radius = 10.0f;
|
|
|
|
|
if(GetModelIndex() == MI_RCGOBLIN || GetModelIndex() == MI_RCRAIDER)
|
|
|
|
|
radius = 3.0f;
|
|
|
|
|
if(GetPosition().z - groundZ < radius)
|
2020-07-21 02:59:31 +00:00
|
|
|
|
HeliDustGenerate(this, radius-(GetPosition().z - groundZ), groundZ, Ceil(rnd));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-27 09:53:51 +00:00
|
|
|
|
CMatrix mat;
|
|
|
|
|
CVector pos;
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
bool onlyFrontWheels = false;
|
|
|
|
|
if(IsRealHeli()){
|
|
|
|
|
// top rotor
|
|
|
|
|
m_aWheelRotation[1] += m_aWheelSpeed[1]*CTimer::GetTimeStep();
|
|
|
|
|
if(m_aWheelRotation[1] > TWOPI) m_aWheelRotation[1] -= TWOPI;
|
|
|
|
|
// rear rotor
|
|
|
|
|
m_aWheelRotation[3] += m_aWheelSpeed[1]*CTimer::GetTimeStep();
|
|
|
|
|
if(m_aWheelRotation[3] > TWOPI) m_aWheelRotation[3] -= TWOPI;
|
|
|
|
|
onlyFrontWheels = true;
|
2019-07-27 09:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CVector contactPoints[4]; // relative to model
|
|
|
|
|
CVector contactSpeeds[4]; // speed at contact points
|
|
|
|
|
CVector frontWheelFwd = Multiply3x3(GetMatrix(), CVector(-Sin(m_fSteerAngle), Cos(m_fSteerAngle), 0.0f));
|
|
|
|
|
CVector rearWheelFwd = GetForward();
|
|
|
|
|
for(i = 0; i < 4; i++){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if (m_aWheelTimer[i] > 0.0f && (!onlyFrontWheels || i == CARWHEEL_FRONT_LEFT || i == CARWHEEL_FRONT_RIGHT)) {
|
2019-10-06 12:49:01 +00:00
|
|
|
|
contactPoints[i] = m_aWheelColPoints[i].point - GetPosition();
|
2019-10-06 12:42:48 +00:00
|
|
|
|
contactSpeeds[i] = GetSpeed(contactPoints[i]);
|
|
|
|
|
if (i == CARWHEEL_FRONT_LEFT || i == CARWHEEL_FRONT_RIGHT)
|
|
|
|
|
m_aWheelSpeed[i] = ProcessWheelRotation(m_aWheelState[i], frontWheelFwd, contactSpeeds[i], 0.5f*mi->m_wheelScale);
|
|
|
|
|
else
|
|
|
|
|
m_aWheelSpeed[i] = ProcessWheelRotation(m_aWheelState[i], rearWheelFwd, contactSpeeds[i], 0.5f*mi->m_wheelScale);
|
|
|
|
|
m_aWheelRotation[i] += m_aWheelSpeed[i];
|
|
|
|
|
}
|
2019-07-27 09:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
RwRGBA hoverParticleCol = { 255, 255, 255, 32 };
|
|
|
|
|
|
2019-07-27 09:53:51 +00:00
|
|
|
|
// Rear right wheel
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RB]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_REAR_RIGHT];
|
|
|
|
|
if(Damage.GetWheelStatus(CARWHEEL_REAR_RIGHT) == WHEEL_STATUS_BURST)
|
|
|
|
|
mat.SetRotate(m_aWheelRotation[CARWHEEL_REAR_RIGHT], 0.0f, 0.3f*Sin(m_aWheelRotation[CARWHEEL_REAR_RIGHT]));
|
|
|
|
|
else
|
|
|
|
|
mat.SetRotateX(m_aWheelRotation[CARWHEEL_REAR_RIGHT]);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER){
|
|
|
|
|
if(bHoverCheat && m_aSuspensionSpringRatioPrev[CARWHEEL_REAR_RIGHT] < 1.0f &&
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB == SURFACE_WATER){
|
|
|
|
|
// hovering on water
|
|
|
|
|
mat.RotateY(-HALFPI);
|
|
|
|
|
if((CTimer::GetFrameCounter()+CARWHEEL_REAR_RIGHT) & 1){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_STEAM_NY_SLOWMOTION, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].point,
|
|
|
|
|
0.5f*m_vecMoveSpeed+0.1f*GetRight(), nil, 0.4f, hoverParticleCol);
|
|
|
|
|
}else{
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CAR_SPLASH, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].point,
|
|
|
|
|
0.3f*m_vecMoveSpeed+0.15f*GetRight()+CVector(0.0f, 0.0f, 0.1f), nil, 0.15f, hoverParticleCol,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 90.0f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 10.0f), 1);
|
|
|
|
|
}
|
2020-10-04 16:03:34 +00:00
|
|
|
|
#ifdef BETTER_ALLCARSAREDODO_CHEAT
|
|
|
|
|
} else if (bAllDodosCheat && m_nDriveWheelsOnGround == 0 && m_nDriveWheelsOnGroundPrev == 0) {
|
|
|
|
|
mat.RotateY(-HALFPI);
|
|
|
|
|
#endif
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else{
|
|
|
|
|
// tilt wheel depending oh how much it presses on ground
|
|
|
|
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
|
|
|
|
if(GetModelIndex() == MI_VOODOO)
|
|
|
|
|
groundOffset *= 0.6f;
|
|
|
|
|
mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
|
|
|
|
mat.Scale(1.15f*mi->m_wheelScale, mi->m_wheelScale, mi->m_wheelScale);
|
|
|
|
|
else
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
2019-07-27 09:53:51 +00:00
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
|
|
|
|
|
// Rear left wheel
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LB]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_REAR_LEFT];
|
|
|
|
|
if(Damage.GetWheelStatus(CARWHEEL_REAR_LEFT) == WHEEL_STATUS_BURST)
|
2020-05-31 15:05:49 +00:00
|
|
|
|
mat.SetRotate(-m_aWheelRotation[CARWHEEL_REAR_LEFT], 0.0f, PI+0.3f*Sin(m_aWheelRotation[CARWHEEL_REAR_LEFT]));
|
2019-07-27 09:53:51 +00:00
|
|
|
|
else
|
|
|
|
|
mat.SetRotate(-m_aWheelRotation[CARWHEEL_REAR_LEFT], 0.0f, PI);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER){
|
|
|
|
|
if(bHoverCheat && m_aSuspensionSpringRatioPrev[CARWHEEL_REAR_LEFT] < 1.0f &&
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB == SURFACE_WATER){
|
|
|
|
|
// hovering on water
|
|
|
|
|
mat.RotateY(HALFPI);
|
|
|
|
|
if((CTimer::GetFrameCounter()+CARWHEEL_REAR_LEFT) & 1){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_STEAM_NY_SLOWMOTION, m_aWheelColPoints[CARWHEEL_REAR_LEFT].point,
|
|
|
|
|
0.5f*m_vecMoveSpeed-0.1f*GetRight(), nil, 0.4f, hoverParticleCol);
|
|
|
|
|
}else{
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CAR_SPLASH, m_aWheelColPoints[CARWHEEL_REAR_LEFT].point,
|
|
|
|
|
0.3f*m_vecMoveSpeed-0.15f*GetRight()+CVector(0.0f, 0.0f, 0.1f), nil, 0.15f, hoverParticleCol,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 90.0f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 10.0f), 1);
|
|
|
|
|
}
|
2020-10-04 16:03:34 +00:00
|
|
|
|
#ifdef BETTER_ALLCARSAREDODO_CHEAT
|
|
|
|
|
} else if (bAllDodosCheat && m_nDriveWheelsOnGround == 0 && m_nDriveWheelsOnGroundPrev == 0) {
|
|
|
|
|
mat.RotateY(HALFPI);
|
|
|
|
|
#endif
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else{
|
|
|
|
|
// tilt wheel depending oh how much it presses on ground
|
|
|
|
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
|
|
|
|
if(GetModelIndex() == MI_VOODOO)
|
|
|
|
|
groundOffset *= 0.6f;
|
|
|
|
|
mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
|
|
|
|
mat.Scale(1.15f*mi->m_wheelScale, mi->m_wheelScale, mi->m_wheelScale);
|
|
|
|
|
else
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
2019-07-27 09:53:51 +00:00
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
|
|
|
|
|
// Mid right wheel
|
|
|
|
|
if(m_aCarNodes[CAR_WHEEL_RM]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RM]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_REAR_RIGHT];
|
|
|
|
|
if(Damage.GetWheelStatus(CARWHEEL_REAR_RIGHT) == WHEEL_STATUS_BURST)
|
|
|
|
|
mat.SetRotate(m_aWheelRotation[CARWHEEL_REAR_RIGHT], 0.0f, 0.3f*Sin(m_aWheelRotation[CARWHEEL_REAR_RIGHT]));
|
|
|
|
|
else
|
|
|
|
|
mat.SetRotateX(m_aWheelRotation[CARWHEEL_REAR_RIGHT]);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER){
|
|
|
|
|
if(bHoverCheat && m_aSuspensionSpringRatioPrev[CARWHEEL_REAR_RIGHT] < 1.0f &&
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB == SURFACE_WATER){
|
|
|
|
|
// hovering on water
|
|
|
|
|
mat.RotateY(-HALFPI);
|
2020-10-04 16:03:34 +00:00
|
|
|
|
#ifdef BETTER_ALLCARSAREDODO_CHEAT
|
|
|
|
|
} else if (bAllDodosCheat && m_nDriveWheelsOnGround == 0 && m_nDriveWheelsOnGroundPrev == 0) {
|
|
|
|
|
mat.RotateY(-HALFPI);
|
|
|
|
|
#endif
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else{
|
|
|
|
|
// tilt wheel depending oh how much it presses on ground
|
|
|
|
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
|
|
|
|
if(GetModelIndex() == MI_VOODOO)
|
|
|
|
|
groundOffset *= 0.6f;
|
|
|
|
|
mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
|
|
|
|
mat.Scale(1.15f*mi->m_wheelScale, mi->m_wheelScale, mi->m_wheelScale);
|
|
|
|
|
else
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
2019-07-27 09:53:51 +00:00
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mid left wheel
|
|
|
|
|
if(m_aCarNodes[CAR_WHEEL_LM]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LM]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_REAR_LEFT];
|
|
|
|
|
if(Damage.GetWheelStatus(CARWHEEL_REAR_LEFT) == WHEEL_STATUS_BURST)
|
2020-05-31 15:05:49 +00:00
|
|
|
|
mat.SetRotate(-m_aWheelRotation[CARWHEEL_REAR_LEFT], 0.0f, PI+0.3f*Sin(m_aWheelRotation[CARWHEEL_REAR_LEFT]));
|
2019-07-27 09:53:51 +00:00
|
|
|
|
else
|
|
|
|
|
mat.SetRotate(-m_aWheelRotation[CARWHEEL_REAR_LEFT], 0.0f, PI);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER){
|
|
|
|
|
if(bHoverCheat && m_aSuspensionSpringRatioPrev[CARWHEEL_REAR_LEFT] < 1.0f &&
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB == SURFACE_WATER){
|
|
|
|
|
// hovering on water
|
|
|
|
|
mat.RotateY(HALFPI);
|
2020-10-04 16:03:34 +00:00
|
|
|
|
#ifdef BETTER_ALLCARSAREDODO_CHEAT
|
|
|
|
|
} else if (bAllDodosCheat && m_nDriveWheelsOnGround == 0 && m_nDriveWheelsOnGroundPrev == 0) {
|
|
|
|
|
mat.RotateY(HALFPI);
|
|
|
|
|
#endif
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else{
|
|
|
|
|
// tilt wheel depending oh how much it presses on ground
|
|
|
|
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
|
|
|
|
if(GetModelIndex() == MI_VOODOO)
|
|
|
|
|
groundOffset *= 0.6f;
|
|
|
|
|
mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
|
|
|
|
mat.Scale(1.15f*mi->m_wheelScale, mi->m_wheelScale, mi->m_wheelScale);
|
|
|
|
|
else
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
2019-07-27 09:53:51 +00:00
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(GetModelIndex() == MI_DODO){
|
|
|
|
|
// Front wheel
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_FRONT_RIGHT];
|
|
|
|
|
if(Damage.GetWheelStatus(CARWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
|
|
|
|
|
mat.SetRotate(m_aWheelRotation[CARWHEEL_FRONT_RIGHT], 0.0f, m_fSteerAngle+0.3f*Sin(m_aWheelRotation[CARWHEEL_FRONT_RIGHT]));
|
|
|
|
|
else
|
|
|
|
|
mat.SetRotate(m_aWheelRotation[CARWHEEL_FRONT_RIGHT], 0.0f, m_fSteerAngle);
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
|
|
|
|
|
// Rotate propeller
|
|
|
|
|
if(m_aCarNodes[CAR_WINDSCREEN]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WINDSCREEN]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
mat.SetRotateY(m_fPropellerRotation);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
|
|
|
|
|
m_fPropellerRotation += m_fGasPedal != 0.0f ? TWOPI/13.0f : TWOPI/26.0f;
|
|
|
|
|
if(m_fPropellerRotation > TWOPI)
|
|
|
|
|
m_fPropellerRotation -= TWOPI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rudder
|
|
|
|
|
if(Damage.GetDoorStatus(DOOR_BOOT) != DOOR_STATUS_MISSING && m_aCarNodes[CAR_BOOT]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BOOT]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
mat.SetRotate(0.0f, 0.0f, -m_fSteerAngle);
|
|
|
|
|
mat.Rotate(0.0f, Sin(m_fSteerAngle)*DEGTORAD(22.0f), 0.0f);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProcessSwingingDoor(CAR_DOOR_LF, DOOR_FRONT_LEFT);
|
|
|
|
|
ProcessSwingingDoor(CAR_DOOR_RF, DOOR_FRONT_RIGHT);
|
|
|
|
|
}else if(GetModelIndex() == MI_RHINO){
|
|
|
|
|
// Front right wheel
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_FRONT_RIGHT];
|
|
|
|
|
// no damaged wheels or steering
|
|
|
|
|
mat.SetRotate(m_aWheelRotation[CARWHEEL_FRONT_RIGHT], 0.0f, 0.0f);
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
|
|
|
|
|
// Front left wheel
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_FRONT_LEFT];
|
|
|
|
|
// no damaged wheels or steering
|
|
|
|
|
mat.SetRotate(-m_aWheelRotation[CARWHEEL_FRONT_LEFT], 0.0f, PI);
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else if(IsRealHeli()){
|
|
|
|
|
// Top rotor
|
|
|
|
|
if(m_aCarNodes[CAR_BONNET]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
mat.SetRotateZ(m_aWheelRotation[1]);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
// Blurred top rotor
|
|
|
|
|
if(m_aCarNodes[CAR_WINDSCREEN]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WINDSCREEN]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
mat.SetRotateZ(-m_aWheelRotation[1]);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
// Rear rotor
|
|
|
|
|
if(m_aCarNodes[CAR_BOOT]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BOOT]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
mat.SetRotateX(m_aWheelRotation[3]);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
// Blurred rear rotor
|
|
|
|
|
if(m_aCarNodes[CAR_BUMP_REAR]){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BUMP_REAR]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
mat.SetRotateX(-m_aWheelRotation[3]);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
2019-07-27 09:53:51 +00:00
|
|
|
|
}else{
|
|
|
|
|
// Front right wheel
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_FRONT_RIGHT];
|
|
|
|
|
if(Damage.GetWheelStatus(CARWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
|
|
|
|
|
mat.SetRotate(m_aWheelRotation[CARWHEEL_FRONT_RIGHT], 0.0f, m_fSteerAngle+0.3f*Sin(m_aWheelRotation[CARWHEEL_FRONT_RIGHT]));
|
|
|
|
|
else
|
|
|
|
|
mat.SetRotate(m_aWheelRotation[CARWHEEL_FRONT_RIGHT], 0.0f, m_fSteerAngle);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER){
|
|
|
|
|
if(bHoverCheat && m_aSuspensionSpringRatioPrev[CARWHEEL_FRONT_RIGHT] < 1.0f &&
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB == SURFACE_WATER){
|
|
|
|
|
// hovering on water
|
|
|
|
|
mat.RotateY(-HALFPI);
|
|
|
|
|
if((CTimer::GetFrameCounter()+CARWHEEL_FRONT_RIGHT) & 1){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_STEAM_NY_SLOWMOTION, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].point,
|
|
|
|
|
0.5f*m_vecMoveSpeed+0.1f*GetRight(), nil, 0.4f, hoverParticleCol);
|
|
|
|
|
}else{
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CAR_SPLASH, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].point,
|
|
|
|
|
0.3f*m_vecMoveSpeed+0.15f*GetRight()+CVector(0.0f, 0.0f, 0.1f), nil, 0.15f, hoverParticleCol,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 90.0f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 10.0f), 1);
|
|
|
|
|
}
|
2020-10-04 16:03:34 +00:00
|
|
|
|
#ifdef BETTER_ALLCARSAREDODO_CHEAT
|
|
|
|
|
} else if (bAllDodosCheat && m_nDriveWheelsOnGround == 0 && m_nDriveWheelsOnGroundPrev == 0) {
|
|
|
|
|
mat.RotateY(-HALFPI);
|
|
|
|
|
#endif
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else{
|
|
|
|
|
// tilt wheel depending oh how much it presses on ground
|
|
|
|
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
|
|
|
|
if(GetModelIndex() == MI_VOODOO)
|
|
|
|
|
groundOffset *= 0.6f;
|
|
|
|
|
mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
|
|
|
|
|
mat.Scale(0.7f*mi->m_wheelScale, mi->m_wheelScale, mi->m_wheelScale);
|
|
|
|
|
else
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
2019-07-27 09:53:51 +00:00
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
|
|
|
|
|
// Front left wheel
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF]));
|
2020-05-31 15:05:49 +00:00
|
|
|
|
pos = mat.GetPosition();
|
2019-07-27 09:53:51 +00:00
|
|
|
|
pos.z = m_aWheelPosition[CARWHEEL_FRONT_LEFT];
|
|
|
|
|
if(Damage.GetWheelStatus(CARWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
|
2020-05-31 15:05:49 +00:00
|
|
|
|
mat.SetRotate(-m_aWheelRotation[CARWHEEL_FRONT_LEFT], 0.0f, PI+m_fSteerAngle+0.3f*Sin(m_aWheelRotation[CARWHEEL_FRONT_LEFT]));
|
2019-07-27 09:53:51 +00:00
|
|
|
|
else
|
|
|
|
|
mat.SetRotate(-m_aWheelRotation[CARWHEEL_FRONT_LEFT], 0.0f, PI+m_fSteerAngle);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER){
|
|
|
|
|
if(bHoverCheat && m_aSuspensionSpringRatioPrev[CARWHEEL_FRONT_LEFT] < 1.0f &&
|
|
|
|
|
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB == SURFACE_WATER){
|
|
|
|
|
// hovering on water
|
|
|
|
|
mat.RotateY(HALFPI);
|
|
|
|
|
if((CTimer::GetFrameCounter()+CARWHEEL_FRONT_LEFT) & 1){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_STEAM_NY_SLOWMOTION, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].point,
|
|
|
|
|
0.5f*m_vecMoveSpeed-0.1f*GetRight(), nil, 0.4f, hoverParticleCol);
|
|
|
|
|
}else{
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CAR_SPLASH, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].point,
|
|
|
|
|
0.3f*m_vecMoveSpeed-0.15f*GetRight()+CVector(0.0f, 0.0f, 0.1f), nil, 0.15f, hoverParticleCol,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 90.0f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 10.0f), 1);
|
|
|
|
|
}
|
2020-10-04 16:03:34 +00:00
|
|
|
|
#ifdef BETTER_ALLCARSAREDODO_CHEAT
|
|
|
|
|
} else if (bAllDodosCheat && m_nDriveWheelsOnGround == 0 && m_nDriveWheelsOnGroundPrev == 0) {
|
|
|
|
|
mat.RotateY(HALFPI);
|
|
|
|
|
#endif
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}else{
|
|
|
|
|
// tilt wheel depending oh how much it presses on ground
|
|
|
|
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
|
|
|
|
if(GetModelIndex() == MI_VOODOO)
|
|
|
|
|
groundOffset *= 0.6f;
|
|
|
|
|
mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
|
|
|
|
|
mat.Scale(0.7f*mi->m_wheelScale, mi->m_wheelScale, mi->m_wheelScale);
|
|
|
|
|
else
|
|
|
|
|
mat.Scale(mi->m_wheelScale);
|
2019-07-27 09:53:51 +00:00
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
|
|
|
|
|
ProcessSwingingDoor(CAR_DOOR_LF, DOOR_FRONT_LEFT);
|
|
|
|
|
ProcessSwingingDoor(CAR_DOOR_RF, DOOR_FRONT_RIGHT);
|
|
|
|
|
ProcessSwingingDoor(CAR_DOOR_LR, DOOR_REAR_LEFT);
|
|
|
|
|
ProcessSwingingDoor(CAR_DOOR_RR, DOOR_REAR_RIGHT);
|
|
|
|
|
ProcessSwingingDoor(CAR_BONNET, DOOR_BONNET);
|
|
|
|
|
ProcessSwingingDoor(CAR_BOOT, DOOR_BOOT);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if((GetModelIndex() == MI_PHEONIX || GetModelIndex() == MI_BFINJECT) &&
|
|
|
|
|
GetStatus() == STATUS_PLAYER && m_aCarNodes[CAR_WING_LR]){
|
|
|
|
|
float rotation = 0.0f;
|
|
|
|
|
|
|
|
|
|
if(GetModelIndex() == MI_BFINJECT)
|
|
|
|
|
if(m_fPropellerRotation > TWOPI) m_fPropellerRotation -= TWOPI;
|
|
|
|
|
|
|
|
|
|
if(Abs(m_fGasPedal) > 0.0f){
|
|
|
|
|
if(GetModelIndex() == MI_BFINJECT){
|
|
|
|
|
m_fPropellerRotation += 0.2f*CTimer::GetTimeStep();
|
|
|
|
|
rotation = m_fPropellerRotation;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_fPropellerRotation < 1.3f){
|
|
|
|
|
m_fPropellerRotation = Min(m_fPropellerRotation+0.1f*CTimer::GetTimeStep(), 1.3f);
|
|
|
|
|
rotation = m_fPropellerRotation;
|
|
|
|
|
}else{
|
|
|
|
|
float wave = Sin((CTimer::GetTimeInMilliseconds()%10000)/70.0f);
|
|
|
|
|
rotation = m_fPropellerRotation + 0.13*wave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(GetModelIndex() == MI_BFINJECT){
|
|
|
|
|
m_fPropellerRotation += 0.1f*CTimer::GetTimeStep();
|
|
|
|
|
rotation = m_fPropellerRotation;
|
|
|
|
|
}else{
|
|
|
|
|
if(m_fPropellerRotation > 0.0f){
|
|
|
|
|
m_fPropellerRotation = Max(m_fPropellerRotation-0.05f*CTimer::GetTimeStep(), 0.0f);
|
|
|
|
|
rotation = m_fPropellerRotation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-27 09:53:51 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WING_LR]));
|
|
|
|
|
pos = mat.GetPosition();
|
|
|
|
|
if(GetModelIndex() == MI_BFINJECT)
|
|
|
|
|
mat.SetRotateY(rotation);
|
|
|
|
|
else
|
|
|
|
|
mat.SetRotateX(rotation);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::Render(void)
|
|
|
|
|
{
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
|
|
|
|
|
|
|
|
|
|
mi->SetVehicleColour(m_currentColour1, m_currentColour2);
|
|
|
|
|
|
|
|
|
|
if(IsRealHeli()){
|
|
|
|
|
RpAtomic *atomic = nil;
|
|
|
|
|
int rotorAlpha = (1.5f - Min(1.7f*Max(m_aWheelSpeed[1],0.0f)/0.22f, 1.5f))*255.0f;
|
|
|
|
|
rotorAlpha = Min(rotorAlpha, 255);
|
|
|
|
|
int blurAlpha = Max(1.5f*m_aWheelSpeed[1]/0.22f - 0.4f, 0.0f)*150.0f;
|
|
|
|
|
blurAlpha = Min(blurAlpha, 150);
|
|
|
|
|
|
|
|
|
|
// Top rotor
|
|
|
|
|
if(m_aCarNodes[CAR_BONNET]){
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[CAR_BONNET], GetCurrentAtomicObjectCB, &atomic);
|
|
|
|
|
if(atomic)
|
|
|
|
|
SetComponentAtomicAlpha(atomic, rotorAlpha);
|
|
|
|
|
}
|
|
|
|
|
atomic = nil;
|
|
|
|
|
// Rear rotor
|
|
|
|
|
if(m_aCarNodes[CAR_BOOT]){
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[CAR_BOOT], GetCurrentAtomicObjectCB, &atomic);
|
|
|
|
|
if(atomic)
|
|
|
|
|
SetComponentAtomicAlpha(atomic, rotorAlpha);
|
|
|
|
|
}
|
|
|
|
|
atomic = nil;
|
|
|
|
|
// Blurred top rotor
|
|
|
|
|
if(m_aCarNodes[CAR_WINDSCREEN]){
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[CAR_WINDSCREEN], GetCurrentAtomicObjectCB, &atomic);
|
|
|
|
|
if(atomic)
|
|
|
|
|
SetComponentAtomicAlpha(atomic, blurAlpha);
|
|
|
|
|
}
|
|
|
|
|
atomic = nil;
|
|
|
|
|
// Blurred rear rotor
|
|
|
|
|
if(m_aCarNodes[CAR_BUMP_REAR]){
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[CAR_BUMP_REAR], GetCurrentAtomicObjectCB, &atomic);
|
|
|
|
|
if(atomic)
|
|
|
|
|
SetComponentAtomicAlpha(atomic, blurAlpha);
|
|
|
|
|
}
|
2019-07-27 09:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(CVehicle::bWheelsOnlyCheat){
|
|
|
|
|
RpAtomicRender((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RB]));
|
|
|
|
|
RpAtomicRender((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LB]));
|
|
|
|
|
RpAtomicRender((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RF]));
|
|
|
|
|
RpAtomicRender((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LF]));
|
|
|
|
|
if(m_aCarNodes[CAR_WHEEL_RM])
|
|
|
|
|
RpAtomicRender((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RM]));
|
|
|
|
|
if(m_aCarNodes[CAR_WHEEL_LM])
|
|
|
|
|
RpAtomicRender((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LM]));
|
|
|
|
|
}else
|
2019-07-27 09:53:51 +00:00
|
|
|
|
CEntity::Render();
|
|
|
|
|
}
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
int32
|
|
|
|
|
CAutomobile::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
CColModel *colModel;
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() != STATUS_SIMPLE)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
bVehicleColProcessed = true;
|
|
|
|
|
|
2019-07-27 11:02:49 +00:00
|
|
|
|
if(bUsingSpecialColModel)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
colModel = &CWorld::Players[CWorld::PlayerInFocus].m_ColModel;
|
|
|
|
|
else
|
|
|
|
|
colModel = GetColModel();
|
|
|
|
|
|
|
|
|
|
int numWheelCollisions = 0;
|
|
|
|
|
float prevRatios[4] = { 0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
prevRatios[i] = m_aSuspensionSpringRatio[i];
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(m_bIsVehicleBeingShifted || bSkipLineCol || ent->IsPed() ||
|
|
|
|
|
GetModelIndex() == MI_DODO && ent->IsVehicle())
|
|
|
|
|
colModel->numLines = 0;
|
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
int numCollisions = CCollision::ProcessColModels(GetMatrix(), *colModel,
|
|
|
|
|
ent->GetMatrix(), *ent->GetColModel(),
|
|
|
|
|
colpoints,
|
|
|
|
|
m_aWheelColPoints, m_aSuspensionSpringRatio);
|
|
|
|
|
|
|
|
|
|
// m_aSuspensionSpringRatio are now set to the point where the tyre touches ground.
|
|
|
|
|
// In ProcessControl these will be re-normalized to ignore the tyre radius.
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(colModel->numLines){
|
2019-07-09 07:57:44 +00:00
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f && m_aSuspensionSpringRatio[i] < prevRatios[i]){
|
|
|
|
|
numWheelCollisions++;
|
|
|
|
|
|
|
|
|
|
// wheel is touching a physical
|
|
|
|
|
if(ent->IsVehicle() || ent->IsObject()){
|
|
|
|
|
CPhysical *phys = (CPhysical*)ent;
|
|
|
|
|
|
|
|
|
|
m_aGroundPhysical[i] = phys;
|
|
|
|
|
phys->RegisterReference((CEntity**)&m_aGroundPhysical[i]);
|
|
|
|
|
m_aGroundOffset[i] = m_aWheelColPoints[i].point - phys->GetPosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_nSurfaceTouched = m_aWheelColPoints[i].surfaceB;
|
|
|
|
|
if(ent->IsBuilding())
|
|
|
|
|
m_pCurGroundEntity = ent;
|
|
|
|
|
}
|
2020-05-27 20:32:33 +00:00
|
|
|
|
}else
|
|
|
|
|
colModel->numLines = 4;
|
2019-07-09 07:57:44 +00:00
|
|
|
|
|
|
|
|
|
if(numCollisions > 0 || numWheelCollisions > 0){
|
|
|
|
|
AddCollisionRecord(ent);
|
|
|
|
|
if(!ent->IsBuilding())
|
|
|
|
|
((CPhysical*)ent)->AddCollisionRecord(this);
|
|
|
|
|
|
|
|
|
|
if(numCollisions > 0)
|
|
|
|
|
if(ent->IsBuilding() ||
|
|
|
|
|
ent->IsObject() && ((CPhysical*)ent)->bInfiniteMass)
|
|
|
|
|
bHasHitWall = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return numCollisions;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-11 10:48:49 +00:00
|
|
|
|
static int16 nLastControlInput;
|
|
|
|
|
static float fMouseCentreRange = 0.35f;
|
|
|
|
|
static float fMouseSteerSens = -0.0035f;
|
|
|
|
|
static float fMouseCentreMult = 0.975f;
|
2019-07-09 07:57:44 +00:00
|
|
|
|
|
2019-07-11 10:48:49 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::ProcessControlInputs(uint8 pad)
|
|
|
|
|
{
|
|
|
|
|
float speed = DotProduct(m_vecMoveSpeed, GetForward());
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(!CPad::GetPad(pad)->GetExitVehicle() ||
|
|
|
|
|
pDriver && pDriver->m_pVehicleAnim && (pDriver->m_pVehicleAnim->animId == ANIM_CAR_ROLLOUT_LHS ||
|
2020-06-03 13:16:31 +00:00
|
|
|
|
pDriver->m_pVehicleAnim->animId == ANIM_CAR_ROLLOUT_RHS))
|
2019-07-11 10:48:49 +00:00
|
|
|
|
bIsHandbrakeOn = !!CPad::GetPad(pad)->GetHandBrake();
|
2020-05-31 15:05:49 +00:00
|
|
|
|
else
|
|
|
|
|
bIsHandbrakeOn = true;
|
2019-07-11 10:48:49 +00:00
|
|
|
|
|
|
|
|
|
// Steer left/right
|
|
|
|
|
if(CCamera::m_bUseMouse3rdPerson && !CVehicle::m_bDisableMouseSteering){
|
|
|
|
|
if(CPad::GetPad(pad)->GetMouseX() != 0.0f){
|
2020-06-02 12:38:30 +00:00
|
|
|
|
m_fSteerInput += fMouseSteerSens*CPad::GetPad(pad)->GetMouseX();
|
2019-07-11 10:48:49 +00:00
|
|
|
|
nLastControlInput = 2;
|
2020-06-02 12:38:30 +00:00
|
|
|
|
if(Abs(m_fSteerInput) < fMouseCentreRange)
|
|
|
|
|
m_fSteerInput *= Pow(fMouseCentreMult, CTimer::GetTimeStep());
|
2019-07-11 10:48:49 +00:00
|
|
|
|
}else if(CPad::GetPad(pad)->GetSteeringLeftRight() || nLastControlInput != 2){
|
|
|
|
|
// mouse hasn't move, steer with pad like below
|
2020-06-02 12:38:30 +00:00
|
|
|
|
m_fSteerInput += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteerInput)*
|
2019-07-11 10:48:49 +00:00
|
|
|
|
0.2f*CTimer::GetTimeStep();
|
|
|
|
|
nLastControlInput = 0;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
2020-06-02 12:38:30 +00:00
|
|
|
|
m_fSteerInput += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteerInput)*
|
2019-07-11 10:48:49 +00:00
|
|
|
|
0.2f*CTimer::GetTimeStep();
|
|
|
|
|
nLastControlInput = 0;
|
|
|
|
|
}
|
2020-06-02 12:38:30 +00:00
|
|
|
|
m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
|
2019-07-11 10:48:49 +00:00
|
|
|
|
|
|
|
|
|
// Accelerate/Brake
|
|
|
|
|
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
|
|
|
|
|
if(GetModelIndex() == MI_DODO && acceleration < 0.0f)
|
|
|
|
|
acceleration *= 0.3f;
|
|
|
|
|
if(Abs(speed) < 0.01f){
|
|
|
|
|
// standing still, go into direction we want
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(CPad::GetPad(pad)->GetAccelerate() > 150.0f && CPad::GetPad(pad)->GetBrake() > 150.0f){
|
|
|
|
|
m_fGasPedal = CPad::GetPad(pad)->GetAccelerate()/255.0f;
|
|
|
|
|
m_fBrakePedal = CPad::GetPad(pad)->GetBrake()/255.0f;
|
|
|
|
|
m_doingBurnout = 1;
|
|
|
|
|
}else{
|
|
|
|
|
m_fGasPedal = acceleration;
|
|
|
|
|
m_fBrakePedal = 0.0f;
|
|
|
|
|
}
|
2019-07-11 10:48:49 +00:00
|
|
|
|
}else{
|
|
|
|
|
#if 1
|
|
|
|
|
// simpler than the code below
|
|
|
|
|
if(speed * acceleration < 0.0f){
|
|
|
|
|
// if opposite directions, have to brake first
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
m_fBrakePedal = Abs(acceleration);
|
|
|
|
|
}else{
|
|
|
|
|
// accelerating in same direction we were already going
|
|
|
|
|
m_fGasPedal = acceleration;
|
|
|
|
|
m_fBrakePedal = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
if(speed < 0.0f){
|
|
|
|
|
// moving backwards currently
|
|
|
|
|
if(acceleration < 0.0f){
|
|
|
|
|
// still go backwards
|
|
|
|
|
m_fGasPedal = acceleration;
|
|
|
|
|
m_fBrakePedal = 0.0f;
|
|
|
|
|
}else{
|
|
|
|
|
// want to go forwards, so brake
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
m_fBrakePedal = acceleration;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
// moving forwards currently
|
|
|
|
|
if(acceleration < 0.0f){
|
|
|
|
|
// want to go backwards, so brake
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
m_fBrakePedal = -acceleration;
|
|
|
|
|
}else{
|
|
|
|
|
// still go forwards
|
|
|
|
|
m_fGasPedal = acceleration;
|
|
|
|
|
m_fBrakePedal = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Actually turn wheels
|
|
|
|
|
static float fValue; // why static?
|
2020-06-02 12:38:30 +00:00
|
|
|
|
if(m_fSteerInput < 0.0f)
|
|
|
|
|
fValue = -sq(m_fSteerInput);
|
2019-07-11 10:48:49 +00:00
|
|
|
|
else
|
2020-06-02 12:38:30 +00:00
|
|
|
|
fValue = sq(m_fSteerInput);
|
2019-07-17 11:19:20 +00:00
|
|
|
|
m_fSteerAngle = DEGTORAD(pHandling->fSteeringLock) * fValue;
|
2019-07-11 10:48:49 +00:00
|
|
|
|
|
|
|
|
|
if(bComedyControls){
|
|
|
|
|
int rnd = CGeneral::GetRandomNumber() % 10;
|
|
|
|
|
switch(m_comedyControlState){
|
|
|
|
|
case 0:
|
|
|
|
|
if(rnd < 2)
|
|
|
|
|
m_comedyControlState = 1;
|
|
|
|
|
else if(rnd < 4)
|
|
|
|
|
m_comedyControlState = 2;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
m_fSteerAngle += 0.05f;
|
|
|
|
|
if(rnd < 2)
|
|
|
|
|
m_comedyControlState = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
m_fSteerAngle -= 0.05f;
|
|
|
|
|
if(rnd < 2)
|
|
|
|
|
m_comedyControlState = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-06-03 07:24:26 +00:00
|
|
|
|
}else
|
2019-07-11 10:48:49 +00:00
|
|
|
|
m_comedyControlState = 0;
|
|
|
|
|
|
|
|
|
|
// Brake if player isn't in control
|
|
|
|
|
// BUG: game always uses pad 0 here
|
2020-02-22 22:42:10 +00:00
|
|
|
|
if(CPad::GetPad(pad)->ArePlayerControlsDisabled()){
|
2019-07-11 10:48:49 +00:00
|
|
|
|
m_fBrakePedal = 1.0f;
|
|
|
|
|
bIsHandbrakeOn = true;
|
|
|
|
|
m_fGasPedal = 0.0f;
|
|
|
|
|
|
|
|
|
|
FindPlayerPed()->KeepAreaAroundPlayerClear();
|
|
|
|
|
|
|
|
|
|
// slow down car immediately
|
|
|
|
|
speed = m_vecMoveSpeed.Magnitude();
|
|
|
|
|
if(speed > 0.28f)
|
|
|
|
|
m_vecMoveSpeed *= 0.28f/speed;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2019-07-26 12:27:13 +00:00
|
|
|
|
void
|
2019-07-17 21:58:06 +00:00
|
|
|
|
CAutomobile::FireTruckControl(void)
|
2019-07-26 12:27:13 +00:00
|
|
|
|
{
|
|
|
|
|
if(this == FindPlayerVehicle()){
|
|
|
|
|
if(!CPad::GetPad(0)->GetWeapon())
|
|
|
|
|
return;
|
2020-03-31 02:54:19 +00:00
|
|
|
|
#ifdef FREE_CAM
|
2020-04-02 10:48:01 +00:00
|
|
|
|
if (!CCamera::bFreeCam)
|
2020-03-31 02:54:19 +00:00
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep();
|
|
|
|
|
m_fCarGunUD += CPad::GetPad(0)->GetCarGunUpDown() * 0.0001f * CTimer::GetTimeStep();
|
|
|
|
|
}
|
2019-07-26 12:27:13 +00:00
|
|
|
|
m_fCarGunUD = clamp(m_fCarGunUD, 0.05f, 0.3f);
|
|
|
|
|
|
2020-03-31 02:54:19 +00:00
|
|
|
|
|
2019-07-26 12:27:13 +00:00
|
|
|
|
CVector cannonPos(0.0f, 1.5f, 1.9f);
|
|
|
|
|
cannonPos = GetMatrix() * cannonPos;
|
|
|
|
|
CVector cannonDir(
|
|
|
|
|
Sin(m_fCarGunLR) * Cos(m_fCarGunUD),
|
|
|
|
|
Cos(m_fCarGunLR) * Cos(m_fCarGunUD),
|
|
|
|
|
Sin(m_fCarGunUD));
|
|
|
|
|
cannonDir = Multiply3x3(GetMatrix(), cannonDir);
|
|
|
|
|
cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f;
|
|
|
|
|
CWaterCannons::UpdateOne((uintptr)this, &cannonPos, &cannonDir);
|
2020-04-30 13:45:45 +00:00
|
|
|
|
}else if(GetStatus() == STATUS_PHYSICS){
|
2019-07-26 12:27:13 +00:00
|
|
|
|
CFire *fire = gFireManager.FindFurthestFire_NeverMindFireMen(GetPosition(), 10.0f, 35.0f);
|
|
|
|
|
if(fire == nil)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Target cannon onto fire
|
|
|
|
|
float targetAngle = CGeneral::GetATanOfXY(fire->m_vecPos.x-GetPosition().x, fire->m_vecPos.y-GetPosition().y);
|
|
|
|
|
float fwdAngle = CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
|
|
|
|
|
float targetCannonAngle = fwdAngle - targetAngle;
|
|
|
|
|
float angleDelta = CTimer::GetTimeStep()*0.01f;
|
|
|
|
|
float cannonDelta = targetCannonAngle - m_fCarGunLR;
|
|
|
|
|
while(cannonDelta < PI) cannonDelta += TWOPI;
|
|
|
|
|
while(cannonDelta > PI) cannonDelta -= TWOPI;
|
|
|
|
|
if(Abs(cannonDelta) < angleDelta)
|
|
|
|
|
m_fCarGunLR = targetCannonAngle;
|
|
|
|
|
else if(cannonDelta > 0.0f)
|
|
|
|
|
m_fCarGunLR += angleDelta;
|
|
|
|
|
else
|
|
|
|
|
m_fCarGunLR -= angleDelta;
|
|
|
|
|
|
|
|
|
|
// Go up and down a bit
|
|
|
|
|
float upDown = Sin((float)(CTimer::GetTimeInMilliseconds() & 0xFFF)/0x1000 * TWOPI);
|
|
|
|
|
m_fCarGunUD = 0.2f + 0.2f*upDown;
|
|
|
|
|
|
|
|
|
|
// Spray water every once in a while
|
|
|
|
|
if((CTimer::GetTimeInMilliseconds()>>10) & 3){
|
|
|
|
|
CVector cannonPos(0.0f, 0.0f, 2.2f); // different position than player's firetruck!
|
|
|
|
|
cannonPos = GetMatrix() * cannonPos;
|
|
|
|
|
CVector cannonDir(
|
|
|
|
|
Sin(m_fCarGunLR) * Cos(m_fCarGunUD),
|
|
|
|
|
Cos(m_fCarGunLR) * Cos(m_fCarGunUD),
|
|
|
|
|
Sin(m_fCarGunUD));
|
|
|
|
|
cannonDir = Multiply3x3(GetMatrix(), cannonDir);
|
|
|
|
|
cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f;
|
|
|
|
|
CWaterCannons::UpdateOne((uintptr)this, &cannonPos, &cannonDir);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-25 14:33:37 +00:00
|
|
|
|
void
|
2019-07-17 21:58:06 +00:00
|
|
|
|
CAutomobile::TankControl(void)
|
2019-07-25 14:33:37 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
// These coords are 1 unit higher then they should be relative to model center
|
|
|
|
|
CVector turrentBase(0.0f, -1.394f, 2.296f);
|
|
|
|
|
CVector gunEnd(0.0f, 1.813f, 2.979f);
|
|
|
|
|
CVector baseToEnd = gunEnd - turrentBase;
|
|
|
|
|
|
|
|
|
|
if(this != FindPlayerVehicle())
|
|
|
|
|
return;
|
|
|
|
|
if(CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Rotate turret
|
|
|
|
|
float prevAngle = m_fCarGunLR;
|
2020-03-31 02:54:19 +00:00
|
|
|
|
#ifdef FREE_CAM
|
2020-04-02 10:48:01 +00:00
|
|
|
|
if(!CCamera::bFreeCam)
|
2020-03-31 02:54:19 +00:00
|
|
|
|
#endif
|
|
|
|
|
m_fCarGunLR -= CPad::GetPad(0)->GetCarGunLeftRight() * 0.00015f * CTimer::GetTimeStep();
|
|
|
|
|
|
2019-07-25 14:33:37 +00:00
|
|
|
|
if(m_fCarGunLR < 0.0f)
|
|
|
|
|
m_fCarGunLR += TWOPI;
|
|
|
|
|
if(m_fCarGunLR > TWOPI)
|
|
|
|
|
m_fCarGunLR -= TWOPI;
|
|
|
|
|
if(m_fCarGunLR != prevAngle)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_TANK_TURRET_ROTATE, Abs(m_fCarGunLR - prevAngle));
|
|
|
|
|
|
|
|
|
|
// Shoot
|
|
|
|
|
if(CPad::GetPad(0)->CarGunJustDown() &&
|
|
|
|
|
CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeTankShotGun + 800){
|
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_nTimeTankShotGun = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
|
|
|
|
|
// more like -sin(angle), cos(angle), i.e. rotated (0,1,0)
|
|
|
|
|
CVector turretDir = CVector(Sin(-m_fCarGunLR), Cos(-m_fCarGunLR), 0.0f);
|
|
|
|
|
turretDir = Multiply3x3(GetMatrix(), turretDir);
|
|
|
|
|
|
|
|
|
|
float c = Cos(m_fCarGunLR);
|
|
|
|
|
float s = Sin(m_fCarGunLR);
|
|
|
|
|
CVector rotatedEnd(
|
|
|
|
|
c*baseToEnd.x - s*baseToEnd.y,
|
|
|
|
|
s*baseToEnd.x + c*baseToEnd.y,
|
|
|
|
|
baseToEnd.z - 1.0f); // correct offset here
|
|
|
|
|
rotatedEnd += turrentBase;
|
|
|
|
|
|
|
|
|
|
CVector point1 = GetMatrix() * rotatedEnd;
|
|
|
|
|
CVector point2 = point1 + 60.0f*turretDir;
|
|
|
|
|
m_vecMoveSpeed -= 0.06f*turretDir;
|
|
|
|
|
m_vecMoveSpeed.z += 0.05f;
|
|
|
|
|
|
|
|
|
|
CWeapon::DoTankDoomAiming(FindPlayerVehicle(), FindPlayerPed(), &point1, &point2);
|
|
|
|
|
CColPoint colpoint;
|
|
|
|
|
CEntity *entity = nil;
|
|
|
|
|
CWorld::ProcessLineOfSight(point1, point2, colpoint, entity, true, true, true, true, true, true, false);
|
|
|
|
|
if(entity)
|
|
|
|
|
point2 = colpoint.point - 0.04f*(colpoint.point - point1);
|
|
|
|
|
|
|
|
|
|
CExplosion::AddExplosion(nil, FindPlayerPed(), EXPLOSION_TANK_GRENADE, point2, 0);
|
|
|
|
|
|
|
|
|
|
// Add particles on the way to the explosion;
|
|
|
|
|
float shotDist = (point2 - point1).Magnitude();
|
|
|
|
|
int n = shotDist/4.0f;
|
|
|
|
|
RwRGBA black = { 0, 0, 0, 0 };
|
|
|
|
|
for(i = 0; i < n; i++){
|
|
|
|
|
float f = (float)i/n;
|
|
|
|
|
CParticle::AddParticle(PARTICLE_HELI_DUST,
|
|
|
|
|
point1 + f*(point2 - point1),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f),
|
|
|
|
|
nil, 0.1f, black);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// More particles
|
|
|
|
|
CVector shotDir = point2 - point1;
|
|
|
|
|
shotDir.Normalise();
|
|
|
|
|
for(i = 0; i < 15; i++){
|
|
|
|
|
float f = i/15.0f;
|
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNSMOKE2, point1,
|
|
|
|
|
shotDir*CGeneral::GetRandomNumberInRange(0.3f, 1.0f)*f,
|
2020-05-31 15:05:49 +00:00
|
|
|
|
nil, CGeneral::GetRandomNumberInRange(0.5f, 1.5f)*f, black);
|
2019-07-25 14:33:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// And some gun flashes near the gun
|
|
|
|
|
CVector flashPos = point1;
|
|
|
|
|
CVector nullDir(0.0f, 0.0f, 0.0f);
|
|
|
|
|
int lifeSpan = 250;
|
|
|
|
|
if(m_vecMoveSpeed.Magnitude() > 0.08f){
|
|
|
|
|
lifeSpan = 125;
|
2019-11-04 23:04:26 +00:00
|
|
|
|
flashPos.x += 5.0f*m_vecMoveSpeed.x;
|
|
|
|
|
flashPos.y += 5.0f*m_vecMoveSpeed.y;
|
2019-07-25 14:33:37 +00:00
|
|
|
|
}
|
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, flashPos, nullDir, nil, 0.4f, black, 0, 0, 0, lifeSpan);
|
|
|
|
|
flashPos += 0.3f*shotDir;
|
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, flashPos, nullDir, nil, 0.2f, black, 0, 0, 0, lifeSpan);
|
|
|
|
|
flashPos += 0.1f*shotDir;
|
|
|
|
|
CParticle::AddParticle(PARTICLE_GUNFLASH, flashPos, nullDir, nil, 0.15f, black, 0, 0, 0, lifeSpan);
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
#define HYDRAULIC_UPPER_EXT (-0.16f)
|
|
|
|
|
#define HYDRAULIC_LOWER_EXT (0.16f)
|
|
|
|
|
|
2019-07-26 12:27:13 +00:00
|
|
|
|
void
|
2019-07-17 21:58:06 +00:00
|
|
|
|
CAutomobile::HydraulicControl(void)
|
2019-07-26 12:27:13 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
float wheelPositions[4];
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
|
|
|
|
|
CColModel *normalColModel = mi->GetColModel();
|
|
|
|
|
float wheelRadius = 0.5f*mi->m_wheelScale;
|
|
|
|
|
CPlayerInfo *playerInfo = &CWorld::Players[CWorld::PlayerInFocus];
|
|
|
|
|
CColModel *specialColModel = &playerInfo->m_ColModel;
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() != STATUS_PLAYER){
|
2019-07-26 12:27:13 +00:00
|
|
|
|
// reset hydraulics for non-player cars
|
|
|
|
|
|
2019-07-27 11:02:49 +00:00
|
|
|
|
if(!bUsingSpecialColModel)
|
2019-07-26 12:27:13 +00:00
|
|
|
|
return;
|
|
|
|
|
if(specialColModel != nil) // this is always true
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
wheelPositions[i] = specialColModel->lines[i].p0.z - m_aSuspensionSpringRatio[i]*m_aSuspensionLineLength[i];
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
m_aSuspensionSpringLength[i] = pHandling->fSuspensionUpperLimit - pHandling->fSuspensionLowerLimit;
|
|
|
|
|
m_aSuspensionLineLength[i] = normalColModel->lines[i].p0.z - normalColModel->lines[i].p1.z;
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (normalColModel->lines[i].p0.z - wheelPositions[i]) / m_aSuspensionLineLength[i];
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_hydraulicState == 0)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_1, 0.0f);
|
|
|
|
|
else if(m_hydraulicState >= 100)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f);
|
|
|
|
|
|
|
|
|
|
if(playerInfo->m_pVehicleEx == this)
|
|
|
|
|
playerInfo->m_pVehicleEx = nil;
|
2019-07-27 11:02:49 +00:00
|
|
|
|
bUsingSpecialColModel = false;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
m_hydraulicState = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Player car
|
|
|
|
|
|
|
|
|
|
float normalUpperLimit = pHandling->fSuspensionUpperLimit;
|
|
|
|
|
float normalLowerLimit = pHandling->fSuspensionLowerLimit;
|
|
|
|
|
float normalSpringLength = normalUpperLimit - normalLowerLimit;
|
|
|
|
|
float extendedUpperLimit = normalUpperLimit - 0.2f;
|
|
|
|
|
float extendedLowerLimit = normalLowerLimit - 0.2f;
|
|
|
|
|
float extendedSpringLength = extendedUpperLimit - extendedLowerLimit;
|
|
|
|
|
|
2019-07-27 11:02:49 +00:00
|
|
|
|
if(!bUsingSpecialColModel){
|
2019-07-26 12:27:13 +00:00
|
|
|
|
// Init special col model
|
|
|
|
|
|
|
|
|
|
if(playerInfo->m_pVehicleEx && playerInfo->m_pVehicleEx == this)
|
2019-07-27 11:02:49 +00:00
|
|
|
|
playerInfo->m_pVehicleEx->bUsingSpecialColModel = false;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
playerInfo->m_pVehicleEx = this;
|
|
|
|
|
playerInfo->m_ColModel = *normalColModel;
|
2019-07-27 11:02:49 +00:00
|
|
|
|
bUsingSpecialColModel = true;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
specialColModel = &playerInfo->m_ColModel;
|
|
|
|
|
|
|
|
|
|
if(m_fVelocityChangeForAudio > 0.1f)
|
|
|
|
|
m_hydraulicState = 20;
|
|
|
|
|
else{
|
|
|
|
|
m_hydraulicState = 0;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
normalUpperLimit += HYDRAULIC_UPPER_EXT;
|
|
|
|
|
normalSpringLength = normalUpperLimit - (normalLowerLimit+HYDRAULIC_LOWER_EXT);
|
2019-07-26 12:27:13 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup suspension
|
|
|
|
|
float normalLineLength = normalSpringLength + wheelRadius;
|
|
|
|
|
CVector pos;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
wheelPositions[i] = normalColModel->lines[i].p0.z - m_aSuspensionSpringRatio[i]*m_aSuspensionLineLength[i];
|
|
|
|
|
mi->GetWheelPosn(i, pos);
|
|
|
|
|
pos.z += normalUpperLimit;
|
|
|
|
|
specialColModel->lines[i].p0 = pos;
|
|
|
|
|
pos.z -= normalLineLength;
|
|
|
|
|
specialColModel->lines[i].p1 = pos;
|
|
|
|
|
m_aSuspensionSpringLength[i] = normalSpringLength;
|
|
|
|
|
m_aSuspensionLineLength[i] = normalLineLength;
|
|
|
|
|
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (specialColModel->lines[i].p0.z - wheelPositions[i])/m_aSuspensionLineLength[i];
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f);
|
|
|
|
|
|
|
|
|
|
// Adjust col model
|
|
|
|
|
mi->GetWheelPosn(0, pos);
|
|
|
|
|
float minz = pos.z + extendedLowerLimit - wheelRadius;
|
|
|
|
|
if(minz < specialColModel->boundingBox.min.z)
|
|
|
|
|
specialColModel->boundingBox.min.z = minz;
|
2020-04-19 16:34:08 +00:00
|
|
|
|
float radius = Max(specialColModel->boundingBox.min.Magnitude(), specialColModel->boundingBox.max.Magnitude());
|
2019-07-26 12:27:13 +00:00
|
|
|
|
if(specialColModel->boundingSphere.radius < radius)
|
|
|
|
|
specialColModel->boundingSphere.radius = radius;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
return;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(playerInfo->m_WBState != WBSTATE_PLAYING)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool setPrevRatio = false;
|
|
|
|
|
if(m_hydraulicState < 20 && m_fVelocityChangeForAudio > 0.2f){
|
|
|
|
|
if(m_hydraulicState == 0){
|
|
|
|
|
m_hydraulicState = 20;
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_1, 0.0f);
|
|
|
|
|
setPrevRatio = true;
|
|
|
|
|
}else{
|
|
|
|
|
m_hydraulicState++;
|
|
|
|
|
}
|
|
|
|
|
}else if(m_hydraulicState != 0){ // must always be true
|
|
|
|
|
if(m_hydraulicState < 21 && m_fVelocityChangeForAudio < 0.1f){
|
|
|
|
|
m_hydraulicState--;
|
|
|
|
|
if(m_hydraulicState == 0)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CPad::GetPad(0)->HornJustDown()){
|
|
|
|
|
// Switch between normal and extended
|
|
|
|
|
|
|
|
|
|
if(m_hydraulicState < 100)
|
|
|
|
|
m_hydraulicState = 100;
|
|
|
|
|
else{
|
|
|
|
|
if(m_fVelocityChangeForAudio > 0.1f)
|
|
|
|
|
m_hydraulicState = 20;
|
|
|
|
|
else
|
|
|
|
|
m_hydraulicState = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_hydraulicState < 100){
|
|
|
|
|
if(m_hydraulicState == 0){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
normalUpperLimit += HYDRAULIC_UPPER_EXT;
|
|
|
|
|
normalLowerLimit += HYDRAULIC_LOWER_EXT;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
normalSpringLength = normalUpperLimit - normalLowerLimit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset suspension to normal
|
|
|
|
|
float normalLineLength = normalSpringLength + wheelRadius;
|
|
|
|
|
CVector pos;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
wheelPositions[i] = specialColModel->lines[i].p0.z - m_aSuspensionSpringRatio[i]*m_aSuspensionLineLength[i];
|
|
|
|
|
mi->GetWheelPosn(i, pos);
|
|
|
|
|
pos.z += normalUpperLimit;
|
|
|
|
|
specialColModel->lines[i].p0 = pos;
|
|
|
|
|
pos.z -= normalLineLength;
|
|
|
|
|
specialColModel->lines[i].p1 = pos;
|
|
|
|
|
m_aSuspensionSpringLength[i] = normalSpringLength;
|
|
|
|
|
m_aSuspensionLineLength[i] = normalLineLength;
|
|
|
|
|
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (specialColModel->lines[i].p0.z - wheelPositions[i])/m_aSuspensionLineLength[i];
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f);
|
|
|
|
|
}else{
|
|
|
|
|
// Reset suspension to extended
|
|
|
|
|
float extendedLineLength = extendedSpringLength + wheelRadius;
|
|
|
|
|
CVector pos;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
wheelPositions[i] = specialColModel->lines[i].p0.z - m_aSuspensionSpringRatio[i]*m_aSuspensionLineLength[i];
|
|
|
|
|
mi->GetWheelPosn(i, pos);
|
|
|
|
|
pos.z += extendedUpperLimit;
|
|
|
|
|
specialColModel->lines[i].p0 = pos;
|
|
|
|
|
pos.z -= extendedLineLength;
|
|
|
|
|
specialColModel->lines[i].p1 = pos;
|
|
|
|
|
m_aSuspensionSpringLength[i] = extendedSpringLength;
|
|
|
|
|
m_aSuspensionLineLength[i] = extendedLineLength;
|
|
|
|
|
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (specialColModel->lines[i].p0.z - wheelPositions[i])/m_aSuspensionLineLength[i];
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setPrevRatio = true;
|
|
|
|
|
}
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
float suspChange[4];
|
|
|
|
|
float maxDelta = 0.0f;
|
|
|
|
|
float rear = CPad::GetPad(0)->GetCarGunUpDown()/128.0f;
|
|
|
|
|
float front = -rear;
|
|
|
|
|
float right = CPad::GetPad(0)->GetCarGunLeftRight()/128.0f;
|
|
|
|
|
float left = -right;
|
2020-04-19 16:34:08 +00:00
|
|
|
|
suspChange[CARWHEEL_FRONT_LEFT] = Max(front+left, 0.0f);
|
|
|
|
|
suspChange[CARWHEEL_REAR_LEFT] = Max(rear+left, 0.0f);
|
|
|
|
|
suspChange[CARWHEEL_FRONT_RIGHT] = Max(front+right, 0.0f);
|
|
|
|
|
suspChange[CARWHEEL_REAR_RIGHT] = Max(rear+right, 0.0f);
|
2019-07-26 12:27:13 +00:00
|
|
|
|
|
|
|
|
|
if(m_hydraulicState < 100){
|
|
|
|
|
// Lowered, move wheels up
|
|
|
|
|
|
|
|
|
|
if(m_hydraulicState == 0){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
normalUpperLimit += HYDRAULIC_UPPER_EXT;
|
|
|
|
|
normalLowerLimit += HYDRAULIC_LOWER_EXT;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
normalSpringLength = normalUpperLimit - normalLowerLimit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set suspension
|
|
|
|
|
CVector pos;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
if(suspChange[i] > 1.0f)
|
|
|
|
|
suspChange[i] = 1.0f;
|
|
|
|
|
|
|
|
|
|
float upperLimit = suspChange[i]*(extendedUpperLimit-normalUpperLimit) + normalUpperLimit;
|
|
|
|
|
float springLength = suspChange[i]*(extendedSpringLength-normalSpringLength) + normalSpringLength;
|
|
|
|
|
float lineLength = springLength + wheelRadius;
|
|
|
|
|
|
|
|
|
|
wheelPositions[i] = specialColModel->lines[i].p0.z - m_aSuspensionSpringRatio[i]*m_aSuspensionLineLength[i];
|
|
|
|
|
mi->GetWheelPosn(i, pos);
|
|
|
|
|
pos.z += upperLimit;
|
|
|
|
|
specialColModel->lines[i].p0 = pos;
|
|
|
|
|
pos.z -= lineLength;
|
|
|
|
|
if(Abs(pos.z - specialColModel->lines[i].p1.z) > Abs(maxDelta))
|
|
|
|
|
maxDelta = pos.z - specialColModel->lines[i].p1.z;
|
|
|
|
|
specialColModel->lines[i].p1 = pos;
|
|
|
|
|
m_aSuspensionSpringLength[i] = springLength;
|
|
|
|
|
m_aSuspensionLineLength[i] = lineLength;
|
|
|
|
|
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (specialColModel->lines[i].p0.z - wheelPositions[i])/m_aSuspensionLineLength[i];
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if(m_hydraulicState < 104)
|
2019-07-26 12:27:13 +00:00
|
|
|
|
m_hydraulicState++;
|
|
|
|
|
|
|
|
|
|
if(m_fVelocityChangeForAudio < 0.1f){
|
2020-05-31 15:05:49 +00:00
|
|
|
|
normalUpperLimit += HYDRAULIC_UPPER_EXT;
|
|
|
|
|
normalLowerLimit += HYDRAULIC_LOWER_EXT;
|
2019-07-26 12:27:13 +00:00
|
|
|
|
normalSpringLength = normalUpperLimit - normalLowerLimit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set suspension
|
|
|
|
|
CVector pos;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
if(suspChange[i] > 1.0f)
|
|
|
|
|
suspChange[i] = 1.0f;
|
|
|
|
|
|
|
|
|
|
float upperLimit = suspChange[i]*(normalUpperLimit-extendedUpperLimit) + extendedUpperLimit;
|
|
|
|
|
float springLength = suspChange[i]*(normalSpringLength-extendedSpringLength) + extendedSpringLength;
|
|
|
|
|
float lineLength = springLength + wheelRadius;
|
|
|
|
|
|
|
|
|
|
wheelPositions[i] = specialColModel->lines[i].p0.z - m_aSuspensionSpringRatio[i]*m_aSuspensionLineLength[i];
|
|
|
|
|
mi->GetWheelPosn(i, pos);
|
|
|
|
|
pos.z += upperLimit;
|
|
|
|
|
specialColModel->lines[i].p0 = pos;
|
|
|
|
|
pos.z -= lineLength;
|
|
|
|
|
if(Abs(pos.z - specialColModel->lines[i].p1.z) > Abs(maxDelta))
|
|
|
|
|
maxDelta = pos.z - specialColModel->lines[i].p1.z;
|
|
|
|
|
specialColModel->lines[i].p1 = pos;
|
|
|
|
|
m_aSuspensionSpringLength[i] = springLength;
|
|
|
|
|
m_aSuspensionLineLength[i] = lineLength;
|
|
|
|
|
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (specialColModel->lines[i].p0.z - wheelPositions[i])/m_aSuspensionLineLength[i];
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] > 1.0f)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float limitDiff = extendedLowerLimit - normalLowerLimit;
|
|
|
|
|
if(limitDiff != 0.0f && Abs(maxDelta/limitDiff) > 0.01f){
|
|
|
|
|
float f = (maxDelta + limitDiff)/2.0f/limitDiff;
|
|
|
|
|
f = clamp(f, 0.0f, 1.0f);
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_3, f);
|
|
|
|
|
if(f < 0.4f || f > 0.6f)
|
|
|
|
|
setPrevRatio = true;
|
|
|
|
|
if(f < 0.25f)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f);
|
|
|
|
|
else if(f > 0.75f)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_1, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(setPrevRatio)
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
// wheel radius in relation to suspension line
|
|
|
|
|
float wheelRadius = 1.0f - m_aSuspensionSpringLength[i]/m_aSuspensionLineLength[i];
|
|
|
|
|
m_aSuspensionSpringRatioPrev[i] = (m_aSuspensionSpringRatio[i]-wheelRadius)/(1.0f-wheelRadius);
|
|
|
|
|
}
|
2019-07-17 21:58:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 21:06:48 +00:00
|
|
|
|
void
|
2019-07-26 12:27:13 +00:00
|
|
|
|
CAutomobile::ProcessBuoyancy(void)
|
2019-07-24 21:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
CVector impulse, point;
|
|
|
|
|
|
|
|
|
|
if(mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)){
|
2020-04-19 16:34:08 +00:00
|
|
|
|
float timeStep = Max(CTimer::GetTimeStep(), 0.01f);
|
2019-07-24 21:06:48 +00:00
|
|
|
|
float impulseRatio = impulse.z / (GRAVITY * m_fMass * timeStep);
|
|
|
|
|
float waterResistance = Pow(1.0f - 0.05f*impulseRatio, CTimer::GetTimeStep());
|
|
|
|
|
m_vecMoveSpeed *= waterResistance;
|
|
|
|
|
m_vecTurnSpeed *= waterResistance;
|
|
|
|
|
|
2020-05-28 16:53:54 +00:00
|
|
|
|
bool heliHitWaterHard = false;
|
|
|
|
|
if(IsRealHeli() && m_aWheelSpeed[1] > 0.15f){
|
|
|
|
|
if(GetModelIndex() == MI_SEASPAR){
|
|
|
|
|
if(impulseRatio > 3.0f){
|
|
|
|
|
m_aWheelSpeed[1] = 0.0f;
|
|
|
|
|
heliHitWaterHard = true;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
float strength = 1.0f/Max(8.0f*impulseRatio, 1.0f);
|
|
|
|
|
ApplyMoveForce(-2.0f*impulse/strength);
|
|
|
|
|
ApplyTurnForce(-impulse/strength, point);
|
|
|
|
|
if(impulseRatio > 0.9f){
|
|
|
|
|
m_aWheelSpeed[1] = 0.0f;
|
|
|
|
|
heliHitWaterHard = true;
|
|
|
|
|
}else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bTouchingWater = true;
|
|
|
|
|
ApplyMoveForce(impulse);
|
|
|
|
|
ApplyTurnForce(impulse, point);
|
|
|
|
|
CVector initialSpeed = m_vecMoveSpeed;
|
|
|
|
|
|
|
|
|
|
if(m_modelIndex == MI_SEASPAR && impulseRatio < 3.0f && (GetUp().z > -0.5f || impulseRatio < 0.6f) ||
|
|
|
|
|
CVehicle::bHoverCheat && GetStatus() == STATUS_PLAYER && GetUp().z > 0.1f){
|
|
|
|
|
bIsInWater = false;
|
|
|
|
|
bIsDrowning = false;
|
|
|
|
|
}else if(heliHitWaterHard || impulseRatio > 1.0f ||
|
|
|
|
|
impulseRatio > 0.6f && (m_aSuspensionSpringRatio[0] == 1.0f ||
|
|
|
|
|
m_aSuspensionSpringRatio[1] == 1.0f ||
|
|
|
|
|
m_aSuspensionSpringRatio[2] == 1.0f ||
|
|
|
|
|
m_aSuspensionSpringRatio[3] == 1.0f)){
|
2019-07-24 21:06:48 +00:00
|
|
|
|
bIsInWater = true;
|
2020-05-19 17:54:05 +00:00
|
|
|
|
bIsDrowning = true;
|
2019-07-24 21:06:48 +00:00
|
|
|
|
if(m_vecMoveSpeed.z < -0.1f)
|
|
|
|
|
m_vecMoveSpeed.z = -0.1f;
|
|
|
|
|
|
|
|
|
|
if(pDriver){
|
|
|
|
|
pDriver->bIsInWater = true;
|
|
|
|
|
if(pDriver->IsPlayer() || !bWaterTight)
|
2020-03-28 20:55:23 +00:00
|
|
|
|
pDriver->InflictDamage(nil, WEAPONTYPE_DROWNING, CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
|
2019-07-24 21:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
for(i = 0; i < m_nNumMaxPassengers; i++)
|
|
|
|
|
if(pPassengers[i]){
|
|
|
|
|
pPassengers[i]->bIsInWater = true;
|
|
|
|
|
if(pPassengers[i]->IsPlayer() || !bWaterTight)
|
2020-03-28 20:55:23 +00:00
|
|
|
|
pPassengers[i]->InflictDamage(nil, WEAPONTYPE_DROWNING, CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
|
2019-07-24 21:06:48 +00:00
|
|
|
|
}
|
2020-05-28 16:53:54 +00:00
|
|
|
|
}else{
|
2019-07-24 21:06:48 +00:00
|
|
|
|
bIsInWater = false;
|
2020-05-19 17:54:05 +00:00
|
|
|
|
bIsDrowning = false;
|
|
|
|
|
}
|
2019-07-24 21:06:48 +00:00
|
|
|
|
|
|
|
|
|
static uint32 nGenerateRaindrops = 0;
|
|
|
|
|
static uint32 nGenerateWaterCircles = 0;
|
|
|
|
|
|
2020-05-28 16:53:54 +00:00
|
|
|
|
if(initialSpeed.z < -0.1f && impulse.z > 0.3f || heliHitWaterHard){
|
2019-07-24 21:06:48 +00:00
|
|
|
|
RwRGBA color;
|
2020-05-28 16:53:54 +00:00
|
|
|
|
color.red = (0.5f * CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed_Obj())*0.45f*255;
|
|
|
|
|
color.green = (0.5f * CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj())*0.45f*255;
|
|
|
|
|
color.blue = (0.5f * CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj())*0.45f*255;
|
2019-07-24 21:06:48 +00:00
|
|
|
|
color.alpha = CGeneral::GetRandomNumberInRange(0, 32) + 128;
|
2020-05-28 16:53:54 +00:00
|
|
|
|
CVector target = CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.15f, 0.45f));
|
2019-07-24 21:06:48 +00:00
|
|
|
|
CParticleObject::AddObject(POBJECT_CAR_WATER_SPLASH, GetPosition(),
|
2020-05-28 16:53:54 +00:00
|
|
|
|
target, 0.0f, 75, color, true);
|
2019-07-24 21:06:48 +00:00
|
|
|
|
|
|
|
|
|
nGenerateRaindrops = CTimer::GetTimeInMilliseconds() + 300;
|
|
|
|
|
nGenerateWaterCircles = CTimer::GetTimeInMilliseconds() + 60;
|
2020-05-28 16:53:54 +00:00
|
|
|
|
|
|
|
|
|
if(heliHitWaterHard){
|
|
|
|
|
CVector right = CrossProduct(GetForward(), CVector(0.0f, 0.0f, 1.0f));
|
|
|
|
|
CParticleObject::AddObject(POBJECT_CAR_WATER_SPLASH, GetPosition() + right,
|
|
|
|
|
target, 0.0f, 75, color, true);
|
|
|
|
|
CParticleObject::AddObject(POBJECT_CAR_WATER_SPLASH, GetPosition() - right,
|
|
|
|
|
target, 0.0f, 75, color, true);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 21:06:48 +00:00
|
|
|
|
if(m_vecMoveSpeed.z < -0.2f)
|
|
|
|
|
m_vecMoveSpeed.z = -0.2f;
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WATER_FALL, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 16:53:54 +00:00
|
|
|
|
if(nGenerateWaterCircles > 0 && nGenerateWaterCircles <= CTimer::GetTimeInMilliseconds()){
|
2019-07-24 21:06:48 +00:00
|
|
|
|
CVector pos = GetPosition();
|
|
|
|
|
float waterLevel = 0.0f;
|
|
|
|
|
if(CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false))
|
|
|
|
|
pos.z = waterLevel;
|
|
|
|
|
static RwRGBA black;
|
|
|
|
|
if(pos.z != 0.0f){
|
|
|
|
|
nGenerateWaterCircles = 0;
|
|
|
|
|
pos.z += 1.0f;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
CVector p = pos;
|
|
|
|
|
p.x += CGeneral::GetRandomNumberInRange(-2.5f, 2.5f);
|
|
|
|
|
p.y += CGeneral::GetRandomNumberInRange(-2.5f, 2.5f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_RAIN_SPLASH_BIGGROW,
|
|
|
|
|
p, CVector(0.0f, 0.0f, 0.0f),
|
|
|
|
|
nil, 0.0f, black, 0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 16:53:54 +00:00
|
|
|
|
if(nGenerateRaindrops > 0 && nGenerateRaindrops <= CTimer::GetTimeInMilliseconds()){
|
2019-07-24 21:06:48 +00:00
|
|
|
|
CVector pos = GetPosition();
|
|
|
|
|
float waterLevel = 0.0f;
|
|
|
|
|
if(CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false))
|
|
|
|
|
pos.z = waterLevel;
|
|
|
|
|
static RwRGBA black;
|
|
|
|
|
if(pos.z >= 0.0f){
|
|
|
|
|
nGenerateRaindrops = 0;
|
2019-08-16 18:17:15 +00:00
|
|
|
|
pos.z += 0.5f;
|
2019-07-24 21:06:48 +00:00
|
|
|
|
CParticleObject::AddObject(POBJECT_SPLASHES_AROUND,
|
|
|
|
|
pos, CVector(0.0f, 0.0f, 0.0f), 6.5f, 2500, black, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
bIsInWater = false;
|
2020-05-19 17:54:05 +00:00
|
|
|
|
bIsDrowning = false;
|
2020-04-10 11:44:08 +00:00
|
|
|
|
bTouchingWater = false;
|
2019-07-24 21:06:48 +00:00
|
|
|
|
|
|
|
|
|
static RwRGBA splashCol = {155, 155, 185, 196};
|
|
|
|
|
static RwRGBA smokeCol = {255, 255, 255, 255};
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
2020-05-26 09:34:20 +00:00
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f && m_aWheelColPoints[i].surfaceB == SURFACE_WATER){
|
2019-07-24 21:06:48 +00:00
|
|
|
|
CVector pos = m_aWheelColPoints[i].point + 0.3f*GetUp() - GetPosition();
|
|
|
|
|
CVector vSpeed = GetSpeed(pos);
|
|
|
|
|
vSpeed.z = 0.0f;
|
|
|
|
|
float fSpeed = vSpeed.MagnitudeSqr();
|
|
|
|
|
if(fSpeed > sq(0.05f)){
|
|
|
|
|
fSpeed = Sqrt(fSpeed);
|
2020-04-23 08:24:03 +00:00
|
|
|
|
|
2020-04-19 16:34:08 +00:00
|
|
|
|
float size = Min((fSpeed < 0.15f ? 0.25f : 0.75f)*fSpeed, 0.6f);
|
2019-07-24 21:06:48 +00:00
|
|
|
|
CVector right = 0.2f*fSpeed*GetRight() + 0.2f*vSpeed;
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_PED_SPLASH,
|
|
|
|
|
pos + GetPosition(), -0.5f*right,
|
|
|
|
|
nil, size, splashCol,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 10.0f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 90.0f), 1, 0);
|
|
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE,
|
|
|
|
|
pos + GetPosition(), -0.6f*right,
|
|
|
|
|
nil, size, smokeCol, 0, 0, 0, 0);
|
2020-04-23 08:24:03 +00:00
|
|
|
|
|
2019-07-24 21:06:48 +00:00
|
|
|
|
if((CTimer::GetFrameCounter() & 0xF) == 0)
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_SPLASH, 2000.0f*fSpeed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-16 17:48:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-23 14:39:30 +00:00
|
|
|
|
void
|
2019-07-17 11:19:20 +00:00
|
|
|
|
CAutomobile::DoDriveByShootings(void)
|
2019-07-23 14:39:30 +00:00
|
|
|
|
{
|
2020-05-23 23:59:30 +00:00
|
|
|
|
CAnimBlendAssociation *anim = nil;
|
2020-07-01 16:03:39 +00:00
|
|
|
|
CPlayerInfo* playerInfo = ((CPlayerPed*)pDriver)->GetPlayerInfoForThisPlayerPed();
|
2020-05-17 17:36:48 +00:00
|
|
|
|
if (playerInfo && !playerInfo->m_bDriveByAllowed)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-07-23 14:39:30 +00:00
|
|
|
|
CWeapon *weapon = pDriver->GetWeapon();
|
2020-05-15 14:30:25 +00:00
|
|
|
|
if(CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->m_nWeaponSlot != 5)
|
2019-07-23 14:39:30 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-17 17:36:48 +00:00
|
|
|
|
weapon->Update(pDriver->m_audioEntityId, nil);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
|
|
|
|
|
bool lookingLeft = false;
|
|
|
|
|
bool lookingRight = false;
|
2020-05-28 16:53:54 +00:00
|
|
|
|
if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN ||
|
|
|
|
|
TheCamera.m_bObbeCinematicCarCamOn){
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(CPad::GetPad(0)->GetLookLeft())
|
|
|
|
|
lookingLeft = true;
|
|
|
|
|
if(CPad::GetPad(0)->GetLookRight())
|
|
|
|
|
lookingRight = true;
|
|
|
|
|
}else{
|
|
|
|
|
if(TheCamera.Cams[TheCamera.ActiveCam].LookingLeft)
|
|
|
|
|
lookingLeft = true;
|
|
|
|
|
if(TheCamera.Cams[TheCamera.ActiveCam].LookingRight)
|
|
|
|
|
lookingRight = true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 17:36:48 +00:00
|
|
|
|
AnimationId rightAnim = ANIM_DRIVEBY_R;
|
|
|
|
|
AnimationId leftAnim = ANIM_DRIVEBY_L;
|
|
|
|
|
if (pDriver->m_pMyVehicle->bLowVehicle) {
|
|
|
|
|
rightAnim = ANIM_DRIVEBY_LOW_R;
|
|
|
|
|
leftAnim = ANIM_DRIVEBY_LOW_L;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(lookingLeft || lookingRight){
|
|
|
|
|
if(lookingLeft){
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), rightAnim);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(anim)
|
|
|
|
|
anim->blendDelta = -1000.0f;
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), leftAnim);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(anim == nil || anim->blendDelta < 0.0f)
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, leftAnim);
|
2019-10-27 03:17:30 +00:00
|
|
|
|
}else if(pDriver->m_pMyVehicle->pPassengers[0] == nil || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), leftAnim);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(anim)
|
|
|
|
|
anim->blendDelta = -1000.0f;
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), rightAnim);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(anim == nil || anim->blendDelta < 0.0f)
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, rightAnim);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 17:36:48 +00:00
|
|
|
|
if (!anim || !anim->IsRunning()) {
|
|
|
|
|
if (CPad::GetPad(0)->GetCarGunFired() && CTimer::GetTimeInMilliseconds() > weapon->m_nTimer) {
|
2020-06-06 22:01:48 +00:00
|
|
|
|
weapon->FireFromCar(this, lookingLeft, true);
|
2020-05-17 17:36:48 +00:00
|
|
|
|
weapon->m_nTimer = CTimer::GetTimeInMilliseconds() + 70;
|
|
|
|
|
}
|
2019-07-23 14:39:30 +00:00
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
weapon->Reload();
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), leftAnim);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(anim)
|
|
|
|
|
anim->blendDelta = -1000.0f;
|
2020-05-17 17:36:48 +00:00
|
|
|
|
anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), rightAnim);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(anim)
|
|
|
|
|
anim->blendDelta = -1000.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: what is this?
|
|
|
|
|
if(!lookingLeft && m_weaponDoorTimerLeft > 0.0f){
|
2020-04-19 16:34:08 +00:00
|
|
|
|
m_weaponDoorTimerLeft = Max(m_weaponDoorTimerLeft - CTimer::GetTimeStep()*0.1f, 0.0f);
|
2020-05-20 17:10:05 +00:00
|
|
|
|
ProcessOpenDoor(CAR_DOOR_LF, NUM_STD_ANIMS, m_weaponDoorTimerLeft);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
}
|
|
|
|
|
if(!lookingRight && m_weaponDoorTimerRight > 0.0f){
|
2020-04-19 16:34:08 +00:00
|
|
|
|
m_weaponDoorTimerRight = Max(m_weaponDoorTimerRight - CTimer::GetTimeStep()*0.1f, 0.0f);
|
2020-05-20 17:10:05 +00:00
|
|
|
|
ProcessOpenDoor(CAR_DOOR_RF, NUM_STD_ANIMS, m_weaponDoorTimerRight);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
}
|
2019-07-17 11:19:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::DoHoverSuspensionRatios(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if(GetUp().z < 0.1f)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CColModel *colmodel = GetColModel();
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
float z, waterZ;
|
|
|
|
|
CVector upper = GetMatrix() * colmodel->lines[i].p0;
|
|
|
|
|
CVector lower = GetMatrix() * colmodel->lines[i].p1;
|
|
|
|
|
if(m_aSuspensionSpringRatio[i] < 1.0f)
|
|
|
|
|
z = m_aWheelColPoints[i].point.z;
|
|
|
|
|
else
|
|
|
|
|
z = -100.0f;
|
|
|
|
|
// see if touching water
|
|
|
|
|
if(CWaterLevel::GetWaterLevel(lower, &waterZ, false) &&
|
|
|
|
|
waterZ > z && lower.z-1.0f < waterZ){
|
|
|
|
|
// compress spring
|
|
|
|
|
if(lower.z < waterZ){
|
|
|
|
|
if(upper.z < waterZ)
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 0.0f;
|
|
|
|
|
else
|
|
|
|
|
m_aSuspensionSpringRatio[i] = (upper.z - waterZ)/(upper.z - lower.z);
|
|
|
|
|
}else
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 0.99999f;
|
|
|
|
|
|
|
|
|
|
m_aWheelColPoints[i].point.x = (lower.x - upper.x)*m_aSuspensionSpringRatio[i] + upper.x;
|
|
|
|
|
m_aWheelColPoints[i].point.y = (lower.y - upper.y)*m_aSuspensionSpringRatio[i] + upper.y;
|
|
|
|
|
m_aWheelColPoints[i].point.z = waterZ;
|
|
|
|
|
m_aWheelColPoints[i].normal = CVector(0.01f, 0.0f, 1.0f);
|
|
|
|
|
m_aWheelColPoints[i].surfaceB = SURFACE_WATER;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-23 14:39:30 +00:00
|
|
|
|
int32
|
2019-07-17 11:19:20 +00:00
|
|
|
|
CAutomobile::RcbanditCheckHitWheels(void)
|
2019-07-23 14:39:30 +00:00
|
|
|
|
{
|
|
|
|
|
int x, xmin, xmax;
|
|
|
|
|
int y, ymin, ymax;
|
|
|
|
|
|
|
|
|
|
xmin = CWorld::GetSectorIndexX(GetPosition().x - 2.0f);
|
|
|
|
|
if(xmin < 0) xmin = 0;
|
|
|
|
|
xmax = CWorld::GetSectorIndexX(GetPosition().x + 2.0f);
|
|
|
|
|
if(xmax > NUMSECTORS_X-1) xmax = NUMSECTORS_X-1;
|
2020-03-07 19:22:43 +00:00
|
|
|
|
ymin = CWorld::GetSectorIndexY(GetPosition().y - 2.0f);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(ymin < 0) ymin = 0;
|
2020-03-07 19:22:43 +00:00
|
|
|
|
ymax = CWorld::GetSectorIndexY(GetPosition().y + 2.0f);
|
2019-07-23 14:39:30 +00:00
|
|
|
|
if(ymax > NUMSECTORS_Y-1) ymax = NUMSECTORS_X-1;
|
|
|
|
|
|
|
|
|
|
CWorld::AdvanceCurrentScanCode();
|
|
|
|
|
|
|
|
|
|
for(y = ymin; y <= ymax; y++)
|
|
|
|
|
for(x = xmin; x <= xmax; x++){
|
|
|
|
|
CSector *s = CWorld::GetSector(x, y);
|
|
|
|
|
if(RcbanditCheck1CarWheels(s->m_lists[ENTITYLIST_VEHICLES]) ||
|
|
|
|
|
RcbanditCheck1CarWheels(s->m_lists[ENTITYLIST_VEHICLES_OVERLAP]))
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32
|
|
|
|
|
CAutomobile::RcbanditCheck1CarWheels(CPtrList &list)
|
|
|
|
|
{
|
|
|
|
|
static CMatrix matW2B;
|
|
|
|
|
int i;
|
|
|
|
|
CPtrNode *node;
|
|
|
|
|
CAutomobile *car;
|
|
|
|
|
CColModel *colModel = GetColModel();
|
|
|
|
|
CVehicleModelInfo *mi;
|
|
|
|
|
|
|
|
|
|
for(node = list.first; node; node = node->next){
|
|
|
|
|
car = (CAutomobile*)node->item;
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(this != car && car->IsCar() && car->GetModelIndex() != MI_RCBANDIT &&
|
|
|
|
|
car->m_scanCode != CWorld::GetCurrentScanCode()){
|
2019-07-23 14:39:30 +00:00
|
|
|
|
car->m_scanCode = CWorld::GetCurrentScanCode();
|
|
|
|
|
|
|
|
|
|
if(Abs(this->GetPosition().x - car->GetPosition().x) < 10.0f &&
|
|
|
|
|
Abs(this->GetPosition().y - car->GetPosition().y) < 10.0f){
|
|
|
|
|
mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(car->GetModelIndex());
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++){
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(car->m_aSuspensionSpringRatioPrev[i] < 1.0f || car->GetStatus() == STATUS_SIMPLE){
|
2019-07-23 14:39:30 +00:00
|
|
|
|
CVector wheelPos;
|
|
|
|
|
CColSphere sph;
|
|
|
|
|
mi->GetWheelPosn(i, wheelPos);
|
|
|
|
|
matW2B = Invert(GetMatrix());
|
|
|
|
|
sph.center = matW2B * (car->GetMatrix() * wheelPos);
|
|
|
|
|
sph.radius = mi->m_wheelScale*0.25f;
|
|
|
|
|
if(CCollision::TestSphereBox(sph, colModel->boundingBox))
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::PlaceOnRoadProperly(void)
|
|
|
|
|
{
|
|
|
|
|
CColPoint point;
|
|
|
|
|
CEntity *entity;
|
|
|
|
|
CColModel *colModel = GetColModel();
|
|
|
|
|
float lenFwd, lenBack;
|
|
|
|
|
float frontZ, rearZ;
|
|
|
|
|
|
|
|
|
|
lenFwd = colModel->boundingBox.max.y;
|
|
|
|
|
lenBack = -colModel->boundingBox.min.y;
|
|
|
|
|
|
|
|
|
|
CVector front(GetPosition().x + GetForward().x*lenFwd,
|
|
|
|
|
GetPosition().y + GetForward().y*lenFwd,
|
|
|
|
|
GetPosition().z + 5.0f);
|
|
|
|
|
if(CWorld::ProcessVerticalLine(front, GetPosition().z - 5.0f, point, entity,
|
|
|
|
|
true, false, false, false, false, false, nil)){
|
|
|
|
|
frontZ = point.point.z;
|
|
|
|
|
m_pCurGroundEntity = entity;
|
|
|
|
|
}else{
|
2019-09-12 10:11:13 +00:00
|
|
|
|
frontZ = m_fMapObjectHeightAhead;
|
2019-07-23 14:39:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CVector rear(GetPosition().x - GetForward().x*lenBack,
|
|
|
|
|
GetPosition().y - GetForward().y*lenBack,
|
|
|
|
|
GetPosition().z + 5.0f);
|
|
|
|
|
if(CWorld::ProcessVerticalLine(rear, GetPosition().z - 5.0f, point, entity,
|
|
|
|
|
true, false, false, false, false, false, nil)){
|
|
|
|
|
rearZ = point.point.z;
|
|
|
|
|
m_pCurGroundEntity = entity;
|
|
|
|
|
}else{
|
2019-09-12 10:11:13 +00:00
|
|
|
|
rearZ = m_fMapObjectHeightBehind;
|
2019-07-23 14:39:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float len = lenFwd + lenBack;
|
|
|
|
|
float angle = Atan((frontZ - rearZ)/len);
|
|
|
|
|
float c = Cos(angle);
|
|
|
|
|
float s = Sin(angle);
|
|
|
|
|
|
2020-05-05 01:45:18 +00:00
|
|
|
|
GetMatrix().GetRight() = CVector((front.y - rear.y) / len, -(front.x - rear.x) / len, 0.0f);
|
|
|
|
|
GetMatrix().GetForward() = CVector(-c * GetRight().y, c * GetRight().x, s);
|
|
|
|
|
GetMatrix().GetUp() = CrossProduct(GetRight(), GetForward());
|
|
|
|
|
GetMatrix().GetPosition() = CVector((front.x + rear.x) / 2.0f, (front.y + rear.y) / 2.0f, (frontZ + rearZ) / 2.0f + GetHeightAboveRoad());
|
2019-07-17 11:19:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 19:41:20 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2020-05-27 20:32:33 +00:00
|
|
|
|
float damageMultiplier = 0.333f;
|
2019-07-18 19:41:20 +00:00
|
|
|
|
|
|
|
|
|
if(impulse == 0.0f){
|
|
|
|
|
impulse = m_fDamageImpulse;
|
|
|
|
|
damagedPiece = m_nDamagePieceType;
|
|
|
|
|
damageMultiplier = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER && CStats::GetPercentageProgress() >= 100.0f)
|
|
|
|
|
impulse *= 0.5f;
|
|
|
|
|
|
2019-07-18 19:41:20 +00:00
|
|
|
|
CVector pos(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
if(!bCanBeDamaged)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(m_pDamageEntity && m_pDamageEntity->IsPed() && ((CPed*)m_pDamageEntity)->bIsStanding){
|
|
|
|
|
float speed = ((CPed*)m_pDamageEntity)->m_vecAnimMoveDelta.y * DotProduct(GetForward(), m_vecDamageNormal);
|
|
|
|
|
if(speed < 0.0f)
|
|
|
|
|
impulse = Max(impulse + ((CPed*)m_pDamageEntity)->m_fMass * speed, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 19:41:20 +00:00
|
|
|
|
// damage flipped over car
|
|
|
|
|
if(GetUp().z < 0.0f && this != FindPlayerVehicle()){
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(bNotDamagedUpsideDown || GetStatus() == STATUS_PLAYER_REMOTE || bIsInWater)
|
2019-07-18 19:41:20 +00:00
|
|
|
|
return;
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(GetStatus() != STATUS_WRECKED)
|
|
|
|
|
m_fHealth = Max(m_fHealth - 4.0f*CTimer::GetTimeStep(), 0.0f);
|
2019-07-18 19:41:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
float minImpulse = GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN ? 1.0f : 25.0f;
|
|
|
|
|
if(impulse > minImpulse && GetStatus() != STATUS_WRECKED){
|
2019-07-18 19:41:20 +00:00
|
|
|
|
if(bIsLawEnforcer &&
|
|
|
|
|
FindPlayerVehicle() && FindPlayerVehicle() == m_pDamageEntity &&
|
2020-05-27 20:32:33 +00:00
|
|
|
|
GetStatus() != STATUS_ABANDONED &&
|
2019-07-18 19:41:20 +00:00
|
|
|
|
FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() >= m_vecMoveSpeed.Magnitude() &&
|
2019-07-19 11:58:19 +00:00
|
|
|
|
FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() > 0.1f)
|
2019-07-18 19:41:20 +00:00
|
|
|
|
FindPlayerPed()->SetWantedLevelNoDrop(1);
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_PLAYER && impulse > 50.0f){
|
2020-04-19 16:34:08 +00:00
|
|
|
|
uint8 freq = Min(0.4f*impulse*2000.0f/m_fMass + 100.0f, 250.0f);
|
2019-07-18 19:41:20 +00:00
|
|
|
|
CPad::GetPad(0)->StartShake(40000/freq, freq);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(GetStatus() != STATUS_PLAYER && bOnlyDamagedByPlayer){
|
2019-07-18 19:41:20 +00:00
|
|
|
|
if(m_pDamageEntity != FindPlayerPed() &&
|
|
|
|
|
m_pDamageEntity != FindPlayerVehicle())
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(m_pDamageEntity && m_pDamageEntity->IsVehicle()){
|
|
|
|
|
m_nLastWeaponDamage = WEAPONTYPE_RAMMEDBYCAR;
|
|
|
|
|
m_pLastDamageEntity = m_pDamageEntity;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 19:41:20 +00:00
|
|
|
|
if(bCollisionProof)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(m_pDamageEntity){
|
2019-07-20 12:39:38 +00:00
|
|
|
|
if(m_pDamageEntity->IsBuilding() &&
|
2019-07-18 19:41:20 +00:00
|
|
|
|
DotProduct(m_vecDamageNormal, GetUp()) > 0.6f)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int oldLightStatus[4];
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
oldLightStatus[i] = Damage.GetLightStatus((eLights)i);
|
|
|
|
|
|
|
|
|
|
if(GetUp().z > 0.0f || m_vecMoveSpeed.MagnitudeSqr() > 0.1f){
|
|
|
|
|
float impulseMult = bMoreResistantToDamage ? 0.5f : 4.0f;
|
|
|
|
|
|
|
|
|
|
switch(damagedPiece){
|
|
|
|
|
case CAR_PIECE_BUMP_FRONT:
|
|
|
|
|
GetComponentWorldPosition(CAR_BUMP_FRONT, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_BUMPER_FRONT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetBumperDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT);
|
|
|
|
|
if(m_aCarNodes[CAR_BONNET] && Damage.GetPanelStatus(VEHBUMPER_FRONT) == PANEL_STATUS_MISSING){
|
|
|
|
|
case CAR_PIECE_BONNET:
|
|
|
|
|
GetComponentWorldPosition(CAR_BONNET, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(GetModelIndex() != MI_DODO)
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_DOOR_BONNET, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetDoorDamage(CAR_BONNET, DOOR_BONNET);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CAR_PIECE_BUMP_REAR:
|
|
|
|
|
GetComponentWorldPosition(CAR_BUMP_REAR, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_BUMPER_REAR, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetBumperDamage(CAR_BUMP_REAR, VEHBUMPER_REAR);
|
|
|
|
|
if(m_aCarNodes[CAR_BOOT] && Damage.GetPanelStatus(VEHBUMPER_REAR) == PANEL_STATUS_MISSING){
|
|
|
|
|
case CAR_PIECE_BOOT:
|
|
|
|
|
GetComponentWorldPosition(CAR_BOOT, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_DOOR_BOOT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetDoorDamage(CAR_BOOT, DOOR_BOOT);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CAR_PIECE_DOOR_LF:
|
|
|
|
|
GetComponentWorldPosition(CAR_DOOR_LF, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_DOOR_FRONT_LEFT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT);
|
|
|
|
|
break;
|
|
|
|
|
case CAR_PIECE_DOOR_RF:
|
|
|
|
|
GetComponentWorldPosition(CAR_DOOR_RF, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_DOOR_FRONT_RIGHT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT);
|
|
|
|
|
break;
|
|
|
|
|
case CAR_PIECE_DOOR_LR:
|
|
|
|
|
GetComponentWorldPosition(CAR_DOOR_LR, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_DOOR_REAR_LEFT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT);
|
|
|
|
|
break;
|
|
|
|
|
case CAR_PIECE_DOOR_RR:
|
|
|
|
|
GetComponentWorldPosition(CAR_DOOR_RR, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_DOOR_REAR_RIGHT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CAR_PIECE_WING_LF:
|
|
|
|
|
GetComponentWorldPosition(CAR_WING_LF, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_PANEL_FRONT_LEFT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetPanelDamage(CAR_WING_LF, VEHPANEL_FRONT_LEFT);
|
|
|
|
|
break;
|
|
|
|
|
case CAR_PIECE_WING_RF:
|
|
|
|
|
GetComponentWorldPosition(CAR_WING_RF, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_PANEL_FRONT_RIGHT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetPanelDamage(CAR_WING_RF, VEHPANEL_FRONT_RIGHT);
|
|
|
|
|
break;
|
|
|
|
|
case CAR_PIECE_WING_LR:
|
|
|
|
|
GetComponentWorldPosition(CAR_WING_LR, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_PANEL_REAR_LEFT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetPanelDamage(CAR_WING_LR, VEHPANEL_REAR_LEFT);
|
|
|
|
|
break;
|
|
|
|
|
case CAR_PIECE_WING_RR:
|
|
|
|
|
GetComponentWorldPosition(CAR_WING_RR, pos);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
dmgDrawCarCollidingParticles(pos, impulse*damageMultiplier);
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_PANEL_REAR_RIGHT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier))
|
2019-07-18 19:41:20 +00:00
|
|
|
|
SetPanelDamage(CAR_WING_RR, VEHPANEL_REAR_RIGHT);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CAR_PIECE_WHEEL_LF:
|
|
|
|
|
case CAR_PIECE_WHEEL_LR:
|
|
|
|
|
case CAR_PIECE_WHEEL_RF:
|
|
|
|
|
case CAR_PIECE_WHEEL_RR:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CAR_PIECE_WINDSCREEN:
|
|
|
|
|
if(Damage.ApplyDamage(COMPONENT_PANEL_WINDSCREEN, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){
|
|
|
|
|
uint8 oldStatus = Damage.GetPanelStatus(VEHPANEL_WINDSCREEN);
|
|
|
|
|
SetPanelDamage(CAR_WINDSCREEN, VEHPANEL_WINDSCREEN);
|
|
|
|
|
if(oldStatus != Damage.GetPanelStatus(VEHPANEL_WINDSCREEN)){
|
2020-05-27 20:32:33 +00:00
|
|
|
|
// DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_WINDSHIELD_CRACK, 0.0f);
|
2019-07-18 19:41:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
float damage = (impulse-minImpulse)*pHandling->fCollisionDamageMultiplier*0.6f*damageMultiplier;
|
2019-07-18 19:41:20 +00:00
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetModelIndex() == MI_SECURICA && m_pDamageEntity && m_pDamageEntity->GetStatus() == STATUS_PLAYER)
|
2019-07-18 19:41:20 +00:00
|
|
|
|
damage *= 7.0f;
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(GetModelIndex() == MI_RCGOBLIN || GetModelIndex() == MI_RCRAIDER)
|
|
|
|
|
damage *= 30.0f;
|
|
|
|
|
|
2019-07-18 19:41:20 +00:00
|
|
|
|
if(damage > 0.0f){
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(damage > 5.0f &&
|
|
|
|
|
pDriver &&
|
|
|
|
|
m_pDamageEntity && m_pDamageEntity->IsVehicle() &&
|
|
|
|
|
(this != FindPlayerVehicle() || ((CVehicle*)m_pDamageEntity)->VehicleCreatedBy == MISSION_VEHICLE) &&
|
|
|
|
|
((CVehicle*)m_pDamageEntity)->pDriver){
|
2020-06-04 15:38:41 +00:00
|
|
|
|
if(GetVehicleAppearance() == VEHICLE_APPEARANCE_CAR)
|
2020-08-20 11:20:48 +00:00
|
|
|
|
pDriver->Say(SOUND_PED_CRASH_CAR);
|
2020-06-04 15:38:41 +00:00
|
|
|
|
else
|
2020-08-20 11:20:48 +00:00
|
|
|
|
pDriver->Say(SOUND_PED_CRASH_VEHICLE);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 19:41:20 +00:00
|
|
|
|
int oldHealth = m_fHealth;
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(this == FindPlayerVehicle())
|
2019-07-18 19:41:20 +00:00
|
|
|
|
m_fHealth -= bTakeLessDamage ? damage/6.0f : damage/2.0f;
|
2020-05-27 20:32:33 +00:00
|
|
|
|
else if(bTakeLessDamage)
|
|
|
|
|
m_fHealth -= damage/12.0f;
|
|
|
|
|
else if(m_pDamageEntity && m_pDamageEntity == FindPlayerVehicle())
|
|
|
|
|
m_fHealth -= damage/1.5f;
|
|
|
|
|
else
|
|
|
|
|
m_fHealth -= damage/4.0f;
|
2019-07-18 19:41:20 +00:00
|
|
|
|
if(m_fHealth <= 0.0f && oldHealth > 0)
|
|
|
|
|
m_fHealth = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// play sound if a light broke
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
if(oldLightStatus[i] != 1 && Damage.GetLightStatus((eLights)i) == 1){
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_LIGHT_BREAK, i); // BUG? i?
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_fHealth < 250.0f){
|
|
|
|
|
// Car is on fire
|
|
|
|
|
if(Damage.GetEngineStatus() < ENGINE_STATUS_ON_FIRE){
|
|
|
|
|
// Set engine on fire and remember who did this
|
|
|
|
|
Damage.SetEngineStatus(ENGINE_STATUS_ON_FIRE);
|
|
|
|
|
m_fFireBlowUpTimer = 0.0f;
|
|
|
|
|
m_pSetOnFireEntity = m_pDamageEntity;
|
|
|
|
|
if(m_pSetOnFireEntity)
|
|
|
|
|
m_pSetOnFireEntity->RegisterReference(&m_pSetOnFireEntity);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(GetModelIndex() == MI_BFINJECT){
|
|
|
|
|
if(m_fHealth < 400.0f)
|
|
|
|
|
Damage.SetEngineStatus(200);
|
|
|
|
|
else if(m_fHealth < 600.0f)
|
|
|
|
|
Damage.SetEngineStatus(100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::dmgDrawCarCollidingParticles(const CVector &pos, float amount)
|
|
|
|
|
{
|
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
|
|
if(!GetIsOnScreen())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// FindPlayerSpeed() unused
|
|
|
|
|
|
|
|
|
|
n = (int)amount/20;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < ((n+4)&0x1F); i++)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, pos,
|
|
|
|
|
CVector(CGeneral::GetRandomNumberInRange(-0.1f, 0.1f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(-0.1f, 0.1f),
|
|
|
|
|
0.006f));
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < n+2; i++)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CARCOLLISION_DUST,
|
|
|
|
|
CVector(CGeneral::GetRandomNumberInRange(-1.2f, 1.2f) + pos.x,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(-1.2f, 1.2f) + pos.y,
|
|
|
|
|
pos.z),
|
|
|
|
|
CVector(0.0f, 0.0f, 0.0f), nil, 0.5f);
|
|
|
|
|
|
|
|
|
|
n = (int)amount/50 + 1;
|
|
|
|
|
for(i = 0; i < n; i++)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, pos,
|
|
|
|
|
CVector(CGeneral::GetRandomNumberInRange(-0.25f, 0.25f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(-0.25f, 0.25f),
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.1f, 0.25f)),
|
|
|
|
|
nil,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.02f, 0.08f),
|
|
|
|
|
CVehicleModelInfo::ms_vehicleColourTable[m_currentColour1],
|
|
|
|
|
CGeneral::GetRandomNumberInRange(-40.0f, 40.0f),
|
|
|
|
|
0,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.0f, 4.0f));
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-26 16:48:14 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::AddDamagedVehicleParticles(void)
|
|
|
|
|
{
|
2020-05-28 16:53:54 +00:00
|
|
|
|
int i, n;
|
|
|
|
|
|
2019-07-26 16:48:14 +00:00
|
|
|
|
if(this == FindPlayerVehicle() && TheCamera.GetLookingForwardFirstPerson())
|
|
|
|
|
return;
|
2020-05-28 16:53:54 +00:00
|
|
|
|
if(this != FindPlayerVehicle() && (CTimer::GetFrameCounter() + m_randomSeed) & 1)
|
|
|
|
|
return;
|
|
|
|
|
if(m_fHealth >= 650.0f)
|
2019-07-26 16:48:14 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-28 16:53:54 +00:00
|
|
|
|
CVector direction = 0.85f*m_vecMoveSpeed;
|
2019-07-26 16:48:14 +00:00
|
|
|
|
CVector damagePos = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->m_positions[CAR_POS_HEADLIGHTS];
|
|
|
|
|
|
|
|
|
|
switch(Damage.GetDoorStatus(DOOR_BONNET)){
|
|
|
|
|
case DOOR_STATUS_OK:
|
|
|
|
|
case DOOR_STATUS_SMASHED:
|
|
|
|
|
// Bonnet is still there, smoke comes out at the edge
|
|
|
|
|
damagePos += vecDAMAGE_ENGINE_POS_SMALL;
|
|
|
|
|
break;
|
|
|
|
|
case DOOR_STATUS_SWINGING:
|
|
|
|
|
case DOOR_STATUS_MISSING:
|
|
|
|
|
// Bonnet is gone, smoke comes out at the engine
|
|
|
|
|
damagePos += vecDAMAGE_ENGINE_POS_BIG;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(GetModelIndex() == MI_BFINJECT)
|
|
|
|
|
damagePos = CVector(0.3f, -1.5f, -0.1f);
|
2020-05-28 16:53:54 +00:00
|
|
|
|
else if(GetModelIndex() == MI_CADDY)
|
|
|
|
|
damagePos = CVector(0.6f, -1.0f, -0.25f);
|
|
|
|
|
else if(IsRealHeli()){
|
|
|
|
|
damagePos.x = 0.4f*GetColModel()->boundingBox.max.x;
|
|
|
|
|
damagePos.y = 0.2f*GetColModel()->boundingBox.min.y;
|
|
|
|
|
damagePos.z = 0.3f*GetColModel()->boundingBox.max.z;
|
|
|
|
|
}else
|
|
|
|
|
damagePos.z += 0.4f*(GetColModel()->boundingBox.max.z-damagePos.z) * DotProduct(GetForward(), m_vecMoveSpeed);
|
2019-07-26 16:48:14 +00:00
|
|
|
|
damagePos = GetMatrix()*damagePos;
|
|
|
|
|
damagePos.z += 0.15f;
|
|
|
|
|
|
2020-05-28 16:53:54 +00:00
|
|
|
|
bool electric = pHandling->Transmission.nEngineType == 'E';
|
|
|
|
|
|
|
|
|
|
if(electric && m_fHealth < 320.0f && m_fHealth > 1.0f){
|
|
|
|
|
direction = 0.85f*m_vecMoveSpeed;
|
|
|
|
|
direction += GetRight() * CGeneral::GetRandomNumberInRange(0.0f, 0.04f) * (1.0f - 2.0f*m_vecMoveSpeed.Magnitude());
|
|
|
|
|
direction.z += 0.001f;
|
|
|
|
|
n = (CGeneral::GetRandomNumber() & 7) + 2;
|
|
|
|
|
for(i = 0; i < n; i++)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, damagePos, direction);
|
|
|
|
|
if(((CTimer::GetFrameCounter() + m_randomSeed) & 7) == 0)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE2, damagePos, 0.8f*m_vecMoveSpeed, nil, 0.1f, 0, 0, 0, 1000);
|
|
|
|
|
}else if(electric && m_fHealth < 460.0f){
|
|
|
|
|
direction = 0.85f*m_vecMoveSpeed;
|
|
|
|
|
direction += GetRight() * CGeneral::GetRandomNumberInRange(0.0f, 0.04f) * (1.0f - 2.0f*m_vecMoveSpeed.Magnitude());
|
|
|
|
|
direction.z += 0.001f;
|
|
|
|
|
n = (CGeneral::GetRandomNumber() & 3) + 2;
|
|
|
|
|
for(i = 0; i < n; i++)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, damagePos, direction);
|
|
|
|
|
if(((CTimer::GetFrameCounter() + m_randomSeed) & 0xF) == 0)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE, damagePos, 0.8f*m_vecMoveSpeed, nil, 0.1f, 0, 0, 0, 1000);
|
|
|
|
|
}else if(m_fHealth < 250.0f){
|
|
|
|
|
// nothing
|
|
|
|
|
}else if(m_fHealth < 320.0f){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE2, damagePos, 0.8f*direction);
|
|
|
|
|
}else if(m_fHealth < 390.0f){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM, damagePos, 0.75f*direction);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE, damagePos, 0.85f*direction);
|
|
|
|
|
}else if(m_fHealth < 460.0f){
|
|
|
|
|
int rnd = CTimer::GetFrameCounter() + m_randomSeed;
|
|
|
|
|
if(rnd < 10 ||
|
|
|
|
|
rnd < 70 && rnd > 25 ||
|
|
|
|
|
rnd < 160 && rnd > 100 ||
|
|
|
|
|
rnd < 200 && rnd > 175 ||
|
|
|
|
|
rnd > 235)
|
|
|
|
|
return;
|
|
|
|
|
direction.z += 0.05f*Max(1.0f - 1.6f*m_vecMoveSpeed.Magnitude(), 0.0f);
|
|
|
|
|
if(electric){
|
|
|
|
|
// BUG. we had that case already
|
|
|
|
|
direction = 0.85f*m_vecMoveSpeed;
|
|
|
|
|
direction += GetRight() * CGeneral::GetRandomNumberInRange(0.0f, 0.04f) * (1.0f - 2.0f*m_vecMoveSpeed.Magnitude());
|
|
|
|
|
direction.z += 0.001f;
|
|
|
|
|
n = (CGeneral::GetRandomNumber() & 2) + 2;
|
|
|
|
|
for(i = 0; i < n; i++)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SPARK_SMALL, damagePos, direction);
|
|
|
|
|
if(((CTimer::GetFrameCounter() + m_randomSeed) & 0xF) == 0)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE, damagePos, 0.8f*m_vecMoveSpeed, nil, 0.1f, 0, 0, 0, 1000);
|
|
|
|
|
}else{
|
|
|
|
|
if(TheCamera.GetLookDirection() != LOOKING_FORWARD)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM, damagePos, 0.75f*direction);
|
|
|
|
|
else if(((CTimer::GetFrameCounter() + m_randomSeed) & 1) == 0)
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM, damagePos, 0.85f*m_vecMoveSpeed);
|
|
|
|
|
}
|
|
|
|
|
}else if(((CTimer::GetFrameCounter() + m_randomSeed) & 3) == 0 ||
|
|
|
|
|
((CTimer::GetFrameCounter() + m_randomSeed) & 3) == 2){
|
|
|
|
|
CParticle::AddParticle(PARTICLE_ENGINE_STEAM, damagePos, 0.9f*direction);
|
2019-07-26 16:48:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 11:14:08 +00:00
|
|
|
|
int32
|
2019-07-26 16:48:14 +00:00
|
|
|
|
CAutomobile::AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
CVector dir;
|
|
|
|
|
static RwRGBA grassCol = { 8, 24, 8, 255 };
|
2020-05-27 20:32:33 +00:00
|
|
|
|
static RwRGBA gravelCol = { 64, 64, 64, 255 };
|
|
|
|
|
static RwRGBA mudCol = { 64, 32, 16, 255 };
|
|
|
|
|
static RwRGBA sandCol = { 170, 165, 140, 255 };
|
2019-07-26 16:48:14 +00:00
|
|
|
|
static RwRGBA waterCol = { 48, 48, 64, 0 };
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(!belowEffectSpeed &&
|
|
|
|
|
colpoint->surfaceB != SURFACE_SAND && colpoint->surfaceB != SURFACE_SAND_BEACH)
|
2019-07-28 11:14:08 +00:00
|
|
|
|
return 0;
|
2019-07-26 16:48:14 +00:00
|
|
|
|
|
|
|
|
|
switch(colpoint->surfaceB){
|
|
|
|
|
case SURFACE_GRASS:
|
|
|
|
|
dir.x = -0.05f*m_vecMoveSpeed.x;
|
|
|
|
|
dir.y = -0.05f*m_vecMoveSpeed.y;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.02f, 0.1f), grassCol);
|
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
return 0;
|
2020-05-26 09:34:20 +00:00
|
|
|
|
case SURFACE_GRAVEL:
|
2019-07-26 16:48:14 +00:00
|
|
|
|
dir.x = -0.05f*m_vecMoveSpeed.x;
|
|
|
|
|
dir.y = -0.05f*m_vecMoveSpeed.y;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil,
|
2020-05-27 20:32:33 +00:00
|
|
|
|
CGeneral::GetRandomNumberInRange(0.05f, 0.09f), gravelCol);
|
2019-07-26 16:48:14 +00:00
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
return 1;
|
2020-05-26 09:34:20 +00:00
|
|
|
|
case SURFACE_MUD_DRY:
|
2019-07-26 16:48:14 +00:00
|
|
|
|
dir.x = -0.05f*m_vecMoveSpeed.x;
|
|
|
|
|
dir.y = -0.05f*m_vecMoveSpeed.y;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil,
|
2020-05-27 20:32:33 +00:00
|
|
|
|
CGeneral::GetRandomNumberInRange(0.02f, 0.06f), mudCol);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
case SURFACE_SAND:
|
|
|
|
|
case SURFACE_SAND_BEACH:
|
|
|
|
|
if(CTimer::GetFrameCounter() & 2 ||
|
|
|
|
|
CGeneral::GetRandomNumberInRange(CWeather::WetRoads, 1.01f) > 0.5f)
|
|
|
|
|
return 0;
|
|
|
|
|
dir.x = 0.5f*m_vecMoveSpeed.x;
|
|
|
|
|
dir.y = 0.5f*m_vecMoveSpeed.y;
|
|
|
|
|
for(i = 0; i < 1; i++){
|
|
|
|
|
dir.z = CGeneral::GetRandomNumberInRange(0.02f, 0.055f);
|
|
|
|
|
CParticle::AddParticle(PARTICLE_SAND, colpoint->point, dir, nil,
|
|
|
|
|
2.0f*m_vecMoveSpeed.Magnitude(), sandCol);
|
2019-07-26 16:48:14 +00:00
|
|
|
|
}
|
2019-07-28 11:14:08 +00:00
|
|
|
|
return 0;
|
2019-07-26 16:48:14 +00:00
|
|
|
|
default:
|
2020-06-06 22:01:48 +00:00
|
|
|
|
if(CWeather::WetRoads > 0.01f){
|
|
|
|
|
if(CTimer::GetFrameCounter() & 1)
|
|
|
|
|
CParticle::AddParticle(
|
|
|
|
|
PARTICLE_WATERSPRAY,
|
|
|
|
|
colpoint->point + CVector(0.0f, 0.0f, 0.25f+0.25f),
|
|
|
|
|
CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.005f, 0.04f)),
|
|
|
|
|
nil,
|
|
|
|
|
CGeneral::GetRandomNumberInRange(0.1f, 0.5f), waterCol);
|
2019-07-28 11:14:08 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
2019-07-26 16:48:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 06:46:42 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::GetComponentWorldPosition(int32 component, CVector &pos)
|
|
|
|
|
{
|
|
|
|
|
if(m_aCarNodes[component] == nil){
|
|
|
|
|
printf("CarNode missing: %d %d\n", GetModelIndex(), component);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
RwMatrix *ltm = RwFrameGetLTM(m_aCarNodes[component]);
|
|
|
|
|
pos = *RwMatrixGetPos(ltm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsComponentPresent(int32 comp)
|
|
|
|
|
{
|
|
|
|
|
return m_aCarNodes[comp] != nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetComponentRotation(int32 component, CVector rotation)
|
|
|
|
|
{
|
|
|
|
|
CMatrix mat(RwFrameGetMatrix(m_aCarNodes[component]));
|
2019-07-08 19:37:47 +00:00
|
|
|
|
CVector pos = mat.GetPosition();
|
2019-07-08 06:46:42 +00:00
|
|
|
|
// BUG: all these set the whole matrix
|
|
|
|
|
mat.SetRotateX(DEGTORAD(rotation.x));
|
|
|
|
|
mat.SetRotateY(DEGTORAD(rotation.y));
|
|
|
|
|
mat.SetRotateZ(DEGTORAD(rotation.z));
|
2019-07-08 19:37:47 +00:00
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::OpenDoor(int32 component, eDoors door, float openRatio)
|
|
|
|
|
{
|
|
|
|
|
CMatrix mat(RwFrameGetMatrix(m_aCarNodes[component]));
|
|
|
|
|
CVector pos = mat.GetPosition();
|
|
|
|
|
float axes[3] = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
float wasClosed = false;
|
|
|
|
|
|
|
|
|
|
if(Doors[door].IsClosed()){
|
|
|
|
|
// enable angle cull for closed doors
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[component], CVehicleModelInfo::ClearAtomicFlagCB, (void*)ATOMIC_FLAG_NOCULL);
|
|
|
|
|
wasClosed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Doors[door].Open(openRatio);
|
|
|
|
|
|
|
|
|
|
if(wasClosed && Doors[door].RetAngleWhenClosed() != Doors[door].m_fAngle){
|
|
|
|
|
// door opened
|
|
|
|
|
HideAllComps();
|
|
|
|
|
// turn off angle cull for swinging door
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[component], CVehicleModelInfo::SetAtomicFlagCB, (void*)ATOMIC_FLAG_NOCULL);
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_DOOR_OPEN_BONNET + door, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!wasClosed && openRatio == 0.0f){
|
|
|
|
|
// door closed
|
|
|
|
|
if(Damage.GetDoorStatus(door) == DOOR_STATUS_SWINGING)
|
|
|
|
|
Damage.SetDoorStatus(door, DOOR_STATUS_OK); // huh?
|
|
|
|
|
ShowAllComps();
|
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_DOOR_CLOSE_BONNET + door, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axes[Doors[door].m_nAxis] = Doors[door].m_fAngle;
|
|
|
|
|
mat.SetRotate(axes[0], axes[1], axes[2]);
|
|
|
|
|
mat.Translate(pos);
|
2019-07-08 06:46:42 +00:00
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
inline void ProcessDoorOpenAnimation(CAutomobile *car, uint32 component, eDoors door, float time, float start, float end)
|
|
|
|
|
{
|
|
|
|
|
if(time > start && time < end){
|
|
|
|
|
float ratio = (time - start)/(end - start);
|
|
|
|
|
if(car->Doors[door].GetAngleOpenRatio() < ratio)
|
|
|
|
|
car->OpenDoor(component, door, ratio);
|
|
|
|
|
}else if(time > end){
|
|
|
|
|
car->OpenDoor(component, door, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void ProcessDoorCloseAnimation(CAutomobile *car, uint32 component, eDoors door, float time, float start, float end)
|
|
|
|
|
{
|
|
|
|
|
if(time > start && time < end){
|
|
|
|
|
float ratio = 1.0f - (time - start)/(end - start);
|
|
|
|
|
if(car->Doors[door].GetAngleOpenRatio() > ratio)
|
|
|
|
|
car->OpenDoor(component, door, ratio);
|
|
|
|
|
}else if(time > end){
|
|
|
|
|
car->OpenDoor(component, door, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void ProcessDoorOpenCloseAnimation(CAutomobile *car, uint32 component, eDoors door, float time, float start, float mid, float end)
|
|
|
|
|
{
|
|
|
|
|
if(time > start && time < mid){
|
|
|
|
|
// open
|
|
|
|
|
float ratio = (time - start)/(mid - start);
|
|
|
|
|
if(car->Doors[door].GetAngleOpenRatio() < ratio)
|
|
|
|
|
car->OpenDoor(component, door, ratio);
|
|
|
|
|
}else if(time > mid && time < end){
|
|
|
|
|
// close
|
|
|
|
|
float ratio = 1.0f - (time - mid)/(end - mid);
|
|
|
|
|
if(car->Doors[door].GetAngleOpenRatio() > ratio)
|
|
|
|
|
car->OpenDoor(component, door, ratio);
|
|
|
|
|
}else if(time > end){
|
|
|
|
|
car->OpenDoor(component, door, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-27 20:32:33 +00:00
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::ProcessOpenDoor(uint32 component, uint32 anim, float time)
|
|
|
|
|
{
|
|
|
|
|
eDoors door;
|
|
|
|
|
|
|
|
|
|
switch(component){
|
|
|
|
|
case CAR_DOOR_RF: door = DOOR_FRONT_RIGHT; break;
|
|
|
|
|
case CAR_DOOR_RR: door = DOOR_REAR_RIGHT; break;
|
|
|
|
|
case CAR_DOOR_LF: door = DOOR_FRONT_LEFT; break;
|
|
|
|
|
case CAR_DOOR_LR: door = DOOR_REAR_LEFT; break;
|
|
|
|
|
default: assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(IsDoorMissing(door))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch(anim){
|
|
|
|
|
case ANIM_CAR_QJACK:
|
|
|
|
|
case ANIM_CAR_OPEN_LHS:
|
|
|
|
|
case ANIM_CAR_OPEN_RHS:
|
2020-05-27 20:32:33 +00:00
|
|
|
|
ProcessDoorOpenAnimation(this, component, door, time, 0.41f, 0.89f);
|
2019-07-09 07:57:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case ANIM_CAR_CLOSEDOOR_LHS:
|
|
|
|
|
case ANIM_CAR_CLOSEDOOR_LOW_LHS:
|
|
|
|
|
case ANIM_CAR_CLOSEDOOR_RHS:
|
|
|
|
|
case ANIM_CAR_CLOSEDOOR_LOW_RHS:
|
2020-05-27 20:32:33 +00:00
|
|
|
|
ProcessDoorCloseAnimation(this, component, door, time, 0.2f, 0.45f);
|
2019-07-09 07:57:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case ANIM_CAR_ROLLDOOR:
|
|
|
|
|
case ANIM_CAR_ROLLDOOR_LOW:
|
|
|
|
|
ProcessDoorOpenCloseAnimation(this, component, door, time, 0.1f, 0.6f, 0.95f);
|
|
|
|
|
break;
|
|
|
|
|
case ANIM_CAR_GETOUT_LHS:
|
|
|
|
|
case ANIM_CAR_GETOUT_LOW_LHS:
|
|
|
|
|
case ANIM_CAR_GETOUT_RHS:
|
|
|
|
|
case ANIM_CAR_GETOUT_LOW_RHS:
|
|
|
|
|
ProcessDoorOpenAnimation(this, component, door, time, 0.06f, 0.43f);
|
|
|
|
|
break;
|
|
|
|
|
case ANIM_CAR_CLOSE_LHS:
|
|
|
|
|
case ANIM_CAR_CLOSE_RHS:
|
|
|
|
|
ProcessDoorCloseAnimation(this, component, door, time, 0.1f, 0.23f);
|
|
|
|
|
break;
|
|
|
|
|
case ANIM_CAR_PULLOUT_RHS:
|
|
|
|
|
case ANIM_CAR_PULLOUT_LOW_RHS:
|
|
|
|
|
OpenDoor(component, door, 1.0f);
|
2020-10-18 13:26:20 +00:00
|
|
|
|
break;
|
2019-07-09 07:57:44 +00:00
|
|
|
|
case ANIM_COACH_OPEN_L:
|
|
|
|
|
case ANIM_COACH_OPEN_R:
|
|
|
|
|
ProcessDoorOpenAnimation(this, component, door, time, 0.66f, 0.8f);
|
|
|
|
|
break;
|
|
|
|
|
case ANIM_COACH_OUT_L:
|
|
|
|
|
ProcessDoorOpenAnimation(this, component, door, time, 0.0f, 0.3f);
|
|
|
|
|
break;
|
|
|
|
|
case ANIM_VAN_OPEN_L:
|
|
|
|
|
case ANIM_VAN_OPEN:
|
|
|
|
|
ProcessDoorOpenAnimation(this, component, door, time, 0.37f, 0.55f);
|
|
|
|
|
break;
|
|
|
|
|
case ANIM_VAN_CLOSE_L:
|
|
|
|
|
case ANIM_VAN_CLOSE:
|
|
|
|
|
ProcessDoorCloseAnimation(this, component, door, time, 0.5f, 0.8f);
|
|
|
|
|
break;
|
|
|
|
|
case ANIM_VAN_GETOUT_L:
|
|
|
|
|
case ANIM_VAN_GETOUT:
|
|
|
|
|
ProcessDoorOpenAnimation(this, component, door, time, 0.5f, 0.6f);
|
|
|
|
|
break;
|
2020-05-20 17:10:05 +00:00
|
|
|
|
case NUM_STD_ANIMS:
|
2019-07-09 07:57:44 +00:00
|
|
|
|
OpenDoor(component, door, time);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsDoorReady(eDoors door)
|
|
|
|
|
{
|
|
|
|
|
if(Doors[door].IsClosed() || IsDoorMissing(door))
|
|
|
|
|
return true;
|
|
|
|
|
int doorflag = 0;
|
|
|
|
|
switch(door){
|
2019-09-06 22:27:07 +00:00
|
|
|
|
case DOOR_FRONT_LEFT: doorflag = CAR_DOOR_FLAG_LF; break;
|
|
|
|
|
case DOOR_FRONT_RIGHT: doorflag = CAR_DOOR_FLAG_RF; break;
|
|
|
|
|
case DOOR_REAR_LEFT: doorflag = CAR_DOOR_FLAG_LR; break;
|
|
|
|
|
case DOOR_REAR_RIGHT: doorflag = CAR_DOOR_FLAG_RR; break;
|
2020-05-11 23:24:57 +00:00
|
|
|
|
default: break;
|
2019-07-08 06:46:42 +00:00
|
|
|
|
}
|
|
|
|
|
return (doorflag & m_nGettingInFlags) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsDoorFullyOpen(eDoors door)
|
|
|
|
|
{
|
|
|
|
|
return Doors[door].IsFullyOpen() || IsDoorMissing(door);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsDoorClosed(eDoors door)
|
|
|
|
|
{
|
|
|
|
|
return !!Doors[door].IsClosed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsDoorMissing(eDoors door)
|
|
|
|
|
{
|
|
|
|
|
return Damage.GetDoorStatus(door) == DOOR_STATUS_MISSING;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsDoorReady(uint32 door)
|
|
|
|
|
{
|
|
|
|
|
switch(door){
|
|
|
|
|
case CAR_DOOR_RF: return IsDoorReady(DOOR_FRONT_RIGHT);
|
|
|
|
|
case CAR_DOOR_RR: return IsDoorReady(DOOR_REAR_RIGHT);
|
|
|
|
|
case CAR_DOOR_LF: return IsDoorReady(DOOR_FRONT_LEFT);
|
|
|
|
|
case CAR_DOOR_LR: return IsDoorReady(DOOR_REAR_LEFT);
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsDoorMissing(uint32 door)
|
|
|
|
|
{
|
|
|
|
|
switch(door){
|
|
|
|
|
case CAR_DOOR_RF: return IsDoorMissing(DOOR_FRONT_RIGHT);
|
|
|
|
|
case CAR_DOOR_RR: return IsDoorMissing(DOOR_REAR_RIGHT);
|
|
|
|
|
case CAR_DOOR_LF: return IsDoorMissing(DOOR_FRONT_LEFT);
|
|
|
|
|
case CAR_DOOR_LR: return IsDoorMissing(DOOR_REAR_LEFT);
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::IsOpenTopCar(void)
|
|
|
|
|
{
|
|
|
|
|
return GetModelIndex() == MI_STINGER ||
|
|
|
|
|
// component 0 is assumed to be a roof
|
|
|
|
|
GetModelIndex() == MI_COMET && m_aExtras[0] != 0 && m_aExtras[1] != 0 ||
|
|
|
|
|
GetModelIndex() == MI_STALLION && m_aExtras[0] != 0 && m_aExtras[1] != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 06:46:42 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::RemoveRefsToVehicle(CEntity *ent)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
if(m_aGroundPhysical[i] == ent)
|
|
|
|
|
m_aGroundPhysical[i] = nil;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 16:50:35 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::BlowUpCar(CEntity *culprit)
|
|
|
|
|
{
|
|
|
|
|
RpAtomic *atomic;
|
|
|
|
|
|
|
|
|
|
if(!bCanBeDamaged)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(culprit == FindPlayerPed() || culprit == FindPlayerVehicle()){
|
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_nHavocLevel += 20;
|
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_fMediaAttention += 10.0f;
|
|
|
|
|
CStats::PropertyDestroyed += CGeneral::GetRandomNumber()%6000 + 4000;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 16:50:35 +00:00
|
|
|
|
// explosion pushes vehicle up
|
|
|
|
|
m_vecMoveSpeed.z += 0.13f;
|
2020-04-30 13:45:45 +00:00
|
|
|
|
SetStatus(STATUS_WRECKED);
|
2019-07-09 16:50:35 +00:00
|
|
|
|
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);
|
2019-07-17 13:18:33 +00:00
|
|
|
|
atomic = nil;
|
2019-07-09 16:50:35 +00:00
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[CAR_WHEEL_LF], GetCurrentAtomicObjectCB, &atomic);
|
|
|
|
|
if(atomic)
|
|
|
|
|
RpAtomicSetFlags(atomic, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_fHealth = 0.0f;
|
|
|
|
|
m_nBombTimer = 0;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
m_bombType = CARBOMB_NONE;
|
2019-07-09 16:50:35 +00:00
|
|
|
|
|
|
|
|
|
TheCamera.CamShake(0.7f, GetPosition().x, GetPosition().y, GetPosition().z);
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
KillPedsInVehicle();
|
2019-07-09 16:50:35 +00:00
|
|
|
|
|
|
|
|
|
bEngineOn = false;
|
|
|
|
|
bLightsOn = false;
|
|
|
|
|
m_bSirenOrAlarm = false;
|
|
|
|
|
bTaxiLight = false;
|
|
|
|
|
if(bIsAmbulanceOnDuty){
|
|
|
|
|
bIsAmbulanceOnDuty = false;
|
|
|
|
|
CCarCtrl::NumAmbulancesOnDuty--;
|
|
|
|
|
}
|
|
|
|
|
if(bIsFireTruckOnDuty){
|
|
|
|
|
bIsFireTruckOnDuty = false;
|
|
|
|
|
CCarCtrl::NumFiretrucksOnDuty--;
|
|
|
|
|
}
|
|
|
|
|
ChangeLawEnforcerState(false);
|
|
|
|
|
|
2020-04-12 22:02:11 +00:00
|
|
|
|
gFireManager.StartFire(this, culprit, 0.8f, true);
|
2019-07-09 16:50:35 +00:00
|
|
|
|
CDarkel::RegisterCarBlownUpByPlayer(this);
|
|
|
|
|
if(GetModelIndex() == MI_RCBANDIT)
|
2019-07-25 14:33:37 +00:00
|
|
|
|
CExplosion::AddExplosion(this, culprit, EXPLOSION_CAR_QUICK, GetPosition(), 0);
|
2019-07-09 16:50:35 +00:00
|
|
|
|
else
|
2019-07-25 14:33:37 +00:00
|
|
|
|
CExplosion::AddExplosion(this, culprit, EXPLOSION_CAR, GetPosition(), 0);
|
2019-07-09 16:50:35 +00:00
|
|
|
|
}
|
2019-07-08 15:07:34 +00:00
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::SetUpWheelColModel(CColModel *colModel)
|
|
|
|
|
{
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
|
|
|
|
|
CColModel *vehColModel = mi->GetColModel();
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI ||
|
|
|
|
|
GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE)
|
|
|
|
|
return false;
|
|
|
|
|
|
2019-07-08 15:07:34 +00:00
|
|
|
|
colModel->boundingSphere = vehColModel->boundingSphere;
|
|
|
|
|
colModel->boundingBox = vehColModel->boundingBox;
|
|
|
|
|
|
|
|
|
|
CMatrix mat;
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF]));
|
2020-11-10 21:08:32 +00:00
|
|
|
|
colModel->spheres[0].Set(mi->m_wheelScale / 2, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_LF);
|
2019-07-08 15:07:34 +00:00
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LB]));
|
2020-11-10 21:08:32 +00:00
|
|
|
|
colModel->spheres[1].Set(mi->m_wheelScale / 2, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_LR);
|
2019-07-08 15:07:34 +00:00
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF]));
|
2020-11-10 21:08:32 +00:00
|
|
|
|
colModel->spheres[2].Set(mi->m_wheelScale / 2, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_RF);
|
2019-07-08 15:07:34 +00:00
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RB]));
|
2020-11-10 21:08:32 +00:00
|
|
|
|
colModel->spheres[3].Set(mi->m_wheelScale / 2, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_RR);
|
2019-07-08 15:07:34 +00:00
|
|
|
|
|
|
|
|
|
if(m_aCarNodes[CAR_WHEEL_LM] != nil && m_aCarNodes[CAR_WHEEL_RM] != nil){
|
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LM]));
|
2020-11-10 21:08:32 +00:00
|
|
|
|
colModel->spheres[4].Set(mi->m_wheelScale / 2, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_LR);
|
2019-07-08 15:07:34 +00:00
|
|
|
|
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RM]));
|
2020-11-10 21:08:32 +00:00
|
|
|
|
colModel->spheres[5].Set(mi->m_wheelScale / 2, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_RR);
|
2019-07-08 15:07:34 +00:00
|
|
|
|
colModel->numSpheres = 6;
|
|
|
|
|
}else
|
|
|
|
|
colModel->numSpheres = 4;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
void
|
2020-05-24 13:14:27 +00:00
|
|
|
|
CAutomobile::BurstTyre(uint8 wheel, bool applyForces)
|
2019-07-08 19:37:47 +00:00
|
|
|
|
{
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(GetModelIndex() == MI_RHINO || bTyresDontBurst)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
switch(wheel){
|
|
|
|
|
case CAR_PIECE_WHEEL_LF: wheel = VEHWHEEL_FRONT_LEFT; break;
|
|
|
|
|
case CAR_PIECE_WHEEL_LR: wheel = VEHWHEEL_REAR_LEFT; break;
|
|
|
|
|
case CAR_PIECE_WHEEL_RF: wheel = VEHWHEEL_FRONT_RIGHT; break;
|
|
|
|
|
case CAR_PIECE_WHEEL_RR: wheel = VEHWHEEL_REAR_RIGHT; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int status = Damage.GetWheelStatus(wheel);
|
|
|
|
|
if(status == WHEEL_STATUS_OK){
|
|
|
|
|
Damage.SetWheelStatus(wheel, WHEEL_STATUS_BURST);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
CStats::TyresPopped++;
|
2020-06-03 13:16:31 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_TYRE_POP, 0.0f);
|
2019-07-08 19:37:47 +00:00
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() == STATUS_SIMPLE){
|
|
|
|
|
SetStatus(STATUS_PHYSICS);
|
2019-07-08 19:37:47 +00:00
|
|
|
|
CCarCtrl::SwitchVehicleToRealPhysics(this);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-24 13:14:27 +00:00
|
|
|
|
if(applyForces){
|
2020-06-02 21:35:20 +00:00
|
|
|
|
ApplyMoveForce(GetRight() * m_fMass * CGeneral::GetRandomNumberInRange(-0.03f, 0.03f));
|
|
|
|
|
ApplyTurnForce(GetRight() * m_fTurnMass * CGeneral::GetRandomNumberInRange(-0.03f, 0.03f), GetForward());
|
2020-05-24 13:14:27 +00:00
|
|
|
|
}
|
2019-07-08 19:37:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-26 16:48:14 +00:00
|
|
|
|
bool
|
2019-07-26 18:11:11 +00:00
|
|
|
|
CAutomobile::IsRoomForPedToLeaveCar(uint32 component, CVector *doorOffset)
|
2019-07-26 16:48:14 +00:00
|
|
|
|
{
|
|
|
|
|
CColPoint colpoint;
|
|
|
|
|
CEntity *ent;
|
|
|
|
|
colpoint.point = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
|
|
|
|
|
|
|
|
|
|
CVector seatPos;
|
|
|
|
|
switch(component){
|
|
|
|
|
case CAR_DOOR_RF:
|
2020-06-02 21:35:20 +00:00
|
|
|
|
seatPos = mi->GetFrontSeatPosn();
|
2019-07-26 16:48:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case CAR_DOOR_LF:
|
2020-06-02 21:35:20 +00:00
|
|
|
|
seatPos = mi->GetFrontSeatPosn();
|
2019-07-26 16:48:14 +00:00
|
|
|
|
seatPos.x = -seatPos.x;
|
|
|
|
|
break;
|
|
|
|
|
case CAR_DOOR_RR:
|
|
|
|
|
seatPos = mi->m_positions[CAR_POS_BACKSEAT];
|
|
|
|
|
break;
|
|
|
|
|
case CAR_DOOR_LR:
|
|
|
|
|
seatPos = mi->m_positions[CAR_POS_BACKSEAT];
|
|
|
|
|
seatPos.x = -seatPos.x;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
seatPos = GetMatrix() * seatPos;
|
|
|
|
|
|
|
|
|
|
CVector doorPos = CPed::GetPositionToOpenCarDoor(this, component);
|
2019-07-26 18:11:11 +00:00
|
|
|
|
if(doorOffset){
|
|
|
|
|
CVector off = *doorOffset;
|
2019-07-26 16:48:14 +00:00
|
|
|
|
if(component == CAR_DOOR_RF || component == CAR_DOOR_RR)
|
2019-07-26 18:11:11 +00:00
|
|
|
|
off.x = -off.x;
|
|
|
|
|
doorPos += Multiply3x3(GetMatrix(), off);
|
2019-07-26 16:48:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(GetUp().z < 0.0f){
|
|
|
|
|
seatPos.z += 0.5f;
|
|
|
|
|
doorPos.z += 0.5f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CVector dist = doorPos - seatPos;
|
2020-02-03 18:03:48 +00:00
|
|
|
|
|
2020-06-02 21:35:20 +00:00
|
|
|
|
// Removing that makes thiProcessEntityCollisions func. return false for van doors.
|
2020-02-03 18:03:48 +00:00
|
|
|
|
doorPos.z += 0.5f;
|
2019-07-26 16:48:14 +00:00
|
|
|
|
float length = dist.Magnitude();
|
|
|
|
|
CVector pedPos = seatPos + dist*((length+0.6f)/length);
|
|
|
|
|
|
|
|
|
|
if(!CWorld::GetIsLineOfSightClear(seatPos, pedPos, true, false, false, true, false, false))
|
|
|
|
|
return false;
|
|
|
|
|
if(CWorld::TestSphereAgainstWorld(doorPos, 0.6f, this, true, true, false, true, false, false))
|
|
|
|
|
return false;
|
|
|
|
|
if(CWorld::ProcessVerticalLine(doorPos, 1000.0f, colpoint, ent, true, false, false, true, false, false, nil))
|
|
|
|
|
if(colpoint.point.z > doorPos.z && colpoint.point.z < doorPos.z + 0.6f)
|
|
|
|
|
return false;
|
|
|
|
|
float upperZ = colpoint.point.z;
|
|
|
|
|
if(!CWorld::ProcessVerticalLine(doorPos, -1000.0f, colpoint, ent, true, false, false, true, false, false, nil))
|
|
|
|
|
return false;
|
|
|
|
|
if(upperZ != 0.0f && upperZ < colpoint.point.z)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
|
|
|
|
float
|
|
|
|
|
CAutomobile::GetHeightAboveRoad(void)
|
|
|
|
|
{
|
|
|
|
|
return m_fHeightAboveRoad;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::PlayCarHorn(void)
|
|
|
|
|
{
|
|
|
|
|
int r;
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
if (IsAlarmOn() || m_nCarHornTimer != 0)
|
2019-07-08 19:37:47 +00:00
|
|
|
|
return;
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2020-05-16 11:01:32 +00:00
|
|
|
|
if (m_nCarHornDelay) {
|
|
|
|
|
m_nCarHornDelay--;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_nCarHornDelay = (CGeneral::GetRandomNumber() & 0x7F) + 150;
|
|
|
|
|
r = m_nCarHornDelay & 7;
|
2019-07-08 19:37:47 +00:00
|
|
|
|
if(r < 2){
|
|
|
|
|
m_nCarHornTimer = 45;
|
|
|
|
|
}else if(r < 4){
|
|
|
|
|
if(pDriver)
|
2020-08-20 11:20:48 +00:00
|
|
|
|
pDriver->Say(SOUND_PED_ANNOYED_DRIVER);
|
2019-07-08 19:37:47 +00:00
|
|
|
|
m_nCarHornTimer = 45;
|
|
|
|
|
}else{
|
|
|
|
|
if(pDriver)
|
2020-08-20 11:20:48 +00:00
|
|
|
|
pDriver->Say(SOUND_PED_ANNOYED_DRIVER);
|
2019-07-08 19:37:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::PlayHornIfNecessary(void)
|
|
|
|
|
{
|
2019-08-11 17:11:54 +00:00
|
|
|
|
if(AutoPilot.m_bSlowedDownBecauseOfPeds ||
|
2019-08-25 13:47:22 +00:00
|
|
|
|
AutoPilot.m_bSlowedDownBecauseOfCars)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
if(!HasCarStoppedBecauseOfLight())
|
|
|
|
|
PlayCarHorn();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::ResetSuspension(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
2019-07-17 21:58:06 +00:00
|
|
|
|
m_aWheelTimer[i] = 0.0f;
|
2019-07-08 19:37:47 +00:00
|
|
|
|
m_aWheelRotation[i] = 0.0f;
|
2019-07-28 11:14:08 +00:00
|
|
|
|
m_aWheelState[i] = WHEEL_STATE_NORMAL;
|
2019-07-08 19:37:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetupSuspensionLines(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
CVector posn;
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
|
|
|
|
|
CColModel *colModel = mi->GetColModel();
|
|
|
|
|
|
|
|
|
|
// Each suspension line starts at the uppermost wheel position
|
|
|
|
|
// and extends down to the lowermost point on the tyre
|
|
|
|
|
for(i = 0; i < 4; i++){
|
|
|
|
|
mi->GetWheelPosn(i, posn);
|
|
|
|
|
m_aWheelPosition[i] = posn.z;
|
|
|
|
|
|
|
|
|
|
// uppermost wheel position
|
2019-07-17 11:19:20 +00:00
|
|
|
|
posn.z += pHandling->fSuspensionUpperLimit;
|
2019-07-09 07:57:44 +00:00
|
|
|
|
colModel->lines[i].p0 = posn;
|
|
|
|
|
|
|
|
|
|
// lowermost wheel position
|
2019-07-17 11:19:20 +00:00
|
|
|
|
posn.z += pHandling->fSuspensionLowerLimit - pHandling->fSuspensionUpperLimit;
|
2019-07-09 07:57:44 +00:00
|
|
|
|
// lowest point on tyre
|
|
|
|
|
posn.z -= mi->m_wheelScale*0.5f;
|
|
|
|
|
colModel->lines[i].p1 = posn;
|
|
|
|
|
|
|
|
|
|
// this is length of the spring at rest
|
2019-07-17 11:19:20 +00:00
|
|
|
|
m_aSuspensionSpringLength[i] = pHandling->fSuspensionUpperLimit - pHandling->fSuspensionLowerLimit;
|
2019-07-09 07:57:44 +00:00
|
|
|
|
m_aSuspensionLineLength[i] = colModel->lines[i].p0.z - colModel->lines[i].p1.z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compress spring somewhat to get normal height on road
|
2020-05-27 20:32:33 +00:00
|
|
|
|
m_fHeightAboveRoad = m_aSuspensionSpringLength[0]*(1.0f - 1.0f/(4.0f*pHandling->fSuspensionForceLevel))
|
|
|
|
|
- colModel->lines[0].p0.z + mi->m_wheelScale*0.5f;
|
2019-07-09 07:57:44 +00:00
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
|
m_aWheelPosition[i] = mi->m_wheelScale*0.5f - m_fHeightAboveRoad;
|
|
|
|
|
|
|
|
|
|
// adjust col model to include suspension lines
|
|
|
|
|
if(colModel->boundingBox.min.z > colModel->lines[0].p1.z)
|
|
|
|
|
colModel->boundingBox.min.z = colModel->lines[0].p1.z;
|
2020-04-19 16:34:08 +00:00
|
|
|
|
float radius = Max(colModel->boundingBox.min.Magnitude(), colModel->boundingBox.max.Magnitude());
|
2019-07-09 07:57:44 +00:00
|
|
|
|
if(colModel->boundingSphere.radius < radius)
|
|
|
|
|
colModel->boundingSphere.radius = radius;
|
|
|
|
|
|
|
|
|
|
if(GetModelIndex() == MI_RCBANDIT){
|
|
|
|
|
colModel->boundingSphere.radius = 2.0f;
|
|
|
|
|
for(i = 0; i < colModel->numSpheres; i++)
|
|
|
|
|
colModel->spheres[i].radius = 0.3f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 16:50:35 +00:00
|
|
|
|
// called on police cars
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::ScanForCrimes(void)
|
|
|
|
|
{
|
|
|
|
|
if(FindPlayerVehicle() && FindPlayerVehicle()->IsCar())
|
2019-07-18 13:41:09 +00:00
|
|
|
|
if(FindPlayerVehicle()->IsAlarmOn())
|
2019-07-09 16:50:35 +00:00
|
|
|
|
// 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;
|
|
|
|
|
|
2020-05-17 18:43:11 +00:00
|
|
|
|
if(m_vecMoveSpeed.Magnitude() > 0.1f && bTankDetonateCars)
|
2019-07-09 16:50:35 +00:00
|
|
|
|
for(i = 0; i < m_nCollisionRecords; i++)
|
|
|
|
|
if(m_aCollisionRecords[i] &&
|
|
|
|
|
m_aCollisionRecords[i]->IsVehicle() &&
|
|
|
|
|
m_aCollisionRecords[i]->GetModelIndex() != MI_RHINO &&
|
2020-05-27 20:32:33 +00:00
|
|
|
|
!m_aCollisionRecords[i]->bRenderScorched){
|
|
|
|
|
if(this == FindPlayerVehicle())
|
|
|
|
|
CEventList::RegisterEvent(EVENT_EXPLOSION, EVENT_ENTITY_VEHICLE, this, FindPlayerPed(), 2000);
|
2019-07-09 16:50:35 +00:00
|
|
|
|
((CVehicle*)m_aCollisionRecords[i])->BlowUpCar(this);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
}
|
2019-07-09 16:50:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
bool
|
|
|
|
|
CAutomobile::HasCarStoppedBecauseOfLight(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2020-04-30 13:45:45 +00:00
|
|
|
|
if(GetStatus() != STATUS_SIMPLE && GetStatus() != STATUS_PHYSICS)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
if(AutoPilot.m_nCurrentRouteNode && AutoPilot.m_nNextRouteNode){
|
|
|
|
|
CPathNode *curnode = &ThePaths.m_pathNodes[AutoPilot.m_nCurrentRouteNode];
|
2019-07-09 07:57:44 +00:00
|
|
|
|
for(i = 0; i < curnode->numLinks; i++)
|
2020-05-03 13:57:57 +00:00
|
|
|
|
if(ThePaths.ConnectedNode(curnode->firstLink + i) == AutoPilot.m_nNextRouteNode)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
break;
|
|
|
|
|
if(i < curnode->numLinks &&
|
2020-04-12 22:02:11 +00:00
|
|
|
|
ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[curnode->firstLink + i]].trafficLightType & 3)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-16 17:48:50 +00:00
|
|
|
|
if(AutoPilot.m_nCurrentRouteNode && AutoPilot.m_nPrevRouteNode){
|
|
|
|
|
CPathNode *curnode = &ThePaths.m_pathNodes[AutoPilot.m_nCurrentRouteNode];
|
2019-07-09 07:57:44 +00:00
|
|
|
|
for(i = 0; i < curnode->numLinks; i++)
|
2020-05-03 13:57:57 +00:00
|
|
|
|
if(ThePaths.ConnectedNode(curnode->firstLink + i) == AutoPilot.m_nPrevRouteNode)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
break;
|
|
|
|
|
if(i < curnode->numLinks &&
|
2020-04-12 22:02:11 +00:00
|
|
|
|
ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[curnode->firstLink + i]].trafficLightType & 3)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-19 23:18:37 +00:00
|
|
|
|
// --MIAMI: Done
|
|
|
|
|
void
|
|
|
|
|
CPed::DeadPedMakesTyresBloody(void)
|
|
|
|
|
{
|
|
|
|
|
int minX = CWorld::GetSectorIndexX(GetPosition().x - 2.0f);
|
|
|
|
|
if (minX < 0) minX = 0;
|
|
|
|
|
int minY = CWorld::GetSectorIndexY(GetPosition().y - 2.0f);
|
|
|
|
|
if (minY < 0) minY = 0;
|
|
|
|
|
int maxX = CWorld::GetSectorIndexX(GetPosition().x + 2.0f);
|
|
|
|
|
if (maxX > NUMSECTORS_X-1) maxX = NUMSECTORS_X-1;
|
|
|
|
|
int maxY = CWorld::GetSectorIndexY(GetPosition().y + 2.0f);
|
|
|
|
|
if (maxY > NUMSECTORS_Y-1) maxY = NUMSECTORS_Y-1;
|
|
|
|
|
|
|
|
|
|
CWorld::AdvanceCurrentScanCode();
|
|
|
|
|
|
|
|
|
|
for (int curY = minY; curY <= maxY; curY++) {
|
|
|
|
|
for (int curX = minX; curX <= maxX; curX++) {
|
|
|
|
|
CSector *sector = CWorld::GetSector(curX, curY);
|
|
|
|
|
MakeTyresMuddySectorList(sector->m_lists[ENTITYLIST_VEHICLES]);
|
|
|
|
|
MakeTyresMuddySectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --MIAMI: Done
|
|
|
|
|
void
|
|
|
|
|
CPed::MakeTyresMuddySectorList(CPtrList &list)
|
|
|
|
|
{
|
|
|
|
|
CAutomobile *car = nil;
|
|
|
|
|
CBike *bike = nil;
|
|
|
|
|
for (CPtrNode *node = list.first; node; node = node->next) {
|
|
|
|
|
CVehicle *veh = (CVehicle*)node->item;
|
|
|
|
|
if (veh->m_scanCode != CWorld::GetCurrentScanCode()) {
|
|
|
|
|
veh->m_scanCode = CWorld::GetCurrentScanCode();
|
|
|
|
|
|
|
|
|
|
if (Abs(GetPosition().x - veh->GetPosition().x) < 10.0f && Abs(GetPosition().y - veh->GetPosition().y) < 10.0f) {
|
|
|
|
|
if (veh->IsCar()) {
|
|
|
|
|
bike = nil;
|
|
|
|
|
car = (CAutomobile*)veh;
|
|
|
|
|
} else if (veh->IsBike()) {
|
|
|
|
|
bike = (CBike*)veh;
|
|
|
|
|
car = nil;
|
|
|
|
|
}
|
|
|
|
|
if (veh->m_vecMoveSpeed.MagnitudeSqr2D() > 0.05f) {
|
|
|
|
|
if (car) {
|
|
|
|
|
for (int wheel = 0; wheel < 4; wheel++) {
|
|
|
|
|
if (!car->m_aWheelSkidmarkBloody[wheel] && car->m_aSuspensionSpringRatio[wheel] < 1.0f) {
|
|
|
|
|
|
|
|
|
|
CColModel* vehCol = car->GetModelInfo()->GetColModel();
|
|
|
|
|
CVector approxWheelOffset;
|
|
|
|
|
switch (wheel) {
|
|
|
|
|
case 0:
|
|
|
|
|
approxWheelOffset = CVector(-vehCol->boundingBox.max.x, vehCol->boundingBox.max.y, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
approxWheelOffset = CVector(-vehCol->boundingBox.max.x, vehCol->boundingBox.min.y, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
approxWheelOffset = CVector(vehCol->boundingBox.max.x, vehCol->boundingBox.max.y, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
approxWheelOffset = CVector(vehCol->boundingBox.max.x, vehCol->boundingBox.min.y, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// I hope so
|
|
|
|
|
CVector wheelPos = car->GetMatrix() * approxWheelOffset;
|
|
|
|
|
if (Abs(wheelPos.z - GetPosition().z) < 2.0f) {
|
|
|
|
|
|
|
|
|
|
if ((wheelPos - GetPosition()).MagnitudeSqr2D() < 1.0f) {
|
|
|
|
|
if (CGame::nastyGame) {
|
|
|
|
|
car->m_aWheelSkidmarkBloody[wheel] = true;
|
|
|
|
|
DMAudio.PlayOneShot(car->m_audioEntityId, SOUND_SPLATTER, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
if (car->m_fMass > 500.f) {
|
|
|
|
|
car->ApplyMoveForce(CVector(0.0f, 0.0f, 50.0f * Min(1.0f, m_fMass * 0.001f)));
|
|
|
|
|
|
|
|
|
|
CVector vehAndWheelDist = wheelPos - car->GetPosition();
|
|
|
|
|
car->ApplyTurnForce(CVector(0.0f, 0.0f, 50.0f * Min(1.0f, m_fTurnMass * 0.0005f)), vehAndWheelDist);
|
|
|
|
|
if (car == FindPlayerVehicle()) {
|
|
|
|
|
CPad::GetPad(0)->StartShake(300, 70);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (bike) {
|
|
|
|
|
for (int wheel = 0; wheel < 2; wheel++) {
|
|
|
|
|
if (!bike->m_aWheelSkidmarkBloody[wheel] && bike->m_aSuspensionSpringRatio[wheel] < 1.0f) {
|
|
|
|
|
|
|
|
|
|
CColModel* vehCol = bike->GetModelInfo()->GetColModel();
|
|
|
|
|
CVector approxWheelOffset;
|
|
|
|
|
switch (wheel) {
|
|
|
|
|
case 0:
|
|
|
|
|
approxWheelOffset = CVector(0.0f, 0.8f * vehCol->boundingBox.max.y, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
approxWheelOffset = CVector(0.0f, 0.8f * vehCol->boundingBox.min.y, 0.0f);
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// I hope so
|
|
|
|
|
CVector wheelPos = bike->GetMatrix() * approxWheelOffset;
|
|
|
|
|
if (Abs(wheelPos.z - GetPosition().z) < 2.0f) {
|
|
|
|
|
|
|
|
|
|
if ((wheelPos - GetPosition()).MagnitudeSqr2D() < 1.0f) {
|
|
|
|
|
if (CGame::nastyGame) {
|
|
|
|
|
bike->m_aWheelSkidmarkBloody[wheel] = true;
|
|
|
|
|
DMAudio.PlayOneShot(bike->m_audioEntityId, SOUND_SPLATTER, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
if (bike->m_fMass > 100.0f) {
|
|
|
|
|
bike->ApplyMoveForce(CVector(0.0f, 0.0f, 10.0f));
|
|
|
|
|
|
|
|
|
|
CVector vehAndWheelDist = wheelPos - bike->GetPosition();
|
|
|
|
|
bike->ApplyTurnForce(CVector(0.0f, 0.0f, 10.0f), vehAndWheelDist);
|
|
|
|
|
|
|
|
|
|
if (bike == FindPlayerVehicle()) {
|
|
|
|
|
CPad::GetPad(0)->StartShake(300, 70);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetBusDoorTimer(uint32 timer, uint8 type)
|
|
|
|
|
{
|
|
|
|
|
if(timer < 1000)
|
|
|
|
|
timer = 1000;
|
|
|
|
|
if(type == 0)
|
|
|
|
|
// open and close
|
|
|
|
|
m_nBusDoorTimerStart = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
else
|
|
|
|
|
// only close
|
|
|
|
|
m_nBusDoorTimerStart = CTimer::GetTimeInMilliseconds() - 500;
|
|
|
|
|
m_nBusDoorTimerEnd = m_nBusDoorTimerStart + timer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::ProcessAutoBusDoors(void)
|
|
|
|
|
{
|
|
|
|
|
if(CTimer::GetTimeInMilliseconds() < m_nBusDoorTimerEnd){
|
|
|
|
|
if(m_nBusDoorTimerEnd != 0 && CTimer::GetTimeInMilliseconds() > m_nBusDoorTimerEnd-500){
|
|
|
|
|
// close door
|
2019-09-06 22:27:07 +00:00
|
|
|
|
if(!IsDoorMissing(DOOR_FRONT_LEFT) && (m_nGettingInFlags & CAR_DOOR_FLAG_LF) == 0){
|
2019-07-09 07:57:44 +00:00
|
|
|
|
if(IsDoorClosed(DOOR_FRONT_LEFT)){
|
|
|
|
|
m_nBusDoorTimerEnd = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
OpenDoor(CAR_DOOR_LF, DOOR_FRONT_LEFT, 0.0f);
|
|
|
|
|
}else{
|
|
|
|
|
OpenDoor(CAR_DOOR_LF, DOOR_FRONT_LEFT,
|
|
|
|
|
1.0f - (CTimer::GetTimeInMilliseconds() - (m_nBusDoorTimerEnd-500))/500.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 22:27:07 +00:00
|
|
|
|
if(!IsDoorMissing(DOOR_FRONT_RIGHT) && (m_nGettingInFlags & CAR_DOOR_FLAG_RF) == 0){
|
2019-07-09 07:57:44 +00:00
|
|
|
|
if(IsDoorClosed(DOOR_FRONT_RIGHT)){
|
|
|
|
|
m_nBusDoorTimerEnd = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
OpenDoor(CAR_DOOR_RF, DOOR_FRONT_RIGHT, 0.0f);
|
|
|
|
|
}else{
|
|
|
|
|
OpenDoor(CAR_DOOR_RF, DOOR_FRONT_RIGHT,
|
|
|
|
|
1.0f - (CTimer::GetTimeInMilliseconds() - (m_nBusDoorTimerEnd-500))/500.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
// ended
|
|
|
|
|
if(m_nBusDoorTimerStart){
|
2019-09-06 22:27:07 +00:00
|
|
|
|
if(!IsDoorMissing(DOOR_FRONT_LEFT) && (m_nGettingInFlags & CAR_DOOR_FLAG_LF) == 0)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
OpenDoor(CAR_DOOR_LF, DOOR_FRONT_LEFT, 0.0f);
|
2019-09-06 22:27:07 +00:00
|
|
|
|
if(!IsDoorMissing(DOOR_FRONT_RIGHT) && (m_nGettingInFlags & CAR_DOOR_FLAG_RF) == 0)
|
2019-07-09 07:57:44 +00:00
|
|
|
|
OpenDoor(CAR_DOOR_RF, DOOR_FRONT_RIGHT, 0.0f);
|
|
|
|
|
m_nBusDoorTimerStart = 0;
|
|
|
|
|
m_nBusDoorTimerEnd = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::ProcessSwingingDoor(int32 component, eDoors door)
|
|
|
|
|
{
|
|
|
|
|
if(Damage.GetDoorStatus(door) != DOOR_STATUS_SWINGING)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-06-17 18:24:59 +00:00
|
|
|
|
if (m_aCarNodes[component] == nil)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
CMatrix mat(RwFrameGetMatrix(m_aCarNodes[component]));
|
|
|
|
|
CVector pos = mat.GetPosition();
|
|
|
|
|
float axes[3] = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
|
|
|
|
|
Doors[door].Process(this);
|
|
|
|
|
axes[Doors[door].m_nAxis] = Doors[door].m_fAngle;
|
|
|
|
|
mat.SetRotate(axes[0], axes[1], axes[2]);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
2020-05-27 20:32:33 +00:00
|
|
|
|
|
|
|
|
|
// make wind rip off bonnet
|
|
|
|
|
if(door == DOOR_BONNET && Doors[door].m_nDoorState == DOORST_OPEN &&
|
|
|
|
|
DotProduct(m_vecMoveSpeed, GetForward()) > 0.4f){
|
|
|
|
|
#ifdef FIX_BUGS
|
|
|
|
|
CObject *comp = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_BONNET);
|
|
|
|
|
#else
|
|
|
|
|
CObject *comp = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_DOOR);
|
|
|
|
|
#endif
|
|
|
|
|
// make both doors invisible on car
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[CAR_BONNET], ATOMIC_FLAG_NONE);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING);
|
|
|
|
|
|
|
|
|
|
if(comp){
|
|
|
|
|
if(CGeneral::GetRandomNumber() & 1)
|
|
|
|
|
comp->m_vecMoveSpeed = 0.4f*m_vecMoveSpeed + 0.1f*GetRight() + 0.5f*GetUp();
|
|
|
|
|
else
|
|
|
|
|
comp->m_vecMoveSpeed = 0.4f*m_vecMoveSpeed - 0.1f*GetRight() + 0.5f*GetUp();
|
|
|
|
|
comp->ApplyTurnForce(10.0f*GetUp(), GetForward());
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-08 19:37:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::Fix(void)
|
|
|
|
|
{
|
|
|
|
|
int component;
|
|
|
|
|
|
|
|
|
|
Damage.ResetDamageStatus();
|
|
|
|
|
|
2019-07-17 11:19:20 +00:00
|
|
|
|
if(pHandling->Flags & HANDLING_NO_DOORS){
|
2019-07-08 19:37:47 +00:00
|
|
|
|
Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_MISSING);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_MISSING);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_REAR_LEFT, DOOR_STATUS_MISSING);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_REAR_RIGHT, DOOR_STATUS_MISSING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bIsDamaged = false;
|
|
|
|
|
RpClumpForAllAtomics((RpClump*)m_rwObject, CVehicleModelInfo::HideAllComponentsAtomicCB, (void*)ATOMIC_FLAG_DAM);
|
|
|
|
|
|
|
|
|
|
for(component = CAR_BUMP_FRONT; component < NUM_CAR_NODES; component++){
|
|
|
|
|
if(m_aCarNodes[component]){
|
|
|
|
|
CMatrix mat(RwFrameGetMatrix(m_aCarNodes[component]));
|
|
|
|
|
mat.SetTranslate(mat.GetPosition());
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-27 20:32:33 +00:00
|
|
|
|
|
|
|
|
|
for(component = 0; component < 4; component++)
|
|
|
|
|
Damage.SetWheelStatus(component, WHEEL_STATUS_OK);
|
|
|
|
|
|
|
|
|
|
if(GetModelIndex() == MI_HUNTER){
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LB]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RB]), 0);
|
|
|
|
|
}else if(IsRealHeli()){
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LF]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RF]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LB]), 0);
|
|
|
|
|
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RB]), 0);
|
|
|
|
|
}
|
2019-07-08 19:37:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetupDamageAfterLoad(void)
|
|
|
|
|
{
|
|
|
|
|
if(m_aCarNodes[CAR_BUMP_FRONT])
|
|
|
|
|
SetBumperDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT);
|
|
|
|
|
if(m_aCarNodes[CAR_BONNET])
|
|
|
|
|
SetDoorDamage(CAR_BONNET, DOOR_BONNET);
|
|
|
|
|
if(m_aCarNodes[CAR_BUMP_REAR])
|
|
|
|
|
SetBumperDamage(CAR_BUMP_REAR, VEHBUMPER_REAR);
|
|
|
|
|
if(m_aCarNodes[CAR_BOOT])
|
|
|
|
|
SetDoorDamage(CAR_BOOT, DOOR_BOOT);
|
|
|
|
|
if(m_aCarNodes[CAR_DOOR_LF])
|
|
|
|
|
SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT);
|
|
|
|
|
if(m_aCarNodes[CAR_DOOR_RF])
|
|
|
|
|
SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT);
|
|
|
|
|
if(m_aCarNodes[CAR_DOOR_LR])
|
|
|
|
|
SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT);
|
|
|
|
|
if(m_aCarNodes[CAR_DOOR_RR])
|
|
|
|
|
SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT);
|
|
|
|
|
if(m_aCarNodes[CAR_WING_LF])
|
|
|
|
|
SetPanelDamage(CAR_WING_LF, VEHPANEL_FRONT_LEFT);
|
|
|
|
|
if(m_aCarNodes[CAR_WING_RF])
|
|
|
|
|
SetPanelDamage(CAR_WING_RF, VEHPANEL_FRONT_RIGHT);
|
|
|
|
|
if(m_aCarNodes[CAR_WING_LR])
|
|
|
|
|
SetPanelDamage(CAR_WING_LR, VEHPANEL_REAR_LEFT);
|
|
|
|
|
if(m_aCarNodes[CAR_WING_RR])
|
|
|
|
|
SetPanelDamage(CAR_WING_RR, VEHPANEL_REAR_RIGHT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RwObject*
|
|
|
|
|
GetCurrentAtomicObjectCB(RwObject *object, void *data)
|
|
|
|
|
{
|
|
|
|
|
RpAtomic *atomic = (RpAtomic*)object;
|
|
|
|
|
assert(RwObjectGetType(object) == rpATOMIC);
|
|
|
|
|
if(RpAtomicGetFlags(atomic) & rpATOMICRENDER)
|
|
|
|
|
*(RpAtomic**)data = atomic;
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CObject*
|
|
|
|
|
CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
|
|
|
|
|
{
|
|
|
|
|
RpAtomic *atomic;
|
|
|
|
|
RwFrame *frame;
|
|
|
|
|
RwMatrix *matrix;
|
|
|
|
|
CObject *obj;
|
|
|
|
|
|
|
|
|
|
if(CObject::nNoTempObjects >= NUMTEMPOBJECTS)
|
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
|
|
atomic = nil;
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[component], GetCurrentAtomicObjectCB, &atomic);
|
|
|
|
|
if(atomic == nil)
|
|
|
|
|
return nil;
|
|
|
|
|
|
2019-11-04 23:04:26 +00:00
|
|
|
|
obj = new CObject();
|
2019-07-08 19:37:47 +00:00
|
|
|
|
if(obj == nil)
|
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
|
|
if(component == CAR_WINDSCREEN){
|
|
|
|
|
obj->SetModelIndexNoCreate(MI_CAR_BONNET);
|
|
|
|
|
}else switch(type){
|
|
|
|
|
case COMPGROUP_BUMPER:
|
|
|
|
|
obj->SetModelIndexNoCreate(MI_CAR_BUMPER);
|
|
|
|
|
break;
|
|
|
|
|
case COMPGROUP_WHEEL:
|
|
|
|
|
obj->SetModelIndexNoCreate(MI_CAR_WHEEL);
|
|
|
|
|
break;
|
|
|
|
|
case COMPGROUP_DOOR:
|
|
|
|
|
obj->SetModelIndexNoCreate(MI_CAR_DOOR);
|
|
|
|
|
obj->SetCenterOfMass(0.0f, -0.5f, 0.0f);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
obj->bDrawLast = true;
|
2019-07-08 19:37:47 +00:00
|
|
|
|
break;
|
|
|
|
|
case COMPGROUP_BONNET:
|
|
|
|
|
obj->SetModelIndexNoCreate(MI_CAR_BONNET);
|
|
|
|
|
obj->SetCenterOfMass(0.0f, 0.4f, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
case COMPGROUP_BOOT:
|
|
|
|
|
obj->SetModelIndexNoCreate(MI_CAR_BOOT);
|
|
|
|
|
obj->SetCenterOfMass(0.0f, -0.3f, 0.0f);
|
|
|
|
|
break;
|
|
|
|
|
case COMPGROUP_PANEL:
|
|
|
|
|
default:
|
|
|
|
|
obj->SetModelIndexNoCreate(MI_CAR_PANEL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// object needs base model
|
|
|
|
|
obj->RefModelInfo(GetModelIndex());
|
|
|
|
|
|
|
|
|
|
// create new atomic
|
|
|
|
|
matrix = RwFrameGetLTM(m_aCarNodes[component]);
|
|
|
|
|
frame = RwFrameCreate();
|
|
|
|
|
atomic = RpAtomicClone(atomic);
|
|
|
|
|
*RwFrameGetMatrix(frame) = *matrix;
|
|
|
|
|
RpAtomicSetFrame(atomic, frame);
|
|
|
|
|
CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
|
|
|
|
|
obj->AttachToRwObject((RwObject*)atomic);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
obj->bDontStream = true;
|
2019-07-08 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
// init object
|
|
|
|
|
obj->m_fMass = 10.0f;
|
|
|
|
|
obj->m_fTurnMass = 25.0f;
|
|
|
|
|
obj->m_fAirResistance = 0.97f;
|
|
|
|
|
obj->m_fElasticity = 0.1f;
|
|
|
|
|
obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f;
|
|
|
|
|
obj->ObjectCreatedBy = TEMP_OBJECT;
|
2020-10-18 13:40:06 +00:00
|
|
|
|
obj->SetIsStatic(false);
|
2019-07-08 19:37:47 +00:00
|
|
|
|
obj->bIsPickup = false;
|
|
|
|
|
obj->bUseVehicleColours = true;
|
|
|
|
|
obj->m_colour1 = m_currentColour1;
|
|
|
|
|
obj->m_colour2 = m_currentColour2;
|
|
|
|
|
|
|
|
|
|
// life time - the more objects the are, the shorter this one will live
|
|
|
|
|
CObject::nNoTempObjects++;
|
|
|
|
|
if(CObject::nNoTempObjects > 20)
|
|
|
|
|
obj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 20000/5.0f;
|
|
|
|
|
else if(CObject::nNoTempObjects > 10)
|
|
|
|
|
obj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 20000/2.0f;
|
|
|
|
|
else
|
|
|
|
|
obj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 20000;
|
|
|
|
|
|
|
|
|
|
obj->m_vecMoveSpeed = m_vecMoveSpeed;
|
|
|
|
|
if(obj->m_vecMoveSpeed.z > 0.0f){
|
|
|
|
|
obj->m_vecMoveSpeed.z *= 1.5f;
|
|
|
|
|
}else if(GetUp().z > 0.0f &&
|
|
|
|
|
(component == COMPGROUP_BONNET || component == COMPGROUP_BOOT || component == CAR_WINDSCREEN)){
|
|
|
|
|
obj->m_vecMoveSpeed.z *= -1.5f;
|
|
|
|
|
obj->m_vecMoveSpeed.z += 0.04f;
|
|
|
|
|
}else{
|
|
|
|
|
obj->m_vecMoveSpeed.z *= 0.25f;
|
|
|
|
|
}
|
|
|
|
|
obj->m_vecMoveSpeed.x *= 0.75f;
|
|
|
|
|
obj->m_vecMoveSpeed.y *= 0.75f;
|
|
|
|
|
|
|
|
|
|
obj->m_vecTurnSpeed = m_vecTurnSpeed*2.0f;
|
|
|
|
|
|
|
|
|
|
// push component away from car
|
|
|
|
|
CVector dist = obj->GetPosition() - GetPosition();
|
|
|
|
|
dist.Normalise();
|
|
|
|
|
if(component == COMPGROUP_BONNET || component == COMPGROUP_BOOT || component == CAR_WINDSCREEN){
|
|
|
|
|
// push these up some
|
|
|
|
|
dist += GetUp();
|
|
|
|
|
if(GetUp().z > 0.0f){
|
|
|
|
|
// simulate fast upward movement if going fast
|
2020-05-27 20:32:33 +00:00
|
|
|
|
float speed = CVector2D(m_vecMoveSpeed).Magnitude();
|
2020-05-05 01:45:18 +00:00
|
|
|
|
obj->GetMatrix().Translate(GetUp()*speed);
|
2019-07-08 19:37:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
obj->ApplyMoveForce(dist);
|
|
|
|
|
|
|
|
|
|
if(type == COMPGROUP_WHEEL){
|
|
|
|
|
obj->m_fTurnMass = 5.0f;
|
|
|
|
|
obj->m_vecTurnSpeed.x = 0.5f;
|
|
|
|
|
obj->m_fAirResistance = 0.99f;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(GetStatus() == STATUS_WRECKED && IsVisible() && DotProduct(dist, TheCamera.GetPosition() - GetPosition()) > -0.5f){
|
|
|
|
|
dist = TheCamera.GetPosition() - GetPosition();
|
|
|
|
|
dist.Normalise();
|
|
|
|
|
dist.z += 0.3f;
|
|
|
|
|
ApplyMoveForce(5.0f*dist);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 07:57:44 +00:00
|
|
|
|
if(CCollision::ProcessColModels(obj->GetMatrix(), *obj->GetColModel(),
|
|
|
|
|
this->GetMatrix(), *this->GetColModel(),
|
2020-05-27 20:32:33 +00:00
|
|
|
|
CWorld::m_aTempColPts, nil, nil) > 0)
|
2019-07-08 19:37:47 +00:00
|
|
|
|
obj->m_pCollidingEntity = this;
|
|
|
|
|
|
|
|
|
|
if(bRenderScorched)
|
|
|
|
|
obj->bRenderScorched = true;
|
|
|
|
|
|
|
|
|
|
CWorld::Add(obj);
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CObject*
|
|
|
|
|
CAutomobile::RemoveBonnetInPedCollision(void)
|
|
|
|
|
{
|
|
|
|
|
CObject *obj;
|
|
|
|
|
|
2020-02-02 12:22:17 +00:00
|
|
|
|
if(Damage.GetDoorStatus(DOOR_BONNET) == DOOR_STATUS_SWINGING &&
|
2019-07-08 19:37:47 +00:00
|
|
|
|
Doors[DOOR_BONNET].RetAngleWhenOpen()*0.4f < Doors[DOOR_BONNET].m_fAngle){
|
2020-05-27 20:32:33 +00:00
|
|
|
|
#ifdef FIX_BUGS
|
|
|
|
|
obj = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_BONNET);
|
|
|
|
|
#else
|
2019-07-08 19:37:47 +00:00
|
|
|
|
obj = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_DOOR);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
#endif
|
2019-07-08 19:37:47 +00:00
|
|
|
|
// make both doors invisible on car
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[CAR_BONNET], ATOMIC_FLAG_NONE);
|
|
|
|
|
Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2019-07-08 06:46:42 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetPanelDamage(int32 component, ePanels panel, bool noFlyingComponents)
|
|
|
|
|
{
|
|
|
|
|
int status = Damage.GetPanelStatus(panel);
|
|
|
|
|
if(m_aCarNodes[component] == nil)
|
|
|
|
|
return;
|
|
|
|
|
if(status == PANEL_STATUS_SMASHED1){
|
2020-06-03 13:16:31 +00:00
|
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_WINDSHIELD_CRACK, 0.0f);
|
2019-07-08 06:46:42 +00:00
|
|
|
|
// show damaged part
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM);
|
|
|
|
|
}else if(status == PANEL_STATUS_MISSING){
|
|
|
|
|
if(!noFlyingComponents)
|
|
|
|
|
SpawnFlyingComponent(component, COMPGROUP_PANEL);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
else
|
|
|
|
|
CGlass::CarWindscreenShatters(this, false);
|
2019-07-08 06:46:42 +00:00
|
|
|
|
// hide both
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetBumperDamage(int32 component, ePanels panel, bool noFlyingComponents)
|
|
|
|
|
{
|
|
|
|
|
int status = Damage.GetPanelStatus(panel);
|
|
|
|
|
if(m_aCarNodes[component] == nil){
|
|
|
|
|
printf("Trying to damage component %d of %s\n",
|
|
|
|
|
component, CModelInfo::GetModelInfo(GetModelIndex())->GetName());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(status == PANEL_STATUS_SMASHED1){
|
|
|
|
|
// show damaged part
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM);
|
|
|
|
|
}else if(status == PANEL_STATUS_MISSING){
|
|
|
|
|
if(!noFlyingComponents)
|
|
|
|
|
SpawnFlyingComponent(component, COMPGROUP_BUMPER);
|
|
|
|
|
// hide both
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents)
|
|
|
|
|
{
|
|
|
|
|
int status = Damage.GetDoorStatus(door);
|
|
|
|
|
if(m_aCarNodes[component] == nil){
|
|
|
|
|
printf("Trying to damage component %d of %s\n",
|
|
|
|
|
component, CModelInfo::GetModelInfo(GetModelIndex())->GetName());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
if(!CanDoorsBeDamaged() && status > DOOR_STATUS_SMASHED && door != DOOR_BONNET && door != DOOR_BOOT){
|
|
|
|
|
Damage.SetDoorStatus(door, DOOR_STATUS_SMASHED);
|
|
|
|
|
status = DOOR_STATUS_SMASHED;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 11:19:20 +00:00
|
|
|
|
if(door == DOOR_BOOT && status == DOOR_STATUS_SWINGING && pHandling->Flags & HANDLING_NOSWING_BOOT){
|
2019-07-08 06:46:42 +00:00
|
|
|
|
Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_MISSING);
|
|
|
|
|
status = DOOR_STATUS_MISSING;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
switch(status){
|
|
|
|
|
case DOOR_STATUS_SMASHED:
|
2019-07-08 06:46:42 +00:00
|
|
|
|
// show damaged part
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
break;
|
|
|
|
|
case DOOR_STATUS_SWINGING:
|
2019-07-08 06:46:42 +00:00
|
|
|
|
// turn off angle cull for swinging doors
|
|
|
|
|
RwFrameForAllObjects(m_aCarNodes[component], CVehicleModelInfo::SetAtomicFlagCB, (void*)ATOMIC_FLAG_NOCULL);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
break;
|
|
|
|
|
case DOOR_STATUS_MISSING:
|
2019-07-08 06:46:42 +00:00
|
|
|
|
if(!noFlyingComponents){
|
|
|
|
|
if(door == DOOR_BONNET)
|
|
|
|
|
SpawnFlyingComponent(component, COMPGROUP_BONNET);
|
|
|
|
|
else if(door == DOOR_BOOT)
|
|
|
|
|
SpawnFlyingComponent(component, COMPGROUP_BOOT);
|
|
|
|
|
else
|
|
|
|
|
SpawnFlyingComponent(component, COMPGROUP_DOOR);
|
|
|
|
|
}
|
|
|
|
|
// hide both
|
|
|
|
|
SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE);
|
2020-05-27 20:32:33 +00:00
|
|
|
|
break;
|
2019-07-08 06:46:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static RwObject*
|
|
|
|
|
SetVehicleAtomicVisibilityCB(RwObject *object, void *data)
|
|
|
|
|
{
|
|
|
|
|
uint32 flags = (uint32)(uintptr)data;
|
|
|
|
|
RpAtomic *atomic = (RpAtomic*)object;
|
|
|
|
|
if((CVisibilityPlugins::GetAtomicId(atomic) & (ATOMIC_FLAG_OK|ATOMIC_FLAG_DAM)) == flags)
|
|
|
|
|
RpAtomicSetFlags(atomic, rpATOMICRENDER);
|
|
|
|
|
else
|
|
|
|
|
RpAtomicSetFlags(atomic, 0);
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetComponentVisibility(RwFrame *frame, uint32 flags)
|
|
|
|
|
{
|
|
|
|
|
HideAllComps();
|
2019-07-08 19:37:47 +00:00
|
|
|
|
bIsDamaged = true;
|
2019-07-08 06:46:42 +00:00
|
|
|
|
RwFrameForAllObjects(frame, SetVehicleAtomicVisibilityCB, (void*)flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetupModelNodes(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for(i = 0; i < NUM_CAR_NODES; i++)
|
|
|
|
|
m_aCarNodes[i] = nil;
|
2020-06-02 21:35:20 +00:00
|
|
|
|
CClumpModelInfo::FillFrameArray(GetClump(), m_aCarNodes);
|
2019-07-08 06:46:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetTaxiLight(bool light)
|
|
|
|
|
{
|
|
|
|
|
bTaxiLight = light;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
CAutomobile::GetAllWheelsOffGround(void)
|
|
|
|
|
{
|
2019-07-17 21:58:06 +00:00
|
|
|
|
return m_nDriveWheelsOnGround == 0;
|
2019-07-08 06:46:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::HideAllComps(void)
|
|
|
|
|
{
|
|
|
|
|
// empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::ShowAllComps(void)
|
|
|
|
|
{
|
|
|
|
|
// empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::ReduceHornCounter(void)
|
|
|
|
|
{
|
|
|
|
|
if(m_nCarHornTimer != 0)
|
|
|
|
|
m_nCarHornTimer--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::SetAllTaxiLights(bool set)
|
|
|
|
|
{
|
|
|
|
|
m_sAllTaxiLights = set;
|
|
|
|
|
}
|
2020-05-02 15:02:17 +00:00
|
|
|
|
|
2020-05-17 18:43:11 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::TellHeliToGoToCoors(float x, float y, float z, uint8 speed)
|
|
|
|
|
{
|
|
|
|
|
AutoPilot.m_nCarMission = MISSION_HELI_FLYTOCOORS;
|
|
|
|
|
AutoPilot.m_vecDestinationCoors.x = x;
|
|
|
|
|
AutoPilot.m_vecDestinationCoors.y = y;
|
|
|
|
|
AutoPilot.m_vecDestinationCoors.z = z;
|
|
|
|
|
AutoPilot.m_nCruiseSpeed = speed;
|
|
|
|
|
SetStatus(STATUS_PHYSICS);
|
2020-05-31 15:05:49 +00:00
|
|
|
|
|
|
|
|
|
if(m_fOrientation == 0.0f){
|
2020-06-12 19:38:37 +00:00
|
|
|
|
m_fOrientation = CGeneral::GetATanOfXY(GetForward().x, GetForward().y) + PI;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
while(m_fOrientation > TWOPI) m_fOrientation -= TWOPI;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::TellPlaneToGoToCoors(float x, float y, float z, uint8 speed)
|
|
|
|
|
{
|
2020-07-30 12:11:06 +00:00
|
|
|
|
AutoPilot.m_nCarMission = MISSION_PLANE_FLYTOCOORS;
|
2020-05-31 15:05:49 +00:00
|
|
|
|
AutoPilot.m_vecDestinationCoors.x = x;
|
|
|
|
|
AutoPilot.m_vecDestinationCoors.y = y;
|
|
|
|
|
AutoPilot.m_vecDestinationCoors.z = z;
|
|
|
|
|
AutoPilot.m_nCruiseSpeed = speed;
|
|
|
|
|
SetStatus(STATUS_PHYSICS);
|
|
|
|
|
|
|
|
|
|
if(m_fOrientation == 0.0f)
|
|
|
|
|
m_fOrientation = CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
|
2020-05-17 18:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 20:32:33 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::PopBoot(void)
|
|
|
|
|
{
|
|
|
|
|
switch(Damage.GetDoorStatus(DOOR_BOOT)){
|
|
|
|
|
case DOOR_STATUS_OK:
|
|
|
|
|
case DOOR_STATUS_SMASHED:
|
|
|
|
|
Doors[DOOR_BOOT].m_fAngle = Doors[DOOR_BOOT].m_fMinAngle;
|
|
|
|
|
CMatrix mat(RwFrameGetMatrix(m_aCarNodes[DOOR_BOOT]));
|
|
|
|
|
CVector pos = mat.GetPosition();
|
|
|
|
|
float axes[3] = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
axes[Doors[DOOR_BOOT].m_nAxis] = Doors[DOOR_BOOT].m_fAngle;
|
|
|
|
|
mat.SetRotate(axes[0], axes[1], axes[2]);
|
|
|
|
|
mat.Translate(pos);
|
|
|
|
|
mat.UpdateRW();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::PopBootUsingPhysics(void)
|
|
|
|
|
{
|
|
|
|
|
switch(Damage.GetDoorStatus(DOOR_BOOT))
|
|
|
|
|
case DOOR_STATUS_OK:
|
|
|
|
|
case DOOR_STATUS_SMASHED:
|
|
|
|
|
Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_SWINGING);
|
|
|
|
|
Doors[DOOR_BOOT].m_fAngle = -2.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::CloseAllDoors(void)
|
|
|
|
|
{
|
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
|
|
|
|
|
if(!IsDoorMissing(DOOR_FRONT_LEFT))
|
|
|
|
|
OpenDoor(CAR_DOOR_LF, DOOR_FRONT_LEFT, 0.0f);
|
|
|
|
|
if(mi->m_numDoors > 1){
|
|
|
|
|
if(!IsDoorMissing(DOOR_FRONT_RIGHT))
|
|
|
|
|
OpenDoor(CAR_DOOR_RF, DOOR_FRONT_RIGHT, 0.0f);
|
|
|
|
|
if(mi->m_numDoors > 2){
|
|
|
|
|
if(!IsDoorMissing(DOOR_REAR_LEFT))
|
|
|
|
|
OpenDoor(CAR_DOOR_LR, DOOR_REAR_LEFT, 0.0f);
|
|
|
|
|
if(!IsDoorMissing(DOOR_REAR_RIGHT))
|
|
|
|
|
OpenDoor(CAR_DOOR_RR, DOOR_REAR_RIGHT, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:05:49 +00:00
|
|
|
|
void
|
|
|
|
|
CAutomobile::KnockPedOutCar(eWeaponType weapon, uint16 door, CPed *ped)
|
|
|
|
|
{
|
|
|
|
|
AnimationId anim = ANIM_KO_SHOT_FRONT1;
|
|
|
|
|
if(ped == nil)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ped->m_vehEnterType = door;
|
|
|
|
|
ped->SetPedState(PED_IDLE);
|
|
|
|
|
CAnimManager::BlendAnimation(ped->GetClump(), ped->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
|
|
|
|
|
CPed::PedSetOutCarCB(nil, ped);
|
|
|
|
|
ped->SetMoveState(PEDMOVE_STILL);
|
|
|
|
|
if(GetUp().z < 0.0f)
|
|
|
|
|
ped->SetHeading(CGeneral::LimitRadianAngle(GetForward().Heading() + PI));
|
|
|
|
|
else
|
|
|
|
|
ped->SetHeading(GetForward().Heading());
|
|
|
|
|
|
|
|
|
|
switch(weapon){
|
|
|
|
|
case WEAPONTYPE_UNARMED:
|
|
|
|
|
case WEAPONTYPE_UNIDENTIFIED:
|
|
|
|
|
ped->m_vecMoveSpeed = m_vecMoveSpeed;
|
|
|
|
|
ped->m_pCollidingEntity = this;
|
|
|
|
|
anim = NUM_STD_ANIMS;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WEAPONTYPE_BASEBALLBAT:
|
|
|
|
|
case WEAPONTYPE_RAMMEDBYCAR:
|
|
|
|
|
case WEAPONTYPE_FALL:
|
|
|
|
|
ped->m_vecMoveSpeed = m_vecMoveSpeed;
|
|
|
|
|
anim = ANIM_KD_LEFT;
|
|
|
|
|
ApplyMoveForce(4.0f*GetUp() + 8.0f*GetRight());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(weapon != WEAPONTYPE_UNARMED){
|
|
|
|
|
ped->SetFall(1000, anim, 0);
|
|
|
|
|
ped->bIsStanding = false;
|
|
|
|
|
ped->m_headingRate = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
ped->m_pMyVehicle = nil;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-02 15:02:17 +00:00
|
|
|
|
#ifdef COMPATIBLE_SAVES
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::Save(uint8*& buf)
|
|
|
|
|
{
|
|
|
|
|
CVehicle::Save(buf);
|
|
|
|
|
WriteSaveBuf<CDamageManager>(buf, Damage);
|
2020-10-17 15:50:16 +00:00
|
|
|
|
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
|
2020-05-02 15:02:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CAutomobile::Load(uint8*& buf)
|
|
|
|
|
{
|
|
|
|
|
CVehicle::Load(buf);
|
|
|
|
|
Damage = ReadSaveBuf<CDamageManager>(buf);
|
2020-10-17 15:50:16 +00:00
|
|
|
|
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
|
2020-05-02 15:02:17 +00:00
|
|
|
|
SetupDamageAfterLoad();
|
|
|
|
|
}
|
|
|
|
|
#endif
|