From db0758690e78f8df8304adab345958ce5cf496ed Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Wed, 30 Sep 2020 13:37:43 +0300 Subject: new implementation for car fly enhancment --- src/vehicles/Vehicle.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/vehicles/Vehicle.cpp') diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 2e790e81..d53f3c9f 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -351,14 +351,25 @@ CVehicle::FlyingControl(eFlightModel flightModel) fSteerUD *= -fSteerMult; // thrust + float fHandlingThrust = pFlyingHandling->fThrust; + float fThrustFallOff = pFlyingHandling->fThrustFallOff; + float fThrustFallOffBack = pFlyingHandling->fThrustFallOff * 8.0f; +#ifdef ALT_DODO_CHEAT + if (bAltDodoCheat && !IsRealPlane()) { + fHandlingThrust = pHandling->Transmission.fEngineAcceleration; + fHandlingThrust *= pHandling->Transmission.nDriveType == '4' ? 4 : 2; + fThrustFallOff = 0.7f / pHandling->Transmission.fMaxVelocity; + fThrustFallOffBack = 0.7f / pHandling->Transmission.fMaxReverseVelocity; + } +#endif // ALT_DOOD_CHEAT float fForwSpeed = DotProduct(GetMoveSpeed(), GetForward()); CVector vecTail = GetColModel()->boundingBox.min.y * GetForward(); float fThrust = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f; float fThrustAccel; if(fForwSpeed > 0.0f || fThrust > 0.0f) - fThrustAccel = (fThrust - pFlyingHandling->fThrustFallOff * fForwSpeed) * pFlyingHandling->fThrust; + fThrustAccel = (fThrust - fThrustFallOff * fForwSpeed) * fHandlingThrust; else - fThrustAccel = Min(fThrust - 8.0f * pFlyingHandling->fThrustFallOff * fForwSpeed, 0.0f) * pFlyingHandling->fThrust; + fThrustAccel = Min(fThrust - fThrustFallOffBack * fForwSpeed, 0.0f) * fHandlingThrust; if(flightModel == FLIGHT_MODEL_PLANE_UNUSED) fThrustAccel *= 0.3f; else if(flightModel == FLIGHT_MODEL_PLANE) -- cgit v1.2.3 From fe46aa5cc25d52ec434860d4ee72fbb1347adbe9 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Thu, 1 Oct 2020 02:20:09 +0300 Subject: better flying cars, some refractoring and fixes --- src/vehicles/Vehicle.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/vehicles/Vehicle.cpp') diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index d53f3c9f..82bdcdda 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -41,7 +41,7 @@ bool CVehicle::bCheat3; bool CVehicle::bCheat4; bool CVehicle::bCheat5; bool CVehicle::bCheat8; -#ifdef ALT_DODO_CHEAT +#ifdef BETTER_ALLCARSAREDODO_CHEAT bool CVehicle::bAltDodoCheat; #endif bool CVehicle::bHoverCheat; @@ -351,25 +351,26 @@ CVehicle::FlyingControl(eFlightModel flightModel) fSteerUD *= -fSteerMult; // thrust - float fHandlingThrust = pFlyingHandling->fThrust; + float fThrust = pFlyingHandling->fThrust; float fThrustFallOff = pFlyingHandling->fThrustFallOff; float fThrustFallOffBack = pFlyingHandling->fThrustFallOff * 8.0f; -#ifdef ALT_DODO_CHEAT +#ifdef BETTER_ALLCARSAREDODO_CHEAT if (bAltDodoCheat && !IsRealPlane()) { - fHandlingThrust = pHandling->Transmission.fEngineAcceleration; - fHandlingThrust *= pHandling->Transmission.nDriveType == '4' ? 4 : 2; - fThrustFallOff = 0.7f / pHandling->Transmission.fMaxVelocity; - fThrustFallOffBack = 0.7f / pHandling->Transmission.fMaxReverseVelocity; + fThrust = pHandling->Transmission.fEngineAcceleration + * pHandling->Transmission.nDriveType == '4' ? 4.0f : 2.0f; + fThrust = 5.0f * Max(fThrust, pFlyingHandling->fThrust); + fThrustFallOff = Min(1.0f / pHandling->Transmission.fMaxVelocity, fThrustFallOff); + fThrustFallOffBack = -1.0f / pHandling->Transmission.fMaxReverseVelocity; } -#endif // ALT_DOOD_CHEAT +#endif float fForwSpeed = DotProduct(GetMoveSpeed(), GetForward()); CVector vecTail = GetColModel()->boundingBox.min.y * GetForward(); - float fThrust = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f; + float fPedalState = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f; float fThrustAccel; - if(fForwSpeed > 0.0f || fThrust > 0.0f) - fThrustAccel = (fThrust - fThrustFallOff * fForwSpeed) * fHandlingThrust; + if(fForwSpeed > 0.0f || fPedalState > 0.0f) + fThrustAccel = (fPedalState - fThrustFallOff * fForwSpeed) * fThrust; else - fThrustAccel = Min(fThrust - fThrustFallOffBack * fForwSpeed, 0.0f) * fHandlingThrust; + fThrustAccel = Min(fPedalState - fThrustFallOffBack * fForwSpeed, 0.0f) * fThrust; if(flightModel == FLIGHT_MODEL_PLANE_UNUSED) fThrustAccel *= 0.3f; else if(flightModel == FLIGHT_MODEL_PLANE) @@ -407,14 +408,18 @@ CVehicle::FlyingControl(eFlightModel flightModel) float fPitchAccel = pFlyingHandling->fPitchStab * fTail * Abs(fTail) + pFlyingHandling->fPitch * fSteerUD * fForwSpeed; ApplyTurnForce(fPitchAccel * m_fTurnMass * GetUp() * CTimer::GetTimeStep(), vecTail); - float fLift = -DotProduct(GetMoveSpeed(), GetUp()) / Max(0.01f, GetMoveSpeed().Magnitude()); - float fLiftAccel = (pFlyingHandling->fAttackLift * fLift + pFlyingHandling->fFormLift) * fForwSpeed * fForwSpeed; + float fLift = DotProduct(GetMoveSpeed(), GetUp()) / Max(0.01f, GetMoveSpeed().Magnitude()); //accel*angle + float fLiftAccel = (pFlyingHandling->fFormLift - pFlyingHandling->fAttackLift * fLift) * SQR(fForwSpeed); float fLiftImpulse = fLiftAccel * m_fMass * CTimer::GetTimeStep(); if (GRAVITY * CTimer::GetTimeStep() * m_fMass < fLiftImpulse) { if (flightModel == FLIGHT_MODEL_RCPLANE && GetPosition().z > 50.0f) fLiftImpulse = CTimer::GetTimeStep() * 0.9f*GRAVITY * m_fMass; else if (flightModel == FLIGHT_MODEL_SEAPLANE && GetPosition().z > 80.0f) fLiftImpulse = CTimer::GetTimeStep() * 0.9f*GRAVITY * m_fMass; +#ifdef BETTER_ALLCARSAREDODO_CHEAT + else if(GetPosition().z > 180.0f) + fLiftImpulse = CTimer::GetTimeStep() * 0.9f * GRAVITY * m_fMass; +#endif } ApplyMoveForce(fLiftImpulse * GetUp()); @@ -444,7 +449,7 @@ CVehicle::FlyingControl(eFlightModel flightModel) case FLIGHT_MODEL_HELI: { #ifdef RESTORE_ALLCARSHELI_CHEAT - tFlyingHandlingData* flyingHandling = bAllCarCheat && GetStatus() == STATUS_PLAYER && !IsRealHeli() ? mod_HandlingManager.GetFlyingPointer(HANDLING_MAVERICK) : pFlyingHandling; + tFlyingHandlingData* flyingHandling = bAllCarCheat && !IsRealHeli() ? mod_HandlingManager.GetFlyingPointer(HANDLING_MAVERICK) : pFlyingHandling; #else tFlyingHandlingData* flyingHandling = pFlyingHandling; #endif -- cgit v1.2.3 From 049c993ce01570fd6aae8166b6622a81f343ef2e Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Thu, 1 Oct 2020 02:45:24 +0300 Subject: fix ternary operator --- src/vehicles/Vehicle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/vehicles/Vehicle.cpp') diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 82bdcdda..3ff9a044 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -357,7 +357,7 @@ CVehicle::FlyingControl(eFlightModel flightModel) #ifdef BETTER_ALLCARSAREDODO_CHEAT if (bAltDodoCheat && !IsRealPlane()) { fThrust = pHandling->Transmission.fEngineAcceleration - * pHandling->Transmission.nDriveType == '4' ? 4.0f : 2.0f; + * (pHandling->Transmission.nDriveType == '4' ? 4.0f : 2.0f); fThrust = 5.0f * Max(fThrust, pFlyingHandling->fThrust); fThrustFallOff = Min(1.0f / pHandling->Transmission.fMaxVelocity, fThrustFallOff); fThrustFallOffBack = -1.0f / pHandling->Transmission.fMaxReverseVelocity; -- cgit v1.2.3 From 063a80ecfb3ccede8b2e5efc135abd2c48f285d2 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 3 Oct 2020 02:26:49 +0300 Subject: now BETTER_ALLCARSDODO_CHEAT tweak original cheat to be useful. --- src/vehicles/Vehicle.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/vehicles/Vehicle.cpp') diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 3ff9a044..4347c9b2 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -41,9 +41,6 @@ bool CVehicle::bCheat3; bool CVehicle::bCheat4; bool CVehicle::bCheat5; bool CVehicle::bCheat8; -#ifdef BETTER_ALLCARSAREDODO_CHEAT -bool CVehicle::bAltDodoCheat; -#endif bool CVehicle::bHoverCheat; bool CVehicle::bAllTaxisHaveNitro; bool CVehicle::m_bDisableMouseSteering = true; @@ -355,11 +352,11 @@ CVehicle::FlyingControl(eFlightModel flightModel) float fThrustFallOff = pFlyingHandling->fThrustFallOff; float fThrustFallOffBack = pFlyingHandling->fThrustFallOff * 8.0f; #ifdef BETTER_ALLCARSAREDODO_CHEAT - if (bAltDodoCheat && !IsRealPlane()) { + if (bAllDodosCheat && !IsRealPlane()) { fThrust = pHandling->Transmission.fEngineAcceleration * (pHandling->Transmission.nDriveType == '4' ? 4.0f : 2.0f); - fThrust = 5.0f * Max(fThrust, pFlyingHandling->fThrust); - fThrustFallOff = Min(1.0f / pHandling->Transmission.fMaxVelocity, fThrustFallOff); + fThrust = 5.0f * Max(fThrust, pFlyingHandling->fThrust); //tweak: (cars engines too weak to thrust car on air) + fThrustFallOff = Min(0.7f / pHandling->Transmission.fMaxVelocity, fThrustFallOff); //tweak: (use 0.7 instead of 1.0 to make cars 30% faster) fThrustFallOffBack = -1.0f / pHandling->Transmission.fMaxReverseVelocity; } #endif @@ -417,7 +414,7 @@ CVehicle::FlyingControl(eFlightModel flightModel) else if (flightModel == FLIGHT_MODEL_SEAPLANE && GetPosition().z > 80.0f) fLiftImpulse = CTimer::GetTimeStep() * 0.9f*GRAVITY * m_fMass; #ifdef BETTER_ALLCARSAREDODO_CHEAT - else if(GetPosition().z > 180.0f) + else if(bAllDodosCheat && GetPosition().z > 170.0f) fLiftImpulse = CTimer::GetTimeStep() * 0.9f * GRAVITY * m_fMass; #endif } -- cgit v1.2.3