Merge branch 'miami' of https://github.com/GTAmodding/re3 into miami

This commit is contained in:
eray orçunus 2020-06-05 23:17:19 +03:00
commit d3736ccb17
6 changed files with 70 additions and 25 deletions

View File

@ -25,7 +25,7 @@
#include "Debug.h"
#include "Camera.h"
#include "DMAudio.h"
#include <vehicles\Bike.h>
#include "Bike.h"
bool PrintDebugCode = false;
int16 DebugCamMode;

View File

@ -1546,10 +1546,8 @@ CAutomobile::ProcessControl(void)
// Blow up car after 5 seconds
m_fFireBlowUpTimer += CTimer::GetTimeStepInMilliseconds();
if(m_fFireBlowUpTimer > 5000.0f){
CWorld::Players[CWorld::PlayerInFocus].AwardMoneyForExplosion(this);
if(m_fFireBlowUpTimer > 5000.0f)
BlowUpCar(m_pSetOnFireEntity);
}
}else
m_fFireBlowUpTimer = 0.0f;

View File

@ -96,7 +96,7 @@ CBike::CBike(int32 id, uint8 CreatedBy)
m_bike_flag08 = false;
bIsStanding = false;
bExtraSpeed = false;
m_bike_flag40 = false;
bIsOnFire = false;
m_bike_flag80 = false;
m_fTireTemperature = 0.0f;
@ -209,22 +209,35 @@ CBike::ProcessControl(void)
if(m_fLeanInput < 0.0f){
m_vecCentreOfMass.y = pHandling->CentreOfMass.y + pBikeHandling->fLeanBakCOM*m_fLeanInput;
CVector com = m_vecCentreOfMass;
#ifdef FIX_BUGS
// center of mass has to have world space orientation. unfortunately we can't do wheelies
// at high speed then, flipping y here is like riding south without this fix where wheelies work
com.y = -com.y;
com = Multiply3x3(GetMatrix(), com);
#endif
if(m_fBrakePedal == 0.0f && !bIsHandbrakeOn || m_nWheelsOnGround == 0){
if(GetModelIndex() == MI_SANCHEZ){
float force = m_fLeanInput*m_fTurnMass*pBikeHandling->fLeanBackForce*Min(m_vecMoveSpeed.Magnitude(), 0.1f);
force *= 0.7f*m_fGasPedal + 0.3f;
ApplyTurnForce(-force*CTimer::GetTimeStep()*GetUp(), m_vecCentreOfMass+GetForward());
ApplyTurnForce(-force*CTimer::GetTimeStep()*GetUp(), com+GetForward());
}else{
float force = m_fLeanInput*m_fTurnMass*pBikeHandling->fLeanBackForce*Min(m_vecMoveSpeed.Magnitude(), 0.1f);
force *= 0.5f*m_fGasPedal + 0.5f;
ApplyTurnForce(-force*CTimer::GetTimeStep()*GetUp(), m_vecCentreOfMass+GetForward());
ApplyTurnForce(-force*CTimer::GetTimeStep()*GetUp(), com+GetForward());
}
}
}else{
m_vecCentreOfMass.y = pHandling->CentreOfMass.y + pBikeHandling->fLeanFwdCOM*m_fLeanInput;
CVector com = m_vecCentreOfMass;
#ifdef FIX_BUGS
// see above
com.y = -com.y;
com = Multiply3x3(GetMatrix(), com);
#endif
if(m_fBrakePedal < 0.0f || m_nWheelsOnGround == 0){
float force = m_fLeanInput*m_fTurnMass*pBikeHandling->fLeanFwdForce*Min(m_vecMoveSpeed.Magnitude(), 0.1f);
ApplyTurnForce(-force*CTimer::GetTimeStep()*GetUp(), m_vecCentreOfMass+GetForward());
ApplyTurnForce(-force*CTimer::GetTimeStep()*GetUp(), com+GetForward());
}
}
@ -388,12 +401,10 @@ CBike::ProcessControl(void)
float turnY = localTurnSpeed.y*(res.y - 1.0f);
res = -GetUp() * turnY * m_fTurnMass;
// BUG? matrix multiplication
ApplyTurnForce(res, GetRight() + Multiply3x3(GetMatrix(),m_vecCentreOfMass));
ApplyTurnForce(res, GetRight() + Multiply3x3(GetMatrix(), m_vecCentreOfMass));
res = GetUp() * turnX * m_fTurnMass;
// BUG? matrix multiplication
ApplyTurnForce(res, GetForward() + Multiply3x3(GetMatrix(),m_vecCentreOfMass));
ApplyTurnForce(res, GetForward() + Multiply3x3(GetMatrix(), m_vecCentreOfMass));
if(GetStatus() != STATUS_PLAYER)
m_vecCentreOfMass = pHandling->CentreOfMass;
@ -1050,6 +1061,41 @@ CBike::ProcessControl(void)
}
}
if(m_fHealth < 250.0f && GetStatus() != STATUS_WRECKED){
// Car is on fire
CVector damagePos, fireDir;
// move fire forward if in first person
if(this == FindPlayerVehicle() && TheCamera.GetLookingForwardFirstPerson()){
damagePos = CVector(0.0f, 1.2f, -0.4f);
fireDir = CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.01125f, 0.09f));
}else{
damagePos = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->m_positions[CAR_POS_BACKSEAT];
damagePos.z -= 0.3f;
fireDir = CGeneral::GetRandomNumberInRange(0.02025f, 0.09f) * GetRight();
fireDir -= CGeneral::GetRandomNumberInRange(0.02025f, 0.18f) * GetForward();
fireDir.z = CGeneral::GetRandomNumberInRange(0.00225f, 0.018f);
}
damagePos = GetMatrix()*damagePos;
CParticle::AddParticle(PARTICLE_CARFLAME, damagePos, fireDir,
nil, 0.9f);
CParticle::AddParticle(PARTICLE_ENGINE_SMOKE2, damagePos, CVector(0.0f, 0.0f, 0.0f), nil, 0.5f);
damagePos.x += CGeneral::GetRandomNumberInRange(-0.5625f, 0.5625f),
damagePos.y += CGeneral::GetRandomNumberInRange(-0.5625f, 0.5625f),
damagePos.z += CGeneral::GetRandomNumberInRange(0.5625f, 2.25f);
CParticle::AddParticle(PARTICLE_CARFLAME_SMOKE, damagePos, CVector(0.0f, 0.0f, 0.0f));
// Blow up car after 5 seconds
m_fFireBlowUpTimer += CTimer::GetTimeStepInMilliseconds();
if(m_fFireBlowUpTimer > 5000.0f)
BlowUpCar(m_pSetOnFireEntity);
}else
m_fFireBlowUpTimer = 0.0f;
ProcessDelayedExplosion();
// Find out how much to shake the pad depending on suspension and ground surface
@ -1915,7 +1961,7 @@ void
CBike::Fix(void)
{
bIsDamaged = false;
m_bike_flag40 = false;
bIsOnFire = false;
m_wheelStatus[0] = WHEEL_STATUS_OK;
m_wheelStatus[1] = WHEEL_STATUS_OK;
}

View File

@ -72,7 +72,7 @@ public:
uint8 m_bike_flag08 : 1;
uint8 bIsStanding : 1;
uint8 bExtraSpeed : 1; // leaning forward
uint8 m_bike_flag40 : 1;
uint8 bIsOnFire : 1;
uint8 m_bike_flag80 : 1; // doing wheelie?
int16 m_doingBurnout;
float m_fTireTemperature;

View File

@ -5,6 +5,8 @@
#include "Timer.h"
#include "Pad.h"
#include "Vehicle.h"
#include "Bike.h"
#include "Automobile.h"
#include "Pools.h"
#include "HandlingMgr.h"
#include "CarCtrl.h"
@ -893,7 +895,7 @@ float fTweakBikeWheelTurnForce = 2.0f;
void
CVehicle::ProcessBikeWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelContactSpeed, CVector &wheelContactPoint,
int32 wheelsOnGround, float thrust, float brake, float adhesion, float unk, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, eBikeWheelSpecial special, uint16 wheelStatus)
int32 wheelsOnGround, float thrust, float brake, float adhesion, float destabTraction, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, eBikeWheelSpecial special, uint16 wheelStatus)
{
// BUG: using statics here is probably a bad idea
static bool bAlreadySkidding = false; // this is never reset
@ -1010,14 +1012,14 @@ CVehicle::ProcessBikeWheel(CVector &wheelFwd, CVector &wheelRight, CVector &whee
right *= adhesion * tractionLoss / l;
fwd *= adhesion * tractionLoss / l;
if(unk < 1.0f)
right *= unk;
}else if(unk < 1.0f){
if(destabTraction < 1.0f)
right *= destabTraction;
}else if(destabTraction < 1.0f){
if(!bAlreadySkidding)
unk *= pHandling->fTractionLoss;
if(sq(adhesion*unk) < speedSq){
destabTraction *= pHandling->fTractionLoss;
if(sq(adhesion*destabTraction) < speedSq){
float l = Sqrt(speedSq);
right *= adhesion * unk / l;
right *= adhesion * destabTraction / l;
}
}
@ -1030,15 +1032,14 @@ CVehicle::ProcessBikeWheel(CVector &wheelFwd, CVector &wheelRight, CVector &whee
float impulse = speed*m_fMass;
float turnImpulse = speed*GetMass(wheelContactPoint, direction);
CVector vTurnImpulse = turnImpulse * direction;
float turnRight = DotProduct(vTurnImpulse, GetRight());
ApplyMoveForce(impulse * direction);
float turnRight = DotProduct(vTurnImpulse, GetRight());
float contactRight = DotProduct(wheelContactPoint, GetRight());
float contactFwd = DotProduct(wheelContactPoint, GetForward());
if(wheelId != CARWHEEL_REAR_LEFT ||
!bBraking && !bReversing)
if(wheelId != BIKEWHEEL_REAR || !bBraking && !bReversing)
ApplyTurnForce((vTurnImpulse - turnRight*GetRight()) * fTweakBikeWheelTurnForce,
wheelContactPoint - contactRight*GetRight());

View File

@ -306,7 +306,7 @@ public:
void ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelContactSpeed, CVector &wheelContactPoint,
int32 wheelsOnGround, float thrust, float brake, float adhesion, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, uint16 wheelStatus);
void ProcessBikeWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelContactSpeed, CVector &wheelContactPoint,
int32 wheelsOnGround, float thrust, float brake, float adhesion, float unk, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, eBikeWheelSpecial special, uint16 wheelStatus);
int32 wheelsOnGround, float thrust, float brake, float adhesion, float destabTraction, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, eBikeWheelSpecial special, uint16 wheelStatus);
void ExtinguishCarFire(void);
void ProcessDelayedExplosion(void);
float ProcessWheelRotation(tWheelState state, const CVector &fwd, const CVector &speed, float radius);