mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-30 04:54:15 +01:00
more CAutomobile::ProcessControl
This commit is contained in:
parent
fa98f40f7c
commit
ba242bcf58
@ -16,3 +16,11 @@ WRAPPER bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool)
|
|||||||
WRAPPER void CCarCtrl::JoinCarWithRoadSystem(CVehicle*) { EAXJMP(0x41F820); }
|
WRAPPER void CCarCtrl::JoinCarWithRoadSystem(CVehicle*) { EAXJMP(0x41F820); }
|
||||||
WRAPPER void CCarCtrl::SteerAICarWithPhysics(CVehicle*) { EAXJMP(0x41DA60); }
|
WRAPPER void CCarCtrl::SteerAICarWithPhysics(CVehicle*) { EAXJMP(0x41DA60); }
|
||||||
WRAPPER void CCarCtrl::UpdateCarOnRails(CVehicle*) { EAXJMP(0x418880); }
|
WRAPPER void CCarCtrl::UpdateCarOnRails(CVehicle*) { EAXJMP(0x418880); }
|
||||||
|
|
||||||
|
bool
|
||||||
|
CCarCtrl::MapCouldMoveInThisArea(float x, float y)
|
||||||
|
{
|
||||||
|
// bridge moves up and down
|
||||||
|
return x > -342.0f && x < -219.0f &&
|
||||||
|
y > -677.0f && y < -580.0f;
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ public:
|
|||||||
static void JoinCarWithRoadSystem(CVehicle*);
|
static void JoinCarWithRoadSystem(CVehicle*);
|
||||||
static void SteerAICarWithPhysics(CVehicle*);
|
static void SteerAICarWithPhysics(CVehicle*);
|
||||||
static void UpdateCarOnRails(CVehicle*);
|
static void UpdateCarOnRails(CVehicle*);
|
||||||
|
static bool MapCouldMoveInThisArea(float x, float y);
|
||||||
|
|
||||||
static int32 &NumLawEnforcerCars;
|
static int32 &NumLawEnforcerCars;
|
||||||
static int32 &NumAmbulancesOnDuty;
|
static int32 &NumAmbulancesOnDuty;
|
||||||
|
@ -718,7 +718,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
|
|||||||
}
|
}
|
||||||
vehicle->bEngineOn = true;
|
vehicle->bEngineOn = true;
|
||||||
if (vehicle->IsCar())
|
if (vehicle->IsCar())
|
||||||
((CAutomobile*)vehicle)->m_nWheelsOnGround = 4;
|
((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4;
|
||||||
CWorld::Remove(vehicle);
|
CWorld::Remove(vehicle);
|
||||||
CWorld::Add(vehicle);
|
CWorld::Add(vehicle);
|
||||||
if (vehicle->IsBoat())
|
if (vehicle->IsBoat())
|
||||||
|
@ -197,7 +197,7 @@ public:
|
|||||||
int16 Mode;
|
int16 Mode;
|
||||||
int16 ShakeDur;
|
int16 ShakeDur;
|
||||||
uint8 ShakeFreq;
|
uint8 ShakeFreq;
|
||||||
int8 bHornHistory[5];
|
bool bHornHistory[5];
|
||||||
uint8 iCurrHornHistory;
|
uint8 iCurrHornHistory;
|
||||||
uint8 DisablePlayerControls;
|
uint8 DisablePlayerControls;
|
||||||
int8 bApplyBrakes;
|
int8 bApplyBrakes;
|
||||||
@ -377,6 +377,7 @@ public:
|
|||||||
bool ArePlayerControlsDisabled(void) { return DisablePlayerControls != PLAYERCONTROL_ENABLED; }
|
bool ArePlayerControlsDisabled(void) { return DisablePlayerControls != PLAYERCONTROL_ENABLED; }
|
||||||
};
|
};
|
||||||
VALIDATE_SIZE(CPad, 0xFC);
|
VALIDATE_SIZE(CPad, 0xFC);
|
||||||
|
extern CPad *Pads; //[2]
|
||||||
|
|
||||||
#define IsButtonJustDown(pad, btn) \
|
#define IsButtonJustDown(pad, btn) \
|
||||||
(!(pad)->OldState.btn && (pad)->NewState.btn)
|
(!(pad)->OldState.btn && (pad)->NewState.btn)
|
||||||
|
@ -1048,8 +1048,6 @@ CStreaming::RemoveReferencedTxds(int32 mem)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: RemoveCurrentZonesModels
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CStreaming::RemoveUnusedModelsInLoadedList(void)
|
CStreaming::RemoveUnusedModelsInLoadedList(void)
|
||||||
{
|
{
|
||||||
|
@ -315,6 +315,11 @@ enum
|
|||||||
MI_TOYZ,
|
MI_TOYZ,
|
||||||
MI_GHOST,
|
MI_GHOST,
|
||||||
|
|
||||||
|
// leftovers on PC
|
||||||
|
MI_MIAMI_RCBARON = 154,
|
||||||
|
MI_MIAMI_RCRAIDER = 155,
|
||||||
|
MI_MIAMI_SPARROW = 159,
|
||||||
|
|
||||||
MI_GRENADE = 170,
|
MI_GRENADE = 170,
|
||||||
MI_AK47,
|
MI_AK47,
|
||||||
MI_BASEBALL_BAT,
|
MI_BASEBALL_BAT,
|
||||||
|
@ -3,3 +3,4 @@
|
|||||||
#include "Rubbish.h"
|
#include "Rubbish.h"
|
||||||
|
|
||||||
WRAPPER void CRubbish::Render(void) { EAXJMP(0x512190); }
|
WRAPPER void CRubbish::Render(void) { EAXJMP(0x512190); }
|
||||||
|
WRAPPER void CRubbish::StirUp(CVehicle *veh) { EAXJMP(0x512690); }
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
class CVehicle;
|
||||||
|
|
||||||
class CRubbish
|
class CRubbish
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Render(void);
|
static void Render(void);
|
||||||
|
static void StirUp(CVehicle *veh); // CAutomobile on PS2
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "DMAudio.h"
|
#include "DMAudio.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "Darkel.h"
|
#include "Darkel.h"
|
||||||
|
#include "Rubbish.h"
|
||||||
#include "Fire.h"
|
#include "Fire.h"
|
||||||
#include "Explosion.h"
|
#include "Explosion.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
@ -24,6 +25,8 @@
|
|||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Automobile.h"
|
#include "Automobile.h"
|
||||||
|
|
||||||
|
bool bAllCarCheat; // unused
|
||||||
|
|
||||||
RwObject *GetCurrentAtomicObjectCB(RwObject *object, void *data);
|
RwObject *GetCurrentAtomicObjectCB(RwObject *object, void *data);
|
||||||
|
|
||||||
bool &CAutomobile::m_sAllTaxiLights = *(bool*)0x95CD21;
|
bool &CAutomobile::m_sAllTaxiLights = *(bool*)0x95CD21;
|
||||||
@ -102,7 +105,7 @@ CAutomobile::ProcessControl(void)
|
|||||||
|
|
||||||
// Process driver
|
// Process driver
|
||||||
if(pDriver){
|
if(pDriver){
|
||||||
if(!bHadDriver && m_bombType == 5){
|
if(!bHadDriver && m_bombType == CARBOMB_ONIGNITIONACTIVE){
|
||||||
// If someone enters the car and there is a bomb, detonate
|
// If someone enters the car and there is a bomb, detonate
|
||||||
m_nBombTimer = 1000;
|
m_nBombTimer = 1000;
|
||||||
m_pBlowUpEntity = field_4DC;
|
m_pBlowUpEntity = field_4DC;
|
||||||
@ -131,7 +134,7 @@ CAutomobile::ProcessControl(void)
|
|||||||
pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, this);
|
pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CRubbish::StirUp
|
CRubbish::StirUp(this);
|
||||||
|
|
||||||
// blend in clump
|
// blend in clump
|
||||||
int clumpAlpha = CVisibilityPlugins::GetClumpAlpha((RpClump*)m_rwObject);
|
int clumpAlpha = CVisibilityPlugins::GetClumpAlpha((RpClump*)m_rwObject);
|
||||||
@ -200,9 +203,9 @@ CAutomobile::ProcessControl(void)
|
|||||||
CPhysical::ProcessControl();
|
CPhysical::ProcessControl();
|
||||||
CCarCtrl::UpdateCarOnRails(this);
|
CCarCtrl::UpdateCarOnRails(this);
|
||||||
|
|
||||||
m_nWheelsOnGround_2 = 4;
|
|
||||||
m_nWheelsOnGroundPrev = m_nWheelsOnGround;
|
|
||||||
m_nWheelsOnGround = 4;
|
m_nWheelsOnGround = 4;
|
||||||
|
m_nDriveWheelsOnGroundPrev = m_nDriveWheelsOnGround;
|
||||||
|
m_nDriveWheelsOnGround = 4;
|
||||||
|
|
||||||
pHandling->Transmission.CalculateGearForSimpleCar(AutoPilot.m_fMaxTrafficSpeed/50.0f, m_nCurrentGear);
|
pHandling->Transmission.CalculateGearForSimpleCar(AutoPilot.m_fMaxTrafficSpeed/50.0f, m_nCurrentGear);
|
||||||
|
|
||||||
@ -252,13 +255,55 @@ CAutomobile::ProcessControl(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GetPosition().z < -0.6f){
|
// what's going on here?
|
||||||
assert(0);
|
if(GetPosition().z < -0.6f &&
|
||||||
}
|
Abs(m_vecMoveSpeed.x) < 0.05f &&
|
||||||
|
Abs(m_vecMoveSpeed.y) < 0.05f)
|
||||||
|
m_vecTurnSpeed *= Pow(0.95f, CTimer::GetTimeStep());
|
||||||
|
|
||||||
|
// Skip physics if object is found to have been static recently
|
||||||
bool skipPhysics = false;
|
bool skipPhysics = false;
|
||||||
if(!bIsStuck){
|
if(!bIsStuck && (m_status == STATUS_ABANDONED || m_status == STATUS_WRECKED)){
|
||||||
assert(0);
|
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;
|
||||||
|
|
||||||
|
if(m_status == STATUS_WRECKED){
|
||||||
|
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()) &&
|
||||||
|
m_fDistanceTravelled < distanceLimit ||
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Postpone
|
// Postpone
|
||||||
@ -268,15 +313,27 @@ CAutomobile::ProcessControl(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VehicleDamage
|
VehicleDamage(1.0f, 0);
|
||||||
|
|
||||||
// special control
|
// special control
|
||||||
switch(GetModelIndex()){
|
switch(GetModelIndex()){
|
||||||
case MI_FIRETRUCK:
|
case MI_FIRETRUCK:
|
||||||
|
FireTruckControl();
|
||||||
|
break;
|
||||||
case MI_RHINO:
|
case MI_RHINO:
|
||||||
|
TankControl();
|
||||||
|
BlowUpCarsInPath();
|
||||||
|
break;
|
||||||
case MI_YARDIE:
|
case MI_YARDIE:
|
||||||
|
// beta also had esperanto here it seems
|
||||||
|
HydraulicControl();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
if(CVehicle::bCheat3){
|
||||||
|
// strong grip cheat
|
||||||
|
// TODO: make cars jump when horn key is pressed
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(skipPhysics){
|
if(skipPhysics){
|
||||||
@ -402,7 +459,369 @@ CAutomobile::ProcessControl(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0);
|
|
||||||
|
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);
|
||||||
|
acceleration /= fForceMultiplier;
|
||||||
|
|
||||||
|
// unused
|
||||||
|
if(GetModelIndex() == MI_MIAMI_RCBARON ||
|
||||||
|
GetModelIndex() == MI_MIAMI_RCRAIDER ||
|
||||||
|
GetModelIndex() == MI_MIAMI_SPARROW)
|
||||||
|
acceleration = 0.0f;
|
||||||
|
|
||||||
|
float brake = m_fBrakePedal * pHandling->fBrakeDeceleration * CTimer::GetTimeStep();
|
||||||
|
bool neutralHandling = !!(pHandling->Flags & HANDLING_NEUTRALHANDLING);
|
||||||
|
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;
|
||||||
|
float tractionBiasRear = neutralHandling ? 1.0f : 2.0f*(1.0f-pHandling->fTractionBias);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
m_aWheelTimer[i] = max(m_aWheelTimer[i]-CTimer::GetTimeStep(), 0.0f);
|
||||||
|
|
||||||
|
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;
|
||||||
|
if(m_status == STATUS_PHYSICS)
|
||||||
|
traction = 0.004f * m_fTraction;
|
||||||
|
else
|
||||||
|
traction = 0.004f;
|
||||||
|
traction *= pHandling->fTractionMultiplier / 4.0f;
|
||||||
|
traction /= fForceMultiplier;
|
||||||
|
if(CVehicle::bCheat3)
|
||||||
|
traction *= 4.0f;
|
||||||
|
|
||||||
|
if(FindPlayerVehicle() && FindPlayerVehicle() == this){
|
||||||
|
if(CPad::GetPad(0)->WeaponJustDown()){
|
||||||
|
if(m_bombType == CARBOMB_TIMED){
|
||||||
|
m_bombType = CARBOMB_TIMEDACTIVE;
|
||||||
|
m_nBombTimer = 7000;
|
||||||
|
m_pBlowUpEntity = FindPlayerPed();
|
||||||
|
CGarages::TriggerMessage("GA_12", -1, 3000, -1);
|
||||||
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_BOMB_TIMED_ACTIVATED, 1.0f);
|
||||||
|
}else{
|
||||||
|
m_bombType = CARBOMB_ONIGNITIONACTIVE;
|
||||||
|
CGarages::TriggerMessage("GA_12", -1, 3000, -1);
|
||||||
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_BOMB_ONIGNITION_ACTIVATED, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if(strongGrip1 || CVehicle::bCheat3){
|
||||||
|
traction *= 1.2f;
|
||||||
|
acceleration *= 1.4f;
|
||||||
|
if(strongGrip2 || CVehicle::bCheat3){
|
||||||
|
traction *= 1.3f;
|
||||||
|
acceleration *= 1.4f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static float fThrust;
|
||||||
|
static tWheelState WheelState[4];
|
||||||
|
|
||||||
|
// Process front wheels on ground
|
||||||
|
|
||||||
|
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 = Multiply3x3(GetMatrix(), CVector(-s, c, 0.0f));
|
||||||
|
CVector wheelRight = Multiply3x3(GetMatrix(), CVector(c, s, 0.0f));
|
||||||
|
|
||||||
|
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
|
||||||
|
if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
|
||||||
|
fThrust = 0.0f;
|
||||||
|
else
|
||||||
|
fThrust = acceleration;
|
||||||
|
|
||||||
|
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceA = SURFACE_RUBBER29;
|
||||||
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_LEFT])*traction;
|
||||||
|
if(m_status == 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;
|
||||||
|
|
||||||
|
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceA = SURFACE_RUBBER29;
|
||||||
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT])*traction;
|
||||||
|
if(m_status == 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
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process rear wheels
|
||||||
|
|
||||||
|
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f || m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
|
||||||
|
CVector wheelFwd = GetForward();
|
||||||
|
CVector wheelRight = GetRight();
|
||||||
|
|
||||||
|
if(bIsHandbrakeOn)
|
||||||
|
brake = 20000.0f;
|
||||||
|
|
||||||
|
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f){
|
||||||
|
if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
|
||||||
|
fThrust = 0.0f;
|
||||||
|
else
|
||||||
|
fThrust = acceleration;
|
||||||
|
|
||||||
|
m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceA = SURFACE_RUBBER29;
|
||||||
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_LEFT])*traction;
|
||||||
|
if(m_status == STATUS_PLAYER)
|
||||||
|
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,
|
||||||
|
brake*brakeBiasRear,
|
||||||
|
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,
|
||||||
|
brake*brakeBiasRear,
|
||||||
|
adhesion*tractionBiasRear,
|
||||||
|
CARWHEEL_REAR_LEFT,
|
||||||
|
&m_aWheelSpeed[CARWHEEL_REAR_LEFT],
|
||||||
|
&WheelState[CARWHEEL_REAR_LEFT],
|
||||||
|
WHEEL_STATUS_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
|
||||||
|
if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
|
||||||
|
fThrust = 0.0f;
|
||||||
|
else
|
||||||
|
fThrust = acceleration;
|
||||||
|
|
||||||
|
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceA = SURFACE_RUBBER29;
|
||||||
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_RIGHT])*traction;
|
||||||
|
if(m_status == STATUS_PLAYER)
|
||||||
|
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,
|
||||||
|
brake*brakeBiasRear,
|
||||||
|
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,
|
||||||
|
brake*brakeBiasRear,
|
||||||
|
adhesion*tractionBiasRear,
|
||||||
|
CARWHEEL_REAR_RIGHT,
|
||||||
|
&m_aWheelSpeed[CARWHEEL_REAR_RIGHT],
|
||||||
|
&WheelState[CARWHEEL_REAR_RIGHT],
|
||||||
|
WHEEL_STATUS_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process rear wheels off ground
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_aWheelRotation[CARWHEEL_REAR_LEFT] += m_aWheelSpeed[CARWHEEL_REAR_LEFT];
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_aWheelRotation[CARWHEEL_REAR_RIGHT] += m_aWheelSpeed[CARWHEEL_REAR_RIGHT];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; i < 4; i++){
|
||||||
|
float wheelPos = colModel->lines[i].p0.z;
|
||||||
|
if(m_aSuspensionSpringRatio[i] > 0.0f)
|
||||||
|
wheelPos -= m_aSuspensionSpringRatio[i]*m_aSuspensionLineLength[i];
|
||||||
|
m_aWheelPosition[i] += (wheelPos - m_aWheelPosition[i])*0.75f;
|
||||||
|
}
|
||||||
|
for(i = 0; i < 4; i++)
|
||||||
|
m_aWheelState[i] = WheelState[i];
|
||||||
|
|
||||||
|
// Process horn
|
||||||
|
|
||||||
|
if(m_status != STATUS_PLAYER){
|
||||||
|
ReduceHornCounter();
|
||||||
|
}else{
|
||||||
|
if(GetModelIndex() == MI_MRWHOOP){
|
||||||
|
if(Pads[0].bHornHistory[Pads[0].iCurrHornHistory] &&
|
||||||
|
!Pads[0].bHornHistory[(Pads[0].iCurrHornHistory+4) % 5]){
|
||||||
|
m_bSirenOrAlarm = !m_bSirenOrAlarm;
|
||||||
|
printf("m_bSirenOrAlarm toggled to %d\n", m_bSirenOrAlarm);
|
||||||
|
}
|
||||||
|
}else if(UsesSiren(GetModelIndex())){
|
||||||
|
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;
|
||||||
|
}else if(GetModelIndex() != MI_YARDIE && !CVehicle::bCheat3){
|
||||||
|
if(Pads[0].GetHorn())
|
||||||
|
m_nCarHornTimer = 1;
|
||||||
|
else
|
||||||
|
m_nCarHornTimer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flying
|
||||||
|
|
||||||
|
if(m_status != STATUS_PLAYER && m_status != STATUS_PLAYER_REMOTE && m_status != STATUS_PHYSICS){
|
||||||
|
if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW)
|
||||||
|
m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.0005f, 0.0f);
|
||||||
|
}else if((GetModelIndex() == MI_DODO || CVehicle::bAllDodosCheat) &&
|
||||||
|
m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){
|
||||||
|
FlyingControl(FLIGHT_MODEL_DODO);
|
||||||
|
}else if(GetModelIndex() == MI_MIAMI_RCBARON){
|
||||||
|
FlyingControl(FLIGHT_MODEL_HELI);
|
||||||
|
}else if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW || bAllCarCheat){
|
||||||
|
if(CPad::GetPad(0)->GetCircleJustDown())
|
||||||
|
m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.03f, 0.0f);
|
||||||
|
if(m_aWheelSpeed[0] < 0.22f)
|
||||||
|
m_aWheelSpeed[0] += 0.0001f;
|
||||||
|
if(m_aWheelSpeed[0] > 0.15f)
|
||||||
|
FlyingControl(FLIGHT_MODEL_HELI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0 && "misc stuff");
|
assert(0 && "misc stuff");
|
||||||
@ -639,6 +1058,27 @@ CAutomobile::ProcessControlInputs(uint8 pad)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRAPPER void
|
||||||
|
CAutomobile::FireTruckControl(void)
|
||||||
|
{ EAXJMP(0x522590);
|
||||||
|
}
|
||||||
|
|
||||||
|
WRAPPER void
|
||||||
|
CAutomobile::TankControl(void)
|
||||||
|
{ EAXJMP(0x53D530);
|
||||||
|
}
|
||||||
|
|
||||||
|
WRAPPER void
|
||||||
|
CAutomobile::HydraulicControl(void)
|
||||||
|
{ EAXJMP(0x52D4E0);
|
||||||
|
}
|
||||||
|
|
||||||
|
WRAPPER void
|
||||||
|
CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
|
||||||
|
{ EAXJMP(0x52F390);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WRAPPER void
|
WRAPPER void
|
||||||
CAutomobile::ProcessBuoyancy(void)
|
CAutomobile::ProcessBuoyancy(void)
|
||||||
{ EAXJMP(0x5308D0);
|
{ EAXJMP(0x5308D0);
|
||||||
@ -908,7 +1348,7 @@ CAutomobile::BlowUpCar(CEntity *culprit)
|
|||||||
|
|
||||||
m_fHealth = 0.0f;
|
m_fHealth = 0.0f;
|
||||||
m_nBombTimer = 0;
|
m_nBombTimer = 0;
|
||||||
m_bombType = 0;
|
m_bombType = CARBOMB_NONE;
|
||||||
|
|
||||||
TheCamera.CamShake(0.7f, GetPosition().x, GetPosition().y, GetPosition().z);
|
TheCamera.CamShake(0.7f, GetPosition().x, GetPosition().y, GetPosition().z);
|
||||||
|
|
||||||
@ -1057,9 +1497,9 @@ CAutomobile::ResetSuspension(void)
|
|||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 4; i++){
|
for(i = 0; i < 4; i++){
|
||||||
m_aSuspensionSpringRatio[i] = 1.0f;
|
m_aSuspensionSpringRatio[i] = 1.0f;
|
||||||
m_aWheelSkidThing[i] = 0.0f;
|
m_aWheelTimer[i] = 0.0f;
|
||||||
m_aWheelRotation[i] = 0.0f;
|
m_aWheelRotation[i] = 0.0f;
|
||||||
m_aWheelState[i] = 0; // TODO: enum?
|
m_aWheelState[i] = WHEEL_STATE_0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1562,7 +2002,7 @@ CAutomobile::SetTaxiLight(bool light)
|
|||||||
bool
|
bool
|
||||||
CAutomobile::GetAllWheelsOffGround(void)
|
CAutomobile::GetAllWheelsOffGround(void)
|
||||||
{
|
{
|
||||||
return m_nWheelsOnGround == 0;
|
return m_nDriveWheelsOnGround == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -6,11 +6,24 @@
|
|||||||
|
|
||||||
class CObject;
|
class CObject;
|
||||||
|
|
||||||
// Wheels are in order:
|
// These are used for all the wheel arrays
|
||||||
// FRONT LEFT
|
// DON'T confuse with VEHWHEEL, which are vehicle components
|
||||||
// REAR LEFT
|
enum {
|
||||||
// FRONT RIGHT
|
CARWHEEL_FRONT_LEFT,
|
||||||
// REAR RIGHT
|
CARWHEEL_REAR_LEFT,
|
||||||
|
CARWHEEL_FRONT_RIGHT,
|
||||||
|
CARWHEEL_REAR_RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eBombType
|
||||||
|
{
|
||||||
|
CARBOMB_NONE,
|
||||||
|
CARBOMB_TIMED,
|
||||||
|
CARBOMB_ONIGNITION,
|
||||||
|
CARBOMB_REMOTE,
|
||||||
|
CARBOMB_TIMEDACTIVE,
|
||||||
|
CARBOMB_ONIGNITIONACTIVE,
|
||||||
|
};
|
||||||
|
|
||||||
class CAutomobile : public CVehicle
|
class CAutomobile : public CVehicle
|
||||||
{
|
{
|
||||||
@ -22,7 +35,7 @@ public:
|
|||||||
CColPoint m_aWheelColPoints[4];
|
CColPoint m_aWheelColPoints[4];
|
||||||
float m_aSuspensionSpringRatio[4];
|
float m_aSuspensionSpringRatio[4];
|
||||||
float m_aSuspensionSpringRatioPrev[4];
|
float m_aSuspensionSpringRatioPrev[4];
|
||||||
float m_aWheelSkidThing[4];
|
float m_aWheelTimer[4]; // set to 4.0 when wheel is touching ground, then decremented
|
||||||
float field_49C;
|
float field_49C;
|
||||||
bool m_aWheelSkidmarkMuddy[4];
|
bool m_aWheelSkidmarkMuddy[4];
|
||||||
bool m_aWheelSkidmarkBloody[4];
|
bool m_aWheelSkidmarkBloody[4];
|
||||||
@ -44,7 +57,7 @@ public:
|
|||||||
float m_aSuspensionSpringLength[4];
|
float m_aSuspensionSpringLength[4];
|
||||||
float m_aSuspensionLineLength[4];
|
float m_aSuspensionLineLength[4];
|
||||||
float m_fHeightAboveRoad;
|
float m_fHeightAboveRoad;
|
||||||
float m_fImprovedHandling;
|
float m_fTraction;
|
||||||
uint8 stuff6[28];
|
uint8 stuff6[28];
|
||||||
float field_530;
|
float field_530;
|
||||||
CPhysical *m_aGroundPhysical[4]; // physicals touching wheels
|
CPhysical *m_aGroundPhysical[4]; // physicals touching wheels
|
||||||
@ -56,11 +69,11 @@ public:
|
|||||||
float m_fCarGunUD;
|
float m_fCarGunUD;
|
||||||
float m_fWindScreenRotation;
|
float m_fWindScreenRotation;
|
||||||
uint8 stuff4[4];
|
uint8 stuff4[4];
|
||||||
uint8 m_nWheelsOnGround_2;
|
|
||||||
uint8 m_nWheelsOnGround;
|
uint8 m_nWheelsOnGround;
|
||||||
uint8 m_nWheelsOnGroundPrev;
|
uint8 m_nDriveWheelsOnGround;
|
||||||
|
uint8 m_nDriveWheelsOnGroundPrev;
|
||||||
uint8 stuff5[5];
|
uint8 stuff5[5];
|
||||||
int32 m_aWheelState[4];
|
tWheelState m_aWheelState[4];
|
||||||
|
|
||||||
static bool &m_sAllTaxiLights;
|
static bool &m_sAllTaxiLights;
|
||||||
|
|
||||||
@ -95,6 +108,10 @@ public:
|
|||||||
float GetHeightAboveRoad(void);
|
float GetHeightAboveRoad(void);
|
||||||
void PlayCarHorn(void);
|
void PlayCarHorn(void);
|
||||||
|
|
||||||
|
void FireTruckControl(void);
|
||||||
|
void TankControl(void);
|
||||||
|
void HydraulicControl(void);
|
||||||
|
void VehicleDamage(float impulse, uint16 damagedPiece);
|
||||||
void ProcessBuoyancy(void);
|
void ProcessBuoyancy(void);
|
||||||
void DoDriveByShootings(void);
|
void DoDriveByShootings(void);
|
||||||
int32 RcbanditCheckHitWheels(void);
|
int32 RcbanditCheckHitWheels(void);
|
||||||
|
@ -66,7 +66,7 @@ class CDamageManager
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
float field_0;
|
float m_fWheelDamageEffect;
|
||||||
uint8 m_engineStatus;
|
uint8 m_engineStatus;
|
||||||
uint8 m_wheelStatus[4];
|
uint8 m_wheelStatus[4];
|
||||||
uint8 m_doorStatus[6];
|
uint8 m_doorStatus[6];
|
||||||
|
@ -127,7 +127,7 @@ cHandlingDataMgr::LoadHandlingData(void)
|
|||||||
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
|
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
|
||||||
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
|
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
|
||||||
handling = &HandlingData[handlingId];
|
handling = &HandlingData[handlingId];
|
||||||
handling->nIdentifier = handlingId;
|
handling->nIdentifier = (eHandlingId)handlingId;
|
||||||
break;
|
break;
|
||||||
case 1: handling->fMass = strtod(word, nil); break;
|
case 1: handling->fMass = strtod(word, nil); break;
|
||||||
case 2: handling->Dimension.x = strtod(word, nil); break;
|
case 2: handling->Dimension.x = strtod(word, nil); break;
|
||||||
|
@ -85,7 +85,7 @@ enum
|
|||||||
|
|
||||||
struct tHandlingData
|
struct tHandlingData
|
||||||
{
|
{
|
||||||
int32 nIdentifier;
|
eHandlingId nIdentifier;
|
||||||
float fMass;
|
float fMass;
|
||||||
float fInvMass;
|
float fInvMass;
|
||||||
float fTurnMass;
|
float fTurnMass;
|
||||||
@ -136,6 +136,8 @@ public:
|
|||||||
void ConvertDataToGameUnits(tHandlingData *handling);
|
void ConvertDataToGameUnits(tHandlingData *handling);
|
||||||
int32 GetHandlingId(const char *name);
|
int32 GetHandlingId(const char *name);
|
||||||
tHandlingData *GetHandlingData(eHandlingId id) { return &HandlingData[id]; }
|
tHandlingData *GetHandlingData(eHandlingId id) { return &HandlingData[id]; }
|
||||||
|
bool HasRearWheelDrive(eHandlingId id) { return HandlingData[id].Transmission.nDriveType == 'R'; }
|
||||||
|
bool HasFrontWheelDrive(eHandlingId id) { return HandlingData[id].Transmission.nDriveType == 'F'; }
|
||||||
};
|
};
|
||||||
VALIDATE_SIZE(cHandlingDataMgr, 0x3030);
|
VALIDATE_SIZE(cHandlingDataMgr, 0x3030);
|
||||||
extern cHandlingDataMgr &mod_HandlingManager;
|
extern cHandlingDataMgr &mod_HandlingManager;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
#include "HandlingMgr.h"
|
||||||
#include "Transmission.h"
|
#include "Transmission.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -39,7 +41,9 @@ cTransmission::InitGearRatios(void)
|
|||||||
void
|
void
|
||||||
cTransmission::CalculateGearForSimpleCar(float speed, uint8 &gear)
|
cTransmission::CalculateGearForSimpleCar(float speed, uint8 &gear)
|
||||||
{
|
{
|
||||||
static tGear *pGearRatio = &Gears[gear];
|
static tGear *pGearRatio;
|
||||||
|
|
||||||
|
pGearRatio = &Gears[gear];
|
||||||
fCurVelocity = speed;
|
fCurVelocity = speed;
|
||||||
if(speed > pGearRatio->fShiftUpVelocity)
|
if(speed > pGearRatio->fShiftUpVelocity)
|
||||||
gear++;
|
gear++;
|
||||||
@ -50,3 +54,90 @@ cTransmission::CalculateGearForSimpleCar(float speed, uint8 &gear)
|
|||||||
gear--;
|
gear--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, float &time, const float &velocity, bool cheat)
|
||||||
|
{
|
||||||
|
static float fAcceleration = 0.0f;
|
||||||
|
static float fVelocity;
|
||||||
|
static float fCheat;
|
||||||
|
static tGear *pGearRatio;
|
||||||
|
|
||||||
|
fVelocity = velocity;
|
||||||
|
if(fVelocity < fMaxReverseVelocity){
|
||||||
|
fVelocity = fMaxReverseVelocity;
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
if(fVelocity > fMaxVelocity){
|
||||||
|
fVelocity = fMaxVelocity;
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
fCurVelocity = fVelocity;
|
||||||
|
|
||||||
|
assert(gear <= nNumberOfGears);
|
||||||
|
|
||||||
|
pGearRatio = &Gears[gear];
|
||||||
|
if(fVelocity > pGearRatio->fShiftUpVelocity){
|
||||||
|
if(gear != 0 || gasPedal > 0.0f){
|
||||||
|
gear++;
|
||||||
|
time = 0.0f;
|
||||||
|
return CalculateDriveAcceleration(gasPedal, gear, time, fVelocity, false);
|
||||||
|
}
|
||||||
|
}else if(fVelocity < pGearRatio->fShiftDownVelocity && gear != 0){
|
||||||
|
if(gear != 1 || gasPedal < 0.0f){
|
||||||
|
gear--;
|
||||||
|
time = 0.0f;
|
||||||
|
return CalculateDriveAcceleration(gasPedal, gear, time, fVelocity, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(time > 0.0f){
|
||||||
|
// changing gears currently, can't accelerate
|
||||||
|
fAcceleration = 0.0f;
|
||||||
|
time -= CTimer::GetTimeStepInSeconds();
|
||||||
|
}else{
|
||||||
|
float speedMul, accelMul;
|
||||||
|
|
||||||
|
if(gear < 1){
|
||||||
|
// going reverse
|
||||||
|
accelMul = (Flags & HANDLING_2G_BOOST) ? 2.0f : 1.0f;
|
||||||
|
speedMul = -1.0f;
|
||||||
|
}else if(nNumberOfGears == 1){
|
||||||
|
accelMul = 1.0f;
|
||||||
|
speedMul = 1.0f;
|
||||||
|
}else{
|
||||||
|
// BUG or not? this is 1.0 normally but 0.0 in the highest gear
|
||||||
|
float f = 1.0f - (gear-1)/(nNumberOfGears-1);
|
||||||
|
speedMul = 3.0f*sq(f) + 1.0f;
|
||||||
|
// This is pretty ugly, could be written more clearly
|
||||||
|
if(Flags & HANDLING_2G_BOOST){
|
||||||
|
if(gear == 1)
|
||||||
|
accelMul = (Flags & HANDLING_1G_BOOST) ? 3.0f : 2.0f;
|
||||||
|
else if(gear == 2)
|
||||||
|
accelMul = 1.3f;
|
||||||
|
else
|
||||||
|
accelMul = 1.0f;
|
||||||
|
}else if(Flags & HANDLING_1G_BOOST && gear == 1){
|
||||||
|
accelMul = 3.0f;
|
||||||
|
}else
|
||||||
|
accelMul = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cheat)
|
||||||
|
fCheat = 1.2f;
|
||||||
|
else
|
||||||
|
fCheat = 1.0f;
|
||||||
|
float targetVelocity = Gears[gear].fMaxVelocity*speedMul*fCheat;
|
||||||
|
float accel = fEngineAcceleration*accelMul * (targetVelocity - fVelocity)/Abs(targetVelocity);
|
||||||
|
if(Abs(fVelocity) < Abs(Gears[gear].fMaxVelocity*fCheat))
|
||||||
|
fAcceleration = gasPedal * accel * CTimer::GetTimeStep();
|
||||||
|
else
|
||||||
|
fAcceleration = 0.0f;
|
||||||
|
}
|
||||||
|
return fAcceleration;
|
||||||
|
}
|
||||||
|
|
||||||
|
STARTPATCHES
|
||||||
|
InjectHook(0x550A00, &cTransmission::CalculateGearForSimpleCar, PATCH_JUMP);
|
||||||
|
InjectHook(0x5506B0, &cTransmission::CalculateDriveAcceleration, PATCH_JUMP);
|
||||||
|
ENDPATCHES
|
||||||
|
@ -24,4 +24,5 @@ public:
|
|||||||
|
|
||||||
void InitGearRatios(void);
|
void InitGearRatios(void);
|
||||||
void CalculateGearForSimpleCar(float speed, uint8 &gear);
|
void CalculateGearForSimpleCar(float speed, uint8 &gear);
|
||||||
|
float CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, float &time, const float &velocity, bool cheat);
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
m_nCurrentGear = 0;
|
m_nCurrentGear = 0;
|
||||||
field_208 = 0;
|
m_fChangeGearTime = 0;
|
||||||
m_fSteerRatio = 0.0f;
|
m_fSteerRatio = 0.0f;
|
||||||
m_type = ENTITY_TYPE_VEHICLE;
|
m_type = ENTITY_TYPE_VEHICLE;
|
||||||
VehicleCreatedBy = CreatedBy;
|
VehicleCreatedBy = CreatedBy;
|
||||||
@ -380,7 +380,7 @@ CVehicle::ProcessDelayedExplosion(void)
|
|||||||
else
|
else
|
||||||
m_nBombTimer -= tick;
|
m_nBombTimer -= tick;
|
||||||
|
|
||||||
if(IsCar() && ((CAutomobile*)this)->m_bombType == 4 && (m_nBombTimer & 0xFE00) != 0xFE00)
|
if(IsCar() && ((CAutomobile*)this)->m_bombType == CARBOMB_TIMEDACTIVE && (m_nBombTimer & 0xFE00) != 0xFE00)
|
||||||
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_BOMB_TICK, 0.0f);
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_BOMB_TICK, 0.0f);
|
||||||
|
|
||||||
if (m_nBombTimer != 0)
|
if (m_nBombTimer != 0)
|
||||||
|
@ -191,7 +191,7 @@ public:
|
|||||||
float m_fHealth; // 1000.0f = full health. 0 -> explode
|
float m_fHealth; // 1000.0f = full health. 0 -> explode
|
||||||
uint8 m_nCurrentGear;
|
uint8 m_nCurrentGear;
|
||||||
int8 field_205[3];
|
int8 field_205[3];
|
||||||
int field_208;
|
float m_fChangeGearTime;
|
||||||
uint32 m_nGunFiringTime; // last time when gun on vehicle was fired (used on boats)
|
uint32 m_nGunFiringTime; // last time when gun on vehicle was fired (used on boats)
|
||||||
uint32 m_nTimeOfDeath;
|
uint32 m_nTimeOfDeath;
|
||||||
int16 field_214;
|
int16 field_214;
|
||||||
|
Loading…
Reference in New Issue
Block a user