mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Fixed change altitude and speed for helicopters
This commit is contained in:
parent
62142ed976
commit
71cf7c67f7
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "airunit.h"
|
||||
|
||||
#define AIRCRAFT_DEST_DIST_THR 2000 // Meters
|
||||
|
||||
class Aircraft : public AirUnit
|
||||
{
|
||||
public:
|
||||
@ -11,6 +13,8 @@ public:
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void changeAltitude(string change);
|
||||
|
||||
virtual double getDestinationReachedThreshold() { return AIRCRAFT_DEST_DIST_THR; }
|
||||
|
||||
protected:
|
||||
static json::value database;
|
||||
};
|
||||
@ -17,6 +17,7 @@ public:
|
||||
|
||||
virtual void changeSpeed(string change) = 0;
|
||||
virtual void changeAltitude(string change) = 0;
|
||||
virtual double getDestinationReachedThreshold() { return AIR_DEST_DIST_THR; }
|
||||
|
||||
protected:
|
||||
virtual void AIloop();
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "airunit.h"
|
||||
|
||||
#define HELICOPTER_DEST_DIST_THR 500 // Meters
|
||||
|
||||
class Helicopter : public AirUnit
|
||||
{
|
||||
public:
|
||||
@ -11,6 +13,8 @@ public:
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void changeAltitude(string change);
|
||||
|
||||
virtual double getDestinationReachedThreshold() { return HELICOPTER_DEST_DIST_THR; }
|
||||
|
||||
protected:
|
||||
static json::value database;
|
||||
};
|
||||
@ -221,7 +221,7 @@ void AirUnit::AIloop()
|
||||
goToDestination(enrouteTask);
|
||||
}
|
||||
else {
|
||||
if (isDestinationReached(AIR_DEST_DIST_THR)) {
|
||||
if (isDestinationReached(getDestinationReachedThreshold())) {
|
||||
if (updateActivePath(looping) && setActiveDestination())
|
||||
goToDestination(enrouteTask);
|
||||
else
|
||||
|
||||
@ -41,33 +41,28 @@ void Helicopter::changeSpeed(string change)
|
||||
if (change.compare("stop") == 0)
|
||||
setState(State::IDLE);
|
||||
else if (change.compare("slow") == 0)
|
||||
desiredSpeed -= knotsToMs(10);
|
||||
setDesiredSpeed(getDesiredSpeed() - knotsToMs(10));
|
||||
else if (change.compare("fast") == 0)
|
||||
desiredSpeed += knotsToMs(10);
|
||||
if (desiredSpeed < 0)
|
||||
desiredSpeed = 0;
|
||||
|
||||
goToDestination(); /* Send the command to reach the destination */
|
||||
setDesiredSpeed(getDesiredSpeed() + knotsToMs(10));
|
||||
}
|
||||
|
||||
void Helicopter::changeAltitude(string change)
|
||||
{
|
||||
if (change.compare("descend") == 0)
|
||||
{
|
||||
if (desiredAltitude > 100)
|
||||
desiredAltitude -= ftToM(100);
|
||||
else if (desiredAltitude > 0)
|
||||
desiredAltitude -= ftToM(10);
|
||||
if (getDesiredAltitude() > 100)
|
||||
setDesiredAltitude(getDesiredAltitude() - ftToM(100));
|
||||
else if (getDesiredAltitude() > 0)
|
||||
setDesiredAltitude(getDesiredAltitude() - ftToM(10));
|
||||
}
|
||||
else if (change.compare("climb") == 0)
|
||||
{
|
||||
if (desiredAltitude > 100)
|
||||
desiredAltitude += ftToM(100);
|
||||
else if (desiredAltitude >= 0)
|
||||
desiredAltitude += ftToM(10);
|
||||
if (getDesiredAltitude() > 100)
|
||||
setDesiredAltitude(getDesiredAltitude() + ftToM(100));
|
||||
else if (getDesiredAltitude() >= 0)
|
||||
setDesiredAltitude(getDesiredAltitude() + ftToM(10));
|
||||
}
|
||||
if (desiredAltitude < 0)
|
||||
desiredAltitude = 0;
|
||||
|
||||
goToDestination(); /* Send the command to reach the destination */
|
||||
}
|
||||
if (getDesiredAltitude() < 0)
|
||||
setDesiredAltitude(0);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user