CT v0.1.6

This commit is contained in:
Frank
2018-11-04 01:14:47 +01:00
parent 27bf6069d7
commit 087ac992a2
3 changed files with 311 additions and 193 deletions

View File

@@ -342,16 +342,26 @@ function CONTROLLABLE:PushTask( DCSTask, WaitTime )
local DCSControllable = self:GetDCSObject()
if DCSControllable then
local Controller = self:_GetController()
local DCSControllableName = self:GetName()
-- When a controllable SPAWNs, it takes about a second to get the controllable in the simulator. Setting tasks to unspawned controllables provides unexpected results.
-- Therefore we schedule the functions to set the mission and options for the Controllable.
-- Controller:pushTask( DCSTask )
-- Controller:pushTask( DCSTask )
local function PushTask( Controller, DCSTask )
if self and self:IsAlive() then
local Controller = self:_GetController()
Controller:pushTask( DCSTask )
else
BASE:E( { DCSControllableName .. " is not alive anymore.", DCSTask = DCSTask } )
end
end
if WaitTime then
self.TaskScheduler:Schedule( Controller, Controller.pushTask, { DCSTask }, WaitTime )
if not WaitTime or WaitTime == 0 then
PushTask( self, DCSTask )
else
Controller:pushTask( DCSTask )
self.TaskScheduler:Schedule( self, PushTask, { DCSTask }, WaitTime )
end
return self

View File

@@ -706,8 +706,8 @@ end
--- Returns the unit's climb or descent angle.
-- @param Wrapper.Positionable#POSITIONABLE self
-- @return #number Climb or descent angle in degrees.
function POSITIONABLE:GetClimbAnge()
-- @return #number Climb or descent angle in degrees. Or 0 if velocity vector norm is zero (or nil). Or nil, if the position of the POSITIONABLE returns nil.
function POSITIONABLE:GetClimbAngle()
-- Get position of the unit.
local unitpos = self:GetPosition()
@@ -719,10 +719,17 @@ function POSITIONABLE:GetClimbAnge()
if unitvel and UTILS.VecNorm(unitvel)~=0 then
return math.asin(unitvel.y/UTILS.VecNorm(unitvel))
-- Calculate climb angle.
local angle=math.asin(unitvel.y/UTILS.VecNorm(unitvel))
-- Return angle in degrees.
return math.deg(angle)
else
return 0
end
end
return nil
end
--- Returns the pitch angle of a unit.