mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
feat: added airborne variable
This commit is contained in:
@@ -67,6 +67,7 @@ namespace DataIndex {
|
||||
targetingRange,
|
||||
aimMethodRange,
|
||||
acquisitionRange,
|
||||
airborne,
|
||||
lastIndex,
|
||||
endOfData = 255
|
||||
};
|
||||
|
||||
@@ -127,6 +127,7 @@ public:
|
||||
virtual void setAimMethodRange(double newValue) { updateValue(aimMethodRange, newValue, DataIndex::aimMethodRange); }
|
||||
virtual void setAcquisitionRange(double newValue) { updateValue(acquisitionRange, newValue, DataIndex::acquisitionRange); }
|
||||
virtual void setRadarState(bool newValue) { updateValue(radarState, newValue, DataIndex::radarState); }
|
||||
virtual void setAirborne(bool newValue) { updateValue(airborne, newValue, DataIndex::airborne); }
|
||||
|
||||
/********** Getters **********/
|
||||
virtual string getCategory() { return category; };
|
||||
@@ -191,6 +192,7 @@ public:
|
||||
virtual double getAimMethodRange() { return aimMethodRange; }
|
||||
virtual double getAcquisitionRange() { return acquisitionRange; }
|
||||
virtual bool getRadarState() { return radarState; }
|
||||
virtual bool getAirborne() { return airborne; }
|
||||
|
||||
protected:
|
||||
unsigned int ID;
|
||||
@@ -258,6 +260,7 @@ protected:
|
||||
double targetingRange = 0;
|
||||
double aimMethodRange = 0;
|
||||
double acquisitionRange = 0;
|
||||
bool airborne = false;
|
||||
|
||||
/********** Other **********/
|
||||
unsigned int taskCheckCounter = 0;
|
||||
|
||||
@@ -373,7 +373,7 @@ void GroundUnit::AIloop()
|
||||
lat = position.lat + RANDOM_MINUS_ONE_TO_ONE * (1 + (ShotsScatter::LOW - shotsScatter)) * 0.01;
|
||||
lng = position.lng + RANDOM_MINUS_ONE_TO_ONE * (1 + (ShotsScatter::LOW - shotsScatter)) * 0.01;
|
||||
barrelElevation = target->getPosition().alt + RANDOM_MINUS_ONE_TO_ONE * (ShotsScatter::LOW - shotsScatter) * 1000;
|
||||
taskString += "Flak box mode.";
|
||||
taskString += "Flak box mode";
|
||||
}
|
||||
else {
|
||||
taskString += "Scenic AAA. Bearing: " + to_string((int)round(randomBearing)) + "deg";
|
||||
|
||||
@@ -148,6 +148,9 @@ void Unit::update(json::value json, double dt)
|
||||
if (json.has_number_field(L"health"))
|
||||
setHealth(static_cast<unsigned char>(json[L"health"].as_number().to_uint32()));
|
||||
|
||||
if (json.has_boolean_field(L"airborne"))
|
||||
setAirborne(json[L"airborne"].as_bool());
|
||||
|
||||
runAILoop();
|
||||
}
|
||||
|
||||
@@ -304,7 +307,7 @@ void Unit::getData(stringstream& ss, unsigned long long time)
|
||||
case DataIndex::racetrackLength: appendNumeric(ss, datumIndex, racetrackLength); break;
|
||||
case DataIndex::racetrackAnchor: appendNumeric(ss, datumIndex, racetrackAnchor); break;
|
||||
case DataIndex::racetrackBearing: appendNumeric(ss, datumIndex, racetrackBearing); break;
|
||||
case DataIndex::timeToNextTasking: appendNumeric(ss, datumIndex, timeToNextTasking); break;
|
||||
//case DataIndex::timeToNextTasking: appendNumeric(ss, datumIndex, timeToNextTasking); break; Useful for debugging, but useless in production and very data hungry
|
||||
case DataIndex::barrelHeight: appendNumeric(ss, datumIndex, barrelHeight); break;
|
||||
case DataIndex::muzzleVelocity: appendNumeric(ss, datumIndex, muzzleVelocity); break;
|
||||
case DataIndex::aimTime: appendNumeric(ss, datumIndex, aimTime); break;
|
||||
@@ -315,6 +318,7 @@ void Unit::getData(stringstream& ss, unsigned long long time)
|
||||
case DataIndex::targetingRange: appendNumeric(ss, datumIndex, targetingRange); break;
|
||||
case DataIndex::aimMethodRange: appendNumeric(ss, datumIndex, aimMethodRange); break;
|
||||
case DataIndex::acquisitionRange: appendNumeric(ss, datumIndex, acquisitionRange); break;
|
||||
case DataIndex::airborne: appendNumeric(ss, datumIndex, airborne); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,6 +513,7 @@ export enum DataIndexes {
|
||||
targetingRange,
|
||||
aimMethodRange,
|
||||
acquisitionRange,
|
||||
airborne,
|
||||
endOfData = 255,
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +283,7 @@ export interface UnitData {
|
||||
targetingRange: number;
|
||||
aimMethodRange: number;
|
||||
acquisitionRange: number;
|
||||
airborne: boolean;
|
||||
}
|
||||
|
||||
export interface LoadoutItemBlueprint {
|
||||
|
||||
@@ -2269,11 +2269,13 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
|
||||
</div>
|
||||
|
||||
<div className="my-auto text-sm text-gray-400">{selectedUnits[0].getTask()}</div>
|
||||
{([UnitState.SIMULATE_FIRE_FIGHT, UnitState.MISS_ON_PURPOSE, UnitState.SCENIC_AAA] as string[]).includes(selectedUnits[0].getState()) && (
|
||||
{/* Useful for debugging but very data hungry
|
||||
|
||||
([UnitState.SIMULATE_FIRE_FIGHT, UnitState.MISS_ON_PURPOSE, UnitState.SCENIC_AAA] as string[]).includes(selectedUnits[0].getState()) && (
|
||||
<div className="my-auto text-sm text-gray-400">
|
||||
Time to next tasking: {zeroAppend(selectedUnits[0].getTimeToNextTasking(), 0, true, 2)}s
|
||||
</div>
|
||||
)}
|
||||
)*/}
|
||||
|
||||
<div className="flex content-center gap-2">
|
||||
<OlLocation
|
||||
|
||||
@@ -154,6 +154,7 @@ export abstract class Unit extends CustomMarker {
|
||||
#racetrackLength: number = 0;
|
||||
#racetrackAnchor: LatLng = new LatLng(0, 0);
|
||||
#racetrackBearing: number = 0;
|
||||
#airborne: boolean = false;
|
||||
|
||||
/* Other members used to draw the unit, mostly ancillary stuff like targets, ranges and so on */
|
||||
#blueprint: UnitBlueprint | null = null;
|
||||
@@ -391,6 +392,9 @@ export abstract class Unit extends CustomMarker {
|
||||
getAcquisitionRange() {
|
||||
return this.#acquisitionRange;
|
||||
}
|
||||
getAirborne() {
|
||||
return this.#airborne;
|
||||
}
|
||||
|
||||
static getConstructor(type: string) {
|
||||
if (type === "GroundUnit") return GroundUnit;
|
||||
@@ -754,6 +758,9 @@ export abstract class Unit extends CustomMarker {
|
||||
case DataIndexes.acquisitionRange:
|
||||
this.#acquisitionRange = dataExtractor.extractFloat64();
|
||||
break;
|
||||
case DataIndexes.airborne:
|
||||
this.#airborne = dataExtractor.extractBool();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -874,6 +881,7 @@ export abstract class Unit extends CustomMarker {
|
||||
targetingRange: this.#targetingRange,
|
||||
aimMethodRange: this.#aimMethodRange,
|
||||
acquisitionRange: this.#acquisitionRange,
|
||||
airborne: this.#airborne
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1236,6 +1236,7 @@ function Olympus.setUnitsData(arg, time)
|
||||
local position = unit:getPosition()
|
||||
local heading = math.atan2( position.x.z, position.x.x )
|
||||
local velocity = unit:getVelocity();
|
||||
local airborne = unit:inAir()
|
||||
|
||||
-- Fill the data table
|
||||
table["name"] = unit:getTypeName()
|
||||
@@ -1248,6 +1249,7 @@ function Olympus.setUnitsData(arg, time)
|
||||
table["horizontalVelocity"] = math.sqrt(velocity.x * velocity.x + velocity.z * velocity.z)
|
||||
table["verticalVelocity"] = velocity.y
|
||||
table["heading"] = heading
|
||||
table["airborne"] = airborne
|
||||
|
||||
-- Track angles are wrong because of weird reference systems, approximate it using latitude and longitude differences
|
||||
if (table["horizontalVelocity"] > 1) then
|
||||
|
||||
Reference in New Issue
Block a user