Take animation for determining the wire
This commit is contained in:
Frank 2022-09-26 23:34:00 +02:00
parent 0731e15385
commit 2157f8e8cd
4 changed files with 54 additions and 7 deletions

1
.gitignore vendored
View File

@ -228,3 +228,4 @@ MooseCodeWS.code-workspace
.gitignore
.gitignore
/.gitignore
Moose Development/Moose/.vscode/settings.json

View File

@ -1,7 +1,8 @@
{
"Lua.workspace.preloadFileSize": 1000,
"Lua.diagnostics.disable": [
"undefined-doc-name"
"undefined-doc-name",
"need-check-nil"
],
"Lua.diagnostics.globals": [
"BASE",
@ -9,9 +10,14 @@
"__Moose",
"trigger",
"coord",
"missionCommands"
"missionCommands",
"world"
],
"Lua.completion.displayContext": 5,
"Lua.runtime.version": "Lua 5.1",
"Lua.completion.callSnippet": "Both"
"Lua.completion.callSnippet": "Both",
"Lua.workspace.library": [
"${3rd}/lfs/library"
],
"Lua.workspace.checkThirdParty": false
}

View File

@ -1809,7 +1809,7 @@ AIRBOSS.version = "1.2.1"
function AIRBOSS:New( carriername, alias )
-- Inherit everthing from FSM class.
local self = BASE:Inherit( self, FSM:New() ) -- #AIRBOSS
self = BASE:Inherit( self, FSM:New() ) -- #AIRBOSS
-- Debug.
self:F2( { carriername = carriername, alias = alias } )
@ -8222,7 +8222,7 @@ function AIRBOSS:OnEventLand( EventData )
local dist = coord:Get2DDistance( self:GetCoordinate() )
-- Get wire
local wire = self:_GetWire( coord, 0 )
local wire = self:_GetWirePos( coord, 0 )
-- Aircraft type.
local _type = EventData.IniUnit:GetTypeName()
@ -10058,12 +10058,34 @@ function AIRBOSS:_GetSternCoord()
return self.sterncoord
end
--- Get wire from
-- @param #AIRBOSS self
-- @param Core.Point#COORDINATE Lcoord Landing position.
-- @return #number Trapped wire (1-4) or 99 if no wire was trapped.
function AIRBOSS:_GetWire()
local wireArgs={}
wireArgs[1]=141
wireArgs[2]=142
wireArgs[3]=143
wireArgs[4]=144
for wire,drawArg in pairs(wireArgs) do
local value=self.carrier:GetDrawArgumentValue(drawArg)
if math.abs(value)>0.001 then
return wire
end
end
return 99
end
--- Get wire from landing position.
-- @param #AIRBOSS self
-- @param Core.Point#COORDINATE Lcoord Landing position.
-- @param #number dc Distance correction. Shift the landing coord back if dc>0 and forward if dc<0.
-- @return #number Trapped wire (1-4) or 99 if no wire was trapped.
function AIRBOSS:_GetWire( Lcoord, dc )
function AIRBOSS:_GetWirePos( Lcoord, dc )
-- Final bearing (true).
local FB = self:GetFinalBearing()
@ -10181,7 +10203,7 @@ function AIRBOSS:_Trapped( playerData )
end
-- Get wire.
local wire = self:_GetWire( coord, dcorr )
local wire = self:_GetWirePos( coord, dcorr )
-- Debug.
local text = string.format( "Player %s _Trapped: v=%.1f km/h, s-dcorr=%.1f m ==> wire=%d (dcorr=%d)", playerData.name, v, s - dcorr, wire, dcorr )

View File

@ -963,6 +963,24 @@ function UNIT:GetDamageRelative()
return 1
end
--- Returns the current value for an animation argument on the external model of the given object.
-- Each model animation has an id tied to with different values representing different states of the model.
-- Animation arguments can be figured out by opening the respective 3d model in the modelviewer.
-- @param #UNIT self
-- @param #number AnimationArgument Number corresponding to the animated part of the unit.
-- @return #number Value of the animation argument [-1, 1]. If draw argument value is invalid for the unit in question a value of 0 will be returned.
function UNIT:GetDrawArgumentValue(AnimationArgument)
local DCSUnit = self:GetDCSObject()
if DCSUnit then
local value = DCSUnit:getDrawArgumentValue(AnimationArgument or 0)
return value
end
return 0
end
--- Returns the category of the #UNIT from descriptor. Returns one of
--
-- * Unit.Category.AIRPLANE