diff --git a/Moose Development/Moose/Wrapper/Weapon.lua b/Moose Development/Moose/Wrapper/Weapon.lua index 7317d53fd..5ba880123 100644 --- a/Moose Development/Moose/Wrapper/Weapon.lua +++ b/Moose Development/Moose/Wrapper/Weapon.lua @@ -223,7 +223,15 @@ function WEAPON:New(WeaponObject) -- Set log ID. self.lid=string.format("[%s] %s | ", self.typeName, self.name) - + + if self.launcherUnit then + self.releaseHeading = self.launcherUnit:GetHeading() + self.releaseAltitudeASL = self.launcherUnit:GetAltitude() + self.releaseAltitudeAGL = self.launcherUnit:GetAltitude(true) + self.releaseCoordinate = self.launcherUnit:GetCoordinate() + self.releasePitch = self.launcherUnit:GetPitch() + end + -- Set default parameters self:SetTimeStepTrack() self:SetDistanceInterceptPoint() @@ -552,6 +560,52 @@ function WEAPON:GetImpactCoordinate() return self.impactCoord end +--- Get the heading on which the weapon was released +-- @param #WEAPON self +-- @param #bool AccountForMagneticInclination (Optional) If true will account for the magnetic declination of the current map. Default is true +-- @return #number Heading +function WEAPON:GetReleaseHeading(AccountForMagneticInclination) + AccountForMagneticInclination = AccountForMagneticInclination or true + if AccountForMagneticInclination then return self.releaseHeading - UTILS.GetMagneticDeclination() else return self.releaseHeading end +end + +--- Get the altitude above sea level at which the weapon was released +-- @param #WEAPON self +-- @return #number Altitude in meters +function WEAPON:GetReleaseAltitudeASL() + return self.releaseAltitudeASL +end + +--- Get the altitude above ground level at which the weapon was released +-- @param #WEAPON self +-- @return #number Altitude in meters +function WEAPON:GetReleaseAltitudeAGL() + return self.releaseAltitudeAGL +end + +--- Get the coordinate where the weapon was released +-- @param #WEAPON self +-- @return Core.Point#COORDINATE Impact coordinate (if any). +function WEAPON:GetReleaseCoordinate() + return self.releaseCoordinate +end + +--- Get the pitch of the unit when the weapon was released +-- @param #WEAPON self +-- @return #number Degrees +function WEAPON:GetReleasePitch() + return self.releasePitch +end + +--- Get the heading of the weapon when it impacted. Note that this might not exist if the weapon has not impacted yet! +-- @param #WEAPON self +-- @param #bool AccountForMagneticInclination (Optional) If true will account for the magnetic declination of the current map. Default is true +-- @return #number Heading +function WEAPON:GetImpactHeading(AccountForMagneticInclination) + AccountForMagneticInclination = AccountForMagneticInclination or true + if AccountForMagneticInclination then return self.impactHeading - UTILS.GetMagneticDeclination() else return self.impactHeading end +end + --- Check if weapon is in the air. Obviously not really useful for torpedos. Well, then again, this is DCS... -- @param #WEAPON self -- @return #boolean If `true`, weapon is in the air and `false` if not. Returns `nil` if weapon object itself is `nil`. @@ -781,7 +835,10 @@ function WEAPON:_TrackWeapon(time) -- Safe impact coordinate. self.impactCoord=COORDINATE:NewFromVec3(self.vec3) - + + -- Safe impact heading + self.impactHeading = UTILS.VecHdg(self:GetVelocityVec3()) + -- Mark impact point on F10 map. if self.impactMark then self.impactCoord:MarkToAll(string.format("Impact point of weapon %s\ntype=%s\nlauncher=%s", self.name, self.typeName, self.launcherName))