better flying cars, some refractoring and fixes

This commit is contained in:
Roman Masanin 2020-10-01 02:20:09 +03:00
parent db0758690e
commit fe46aa5cc2
6 changed files with 47 additions and 33 deletions

View File

@ -733,6 +733,9 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_Driving(int32
FindPlayerVehicle()->GetModelIndex() == MI_DODO
#ifdef FIX_BUGS
|| (CVehicle::bAllDodosCheat && !FindPlayerVehicle()->IsRealHeli())
#endif
#ifdef BETTER_ALLCARSAREDODO_CHEAT
|| (CVehicle::bAltDodoCheat && !FindPlayerVehicle()->IsRealHeli())
#endif
)))
{

View File

@ -542,8 +542,8 @@ void AllCarsHeliCheat(void)
}
#endif
#ifdef ALT_DODO_CHEAT
void AltDodoCheat(void)
#ifdef BETTER_ALLCARSAREDODO_CHEAT
void AllCarsPlaneCheat(void)
{
wchar* string;
if (CVehicle::bAltDodoCheat) {
@ -1444,10 +1444,10 @@ void CPad::AddToPCCheatString(char c)
AllCarsHeliCheat();
#endif
#ifdef ALT_DODO_CHEAT
// "IWANTTOMASTERDODO"
if (!_CHEATCMP("ODODRETSAMOTTNAWI"))
AltDodoCheat();
#ifdef BETTER_ALLCARSAREDODO_CHEAT
// "CARSAREPLANE"
if (!_CHEATCMP("ENALPERASRAC"))
AllCarsPlaneCheat();
#endif
#ifdef WALLCLIMB_CHEAT
@ -3166,6 +3166,14 @@ void CPad::ResetCheats(void)
CVehicle::bCheat4 = false;
CVehicle::bCheat5 = false;
CVehicle::bCheat8 = false;
#ifdef RESTORE_ALLCARSHELI_CHEAT
bAllCarCheat = false;
#endif
#ifdef BETTER_ALLCARSAREDODO_CHEAT
CVehicle::bAltDodoCheat = false;
#endif
gbBlackCars = false;
gbPinkCars = false;
CCarCtrl::bMadDriversCheat = false;

View File

@ -251,7 +251,7 @@ enum Config {
#define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m
#define KANGAROO_CHEAT
#define RESTORE_ALLCARSHELI_CHEAT
#define ALT_DODO_CHEAT
#define BETTER_ALLCARSAREDODO_CHEAT
#define WALLCLIMB_CHEAT
#define REGISTER_START_BUTTON
//#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls

View File

@ -1375,6 +1375,13 @@ CAutomobile::ProcessControl(void)
// Flying
bool playRotorSound = false;
bool isPlane = GetModelIndex() == MI_DODO || bAllDodosCheat;
#ifdef BETTER_ALLCARSAREDODO_CHEAT
isPlane = isPlane || bAltDodoCheat;
#endif
#ifdef FIX_BUGS
isPlane = isPlane && !IsRealHeli();
#endif
if(GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PHYSICS){
if(IsRealHeli()){
bEngineOn = false;
@ -1383,16 +1390,7 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[1] < 0.154f && m_aWheelSpeed[1] > 0.0044f)
playRotorSound = true;
}
}else if((GetModelIndex() == MI_DODO || CVehicle::bAllDodosCheat) &&
#ifdef FIX_BUGS
!IsRealHeli() &&
#endif
m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){
#ifdef ALT_DODO_CHEAT
if (bAltDodoCheat)
FlyingControl(FLIGHT_MODEL_PLANE_UNUSED);
else
#endif
}else if(isPlane && m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){
if(GetModelIndex() == MI_DODO)
FlyingControl(FLIGHT_MODEL_DODO);
else

View File

@ -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

View File

@ -400,7 +400,7 @@ public:
static bool bCheat4;
static bool bCheat5;
static bool bCheat8;
#ifdef ALT_DODO_CHEAT
#ifdef BETTER_ALLCARSAREDODO_CHEAT
static bool bAltDodoCheat;
#endif
static bool bHoverCheat;