mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Started air fighter AI
This commit is contained in:
@@ -8,7 +8,7 @@ namespace CommandPriority {
|
||||
};
|
||||
|
||||
namespace CommandType {
|
||||
enum CommandTypes { NO_TYPE, MOVE, SMOKE, LASE, EXPLODE, SPAWN_AIR, SPAWN_GROUND };
|
||||
enum CommandTypes { NO_TYPE, MOVE, SMOKE, LASE, EXPLODE, SPAWN_AIR, SPAWN_GROUND, ATTACK_UNIT };
|
||||
};
|
||||
|
||||
/* Base command class */
|
||||
@@ -102,4 +102,24 @@ private:
|
||||
const wstring coalition;
|
||||
const wstring unitType;
|
||||
const Coords location;
|
||||
};
|
||||
|
||||
/* Attack unit command */
|
||||
class AttackUnitCommand : public Command
|
||||
{
|
||||
public:
|
||||
AttackUnitCommand(wstring unitName, wstring targetName, Coords location) :
|
||||
unitName(unitName),
|
||||
targetName(targetName),
|
||||
location(location)
|
||||
{
|
||||
priority = CommandPriority::MEDIUM;
|
||||
type = CommandType::ATTACK_UNIT;
|
||||
};
|
||||
virtual void execute(lua_State* L);
|
||||
|
||||
private:
|
||||
const wstring unitName;
|
||||
const wstring targetName;
|
||||
const Coords location;
|
||||
};
|
||||
@@ -15,6 +15,6 @@ public:
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
mutex lock;
|
||||
mutex mutexLock;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "dcstools.h"
|
||||
#include "luatools.h"
|
||||
|
||||
#define GROUND_DEST_DIST_THR 100
|
||||
#define AIR_DEST_DIST_THR 2000
|
||||
|
||||
namespace UnitCategory {
|
||||
enum UnitCategories { NO_CATEGORY, AIR, GROUND, NAVY }; // Do not edit, this codes are tied to values in DCS
|
||||
};
|
||||
@@ -30,12 +33,15 @@ public:
|
||||
double getLongitude() { return longitude; }
|
||||
double getAltitude() { return altitude; }
|
||||
double getHeading() { return heading; }
|
||||
json::value getFlags() { return flags; }
|
||||
int getCategory();
|
||||
Coords getActiveDestination() { return activeDestination; }
|
||||
|
||||
json::value json();
|
||||
|
||||
protected:
|
||||
int ID;
|
||||
bool AI = false;
|
||||
bool alive = true;
|
||||
wstring name = L"undefined";
|
||||
wstring unitName = L"undefined";
|
||||
@@ -47,11 +53,15 @@ protected:
|
||||
double longitude = 0;
|
||||
double altitude = 0;
|
||||
double heading = 0;
|
||||
json::value flags = json::value::null();
|
||||
|
||||
list<Coords> activePath;
|
||||
Coords activeDestination;
|
||||
Coords activeDestination = Coords(0);
|
||||
|
||||
private:
|
||||
virtual void AIloop();
|
||||
|
||||
double oldDist = 0;
|
||||
mutex mutexLock;
|
||||
};
|
||||
|
||||
|
||||
4
src/core/include/scriptLoader.h
Normal file
4
src/core/include/scriptLoader.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
void registerLuaFunctions(lua_State* L);
|
||||
29
src/core/include/server.h
Normal file
29
src/core/include/server.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "luatools.h"
|
||||
|
||||
using namespace web::http;
|
||||
using namespace web::http::experimental::listener;
|
||||
|
||||
class UnitsFactory;
|
||||
class Scheduler;
|
||||
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
Server(lua_State* L);
|
||||
~Server();
|
||||
|
||||
private:
|
||||
std::thread* serverThread;
|
||||
|
||||
void handle_options(http_request request);
|
||||
void handle_get(http_request request);
|
||||
void handle_request(http_request request, function<void(json::value const&, json::value&)> action);
|
||||
void handle_put(http_request request);
|
||||
|
||||
void task();
|
||||
|
||||
atomic<bool> runListener;
|
||||
};
|
||||
|
||||
23
src/core/include/unitsFactory.h
Normal file
23
src/core/include/unitsFactory.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "dcstools.h"
|
||||
|
||||
class Unit;
|
||||
|
||||
class UnitsFactory
|
||||
{
|
||||
public:
|
||||
UnitsFactory(lua_State* L);
|
||||
~UnitsFactory();
|
||||
|
||||
Unit* getUnit(int ID);
|
||||
void getMissionDB(lua_State* L);
|
||||
void update(lua_State* L);
|
||||
void updateAnswer(json::value& answer);
|
||||
|
||||
private:
|
||||
map<int, Unit*> units;
|
||||
json::value missionDB;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user