diff options
author | aap <aap@papnet.eu> | 2020-06-05 15:09:45 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-06-05 15:09:45 +0200 |
commit | 1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3 (patch) | |
tree | 8ea52a3d6c8a17e42244e464c69639c0fde5431d /src | |
parent | fix (diff) | |
download | re3-1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3.tar re3-1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3.tar.gz re3-1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3.tar.bz2 re3-1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3.tar.lz re3-1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3.tar.xz re3-1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3.tar.zst re3-1bfb01d5f52e64e4b2d6557e2b7c3f6618671da3.zip |
Diffstat (limited to '')
-rw-r--r-- | src/vehicles/Automobile.cpp | 4 | ||||
-rw-r--r-- | src/vehicles/Bike.cpp | 64 | ||||
-rw-r--r-- | src/vehicles/Bike.h | 2 | ||||
-rw-r--r-- | src/vehicles/Vehicle.cpp | 21 | ||||
-rw-r--r-- | src/vehicles/Vehicle.h | 2 |
5 files changed, 69 insertions, 24 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 6fac4ec1..d0157c44 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -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; diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index e6a82288..d1275dd2 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -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; } diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index aa85942d..bb9d694c 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -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; int16 m_doingBurnout; float m_fTireTemperature; diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 764e49cc..ad8bc4d5 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -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()); diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index b3a36c6d..bc14bc77 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -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); |