Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immortal mode + refactoring #539

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions A-4E-C/ExternalFM/FM/Airframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,20 @@ class Airframe : public BaseComponent
setDamageDelta( Airframe::Damage::WING_L_OUT, 1.0 );
setDamageDelta( Airframe::Damage::AILERON_L, 1.0 );
}
inline void setNoDamage(bool state)
{
m_noDamage = state;
}
inline bool getNoDamage()
{
return m_noDamage;
}

private:

//No damage mode
bool m_noDamage = false;

//Airframe Constants
const double m_hookExtendTime = 1.5;

Expand Down
33 changes: 19 additions & 14 deletions A-4E-C/ExternalFM/FM/FuelSystem2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,24 @@ bool FuelSystem2::handleInput( int command, float value )

return true;
case DEVICE_COMMANDS_ENGINE_DROP_TANKS_SW:
m_externalTankPressure = true;
m_externalTankFlightRefuel = false;

if ( value == 1.0 )
if ( value == 1.0 ) // Off
{
m_externalTankPressure = false;
else if ( value == -1.0 )
m_externalTankFlightRefuel = false;
}
else if ( value == -1.0 ) // Flight refuel
{
m_externalTankFlightRefuel = true;
m_externalTankPressure = false;
m_externalTankFlightRefuel = true;
}
else // Press
{
m_externalTankPressure = true;
m_externalTankFlightRefuel = false;
}

return true;

case DEVICE_COMMANDS_FUEL_TRANSFER_BYPASS:
if ( value == 1.0 )
m_wingTankBypass = true;
Expand All @@ -86,7 +92,8 @@ void FuelSystem2::addFuel( double dm, bool wingFirst )
if ( dm > 0.0 && ! wingFirst )
dm = addFuelToTank( TANK_FUSELAGE, dm );

printf( "dm after fuse: %lf\n", dm );
//printf( "dm after fuse: %lf\n", dm );

//If the wing tank bypass switch is enabled we
//refuel the external tanks instead.
if ( m_externalTankFlightRefuel )
Expand All @@ -97,11 +104,9 @@ void FuelSystem2::addFuel( double dm, bool wingFirst )
externalTanks += m_fuelCapacity[i] > 15.0;
}

double fracDM = dm / (double)externalTanks;


if ( externalTanks > 0 )
{
double fracDM = dm / (double)externalTanks;
dm = 0.0;

for ( int i = TANK_EXTERNAL_LEFT; i < NUMBER_OF_TANKS; i++ )
Expand All @@ -112,25 +117,25 @@ void FuelSystem2::addFuel( double dm, bool wingFirst )
}
}

printf( "dm after ext: %lf\n", dm );
//printf( "dm after ext: %lf\n", dm );

if ( ! m_wingTankBypass ) //Bypass is not enabled so refuel the wing tank.
{
dm = addFuelToTank( TANK_WING, dm );
}

printf( "dm after wing: %lf\n", dm );
//printf( "dm after wing: %lf\n", dm );

//If removing fuel remove it from the wing tanks first.
if ( dm < 0.0 || wingFirst )
dm = addFuelToTank( TANK_FUSELAGE, dm );

printf( "dm after fuse/all: %lf\n", dm );
//printf( "dm after fuse/all: %lf\n", dm );
}

void FuelSystem2::update( double dt )
{
if(m_unlimited_fuel)
if(m_unlimitedFuel)
{
m_boostPumpPressure = true; //Cut the Fuel Boost light
return;
Expand Down
4 changes: 2 additions & 2 deletions A-4E-C/ExternalFM/FM/FuelSystem2.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FuelSystem2 : public BaseComponent
inline void setTankPos( Tank tank, const Vec3& pos ) { m_fuelPos[tank] = pos; }

private:
bool m_unlimited_fuel = false;
bool m_unlimitedFuel = false;

double m_fuel[NUMBER_OF_TANKS] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
double m_fuelPrevious[NUMBER_OF_TANKS] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
Expand Down Expand Up @@ -115,7 +115,7 @@ class FuelSystem2 : public BaseComponent

void FuelSystem2::setUnlimitedFuel( bool state )
{
m_unlimited_fuel = state;
m_unlimitedFuel = state;
}

void FuelSystem2::setBoostPumpPower( bool power )
Expand Down
7 changes: 4 additions & 3 deletions A-4E-C/ExternalFM/FM/Scooter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@ void ed_fm_set_current_state_body_axis

void ed_fm_on_damage( int element, double element_integrity_factor )
{
s_airframe->setIntegrityElement((Scooter::Airframe::Damage)element, (float)element_integrity_factor);
if (s_airframe->getNoDamage() == false){
s_airframe->setIntegrityElement((Scooter::Airframe::Damage)element, (float)element_integrity_factor);
}
}

void ed_fm_set_surface
Expand Down Expand Up @@ -1259,8 +1261,7 @@ bool ed_fm_LERX_vortex_update( unsigned idx, LERX_vortex& out )

void ed_fm_set_immortal( bool value )
{
if ( value )
printf( "Nice try!\n" );
s_airframe->setNoDamage(value);
}

void ed_fm_unlimited_fuel( bool value )
Expand Down