Added speed and altitude controls

Fixed Clone
Added "Land here" command
Added ROE and reaction to threat buttons
This commit is contained in:
Pax1601
2023-02-08 18:26:45 +01:00
parent 3cf133a10e
commit 30a9d4e730
27 changed files with 852 additions and 102 deletions

View File

@@ -11,6 +11,54 @@ namespace CommandType {
enum CommandTypes { NO_TYPE, MOVE, SMOKE, SPAWN_AIR, SPAWN_GROUND, CLONE, FOLLOW, RESET_TASK, SET_OPTION, SET_COMMAND, SET_TASK };
};
namespace SetCommandType {
enum SetCommandTypes {
ROE = 0,
REACTION_ON_THREAT = 1,
RADAR_USING = 3,
FLARE_USING = 4,
Formation = 5,
RTB_ON_BINGO = 6,
SILENCE = 7,
RTB_ON_OUT_OF_AMMO = 10,
ECM_USING = 13,
PROHIBIT_AA = 14,
PROHIBIT_JETT = 15,
PROHIBIT_AB = 16,
PROHIBIT_AG = 17,
MISSILE_ATTACK = 18,
PROHIBIT_WP_PASS_REPORT = 19,
OPTION_RADIO_USAGE_CONTACT = 21,
OPTION_RADIO_USAGE_ENGAGE = 22,
OPTION_RADIO_USAGE_KILL = 23,
JETT_TANKS_IF_EMPTY = 25,
FORCED_ATTACK = 26
};
}
namespace ROE {
enum ROEs {
WEAPON_FREE = 0,
OPEN_FIRE_WEAPON_FREE = 1,
OPEN_FIRE = 2,
RETURN_FIRE = 3,
WEAPON_HOLD = 4,
};
}
namespace ReactionToThreat {
enum ReactionToThreats {
NO_REACTION = 0,
PASSIVE_DEFENCE = 1,
EVADE_FIRE = 2,
BYPASS_AND_ESCAPE = 3,
ALLOW_ABORT_MISSION = 4
};
}
/* Base command class */
class Command
{
@@ -117,14 +165,32 @@ private:
class Clone : public Command
{
public:
Clone(int ID) :
ID(ID)
Clone(int ID, Coords location) :
ID(ID),
location(location)
{
priority = CommandPriority::LOW;
type = CommandType::CLONE;
};
virtual wstring getString(lua_State* L);
private:
const int ID;
const Coords location;
};
/* Delete unit command */
class Delete : public Command
{
public:
Delete(int ID) :
ID(ID)
{
priority = CommandPriority::HIGH;
type = CommandType::CLONE;
};
virtual wstring getString(lua_State* L);
private:
const int ID;
};

View File

@@ -5,7 +5,7 @@
#include "luatools.h"
namespace State {
enum States { IDLE, REACH_DESTINATION, ATTACK, WINGMAN, FOLLOW, RTB, REFUEL, AWACS, EWR, TANKER, RUN_AWAY };
enum States { IDLE, REACH_DESTINATION, ATTACK, WINGMAN, FOLLOW, LAND, REFUEL, AWACS, EWR, TANKER, RUN_AWAY };
};
class Unit
@@ -31,6 +31,9 @@ public:
void setWingmen(vector<Unit*> newWingmen) { wingmen = newWingmen; }
void setFormation(wstring newFormation) { formation = newFormation; }
void setFormationOffset(Offset formationOffset);
void setROE(wstring newROE);
void setReactionToThreat(wstring newReactionToThreat);
void landAt(Coords loc);
int getID() { return ID; }
wstring getName() { return name; }
@@ -65,33 +68,35 @@ public:
protected:
int ID;
int state = State::IDLE;
bool hasTask = false;
bool AI = false;
bool alive = true;
wstring name = L"undefined";
wstring unitName = L"undefined";
wstring groupName = L"undefined";
json::value type = json::value::null();
int country = NULL;
int coalitionID = NULL;
double latitude = NULL;
double longitude = NULL;
double altitude = NULL;
double heading = NULL;
double speed = NULL;
json::value flags = json::value::null();
int targetID = NULL;
wstring currentTask = L"";
bool isLeader = false;
bool isWingman = false;
Offset formationOffset = Offset(NULL);
wstring formation = L"";
Unit* leader = nullptr;
int state = State::IDLE;
bool hasTask = false;
bool AI = false;
bool alive = true;
wstring name = L"undefined";
wstring unitName = L"undefined";
wstring groupName = L"undefined";
json::value type = json::value::null();
int country = NULL;
int coalitionID = NULL;
double latitude = NULL;
double longitude = NULL;
double altitude = NULL;
double heading = NULL;
double speed = NULL;
json::value flags = json::value::null();
int targetID = NULL;
wstring currentTask = L"";
bool isLeader = false;
bool isWingman = false;
Offset formationOffset = Offset(NULL);
wstring formation = L"";
Unit* leader = nullptr;
wstring ROE = L"";
wstring reactionToThreat = L"";
vector<Unit*> wingmen;
double targetSpeed = 0;
double targetAltitude = 0;
double fuel = 0;
double targetSpeed = 0;
double targetAltitude = 0;
double fuel = 0;
json::value ammo;
json::value targets;

View File

@@ -12,8 +12,10 @@ public:
virtual void changeAltitude(wstring change);
virtual double getTargetSpeed() { return targetSpeed; };
virtual double getTargetAltitude() { return targetAltitude; };
virtual void setTargetSpeed(double newTargetSpeed);
virtual void setTargetAltitude(double newTargetAltitude);
protected:
double targetSpeed = 150;
double targetAltitude = 5000;
double targetSpeed = 300 / 1.94384;
double targetAltitude = 20000 * 0.3048;
};

View File

@@ -15,8 +15,8 @@ public:
virtual wstring getCategory() = 0;
virtual void changeSpeed(wstring change) {};
virtual void changeAltitude(wstring change) {};
virtual void setTargetSpeed(double newTargetSpeed);
virtual void setTargetAltitude(double newTargetAltitude);
virtual void setTargetSpeed(double newTargetSpeed) {};
virtual void setTargetAltitude(double newTargetAltitude) {};
protected:
virtual void AIloop();

View File

@@ -12,8 +12,10 @@ public:
virtual void changeAltitude(wstring change);
virtual double getTargetSpeed() { return targetSpeed; };
virtual double getTargetAltitude() { return targetAltitude; };
virtual void setTargetSpeed(double newTargetSpeed);
virtual void setTargetAltitude(double newTargetAltitude);
protected:
double targetSpeed = 50;
double targetAltitude = 1000;
double targetSpeed = 100 / 1.94384;
double targetAltitude = 5000 * 0.3048;
};

View File

@@ -14,6 +14,7 @@ public:
void updateExportData(lua_State* L);
void updateMissionData(json::value missionData);
void updateAnswer(json::value& answer);
void deleteUnit(int ID);
private:
map<int, Unit*> units;