diff --git a/Moose Development/Moose/AI/AI_CAS.lua b/Moose Development/Moose/AI/AI_CAS.lua index 812af56a8..3c2a489de 100644 --- a/Moose Development/Moose/AI/AI_CAS.lua +++ b/Moose Development/Moose/AI/AI_CAS.lua @@ -136,8 +136,8 @@ AI_CAS_ZONE = { -- @param Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol. -- @param Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h. -- @param Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h. +-- @param Core.Zone#ZONE_BASE EngageZone The zone where the engage will happen. -- @param Dcs.DCSTypes#AltitudeType PatrolAltType The altitude type ("RADIO"=="AGL", "BARO"=="ASL"). Defaults to RADIO --- @param Core.Zone#ZONE EngageZone -- @return #AI_CAS_ZONE self function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageZone, PatrolAltType ) diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index 86a95d76d..10967685b 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -38,7 +38,7 @@ -- -- ![Objects](..\Presentations\EVENT\Dia6.JPG) -- --- For most DCS events, the above order of updating will be followed.1 +-- For most DCS events, the above order of updating will be followed. -- -- ![Objects](..\Presentations\EVENT\Dia7.JPG) -- @@ -124,6 +124,22 @@ -- -- ![Objects](..\Presentations\EVENT\Dia14.JPG) -- +-- **IMPORTANT NOTE:** Some events can involve not just UNIT objects, but also STATIC objects!!! +-- In that case the initiator or target unit fields will refer to a STATIC object! +-- In case a STATIC object is involved, the documentation indicates which fields will and won't not be populated. +-- The fields **IniCategory** and **TgtCategory** contain the indicator which **kind of object is involved** in the event. +-- You can use the enumerator **Object.Category.UNIT** and **Object.Category.STATIC** to check on IniCategory and TgtCategory. +-- Example code snippet: +-- +-- if Event.IniCategory == Object.Category.UNIT then +-- ... +-- end +-- if Event.IniCategory == Object.Category.STATIC then +-- ... +-- end +-- +-- When a static object is involved in the event, the Group and Player fields won't be populated. +-- -- ==== -- -- # **API CHANGE HISTORY** @@ -152,7 +168,8 @@ -- -- @module Event - +-- TODO: Need to update the EVENTDATA documentation with IniPlayerName and TgtPlayerName +-- TODO: Need to update the EVENTDATA documentation with IniCategory and TgtCategory @@ -195,23 +212,39 @@ EVENTS = { } --- The Event structure +-- Note that at the beginning of each field description, there is an indication which field will be populated depending on the object type involved in the Event: +-- +-- * A (Object.Category.)UNIT : A UNIT object type is involved in the Event. +-- * A (Object.Category.)STATIC : A STATIC object type is involved in the Event.µ +-- -- @type EVENTDATA --- @field id --- @field initiator --- @field target --- @field weapon --- @field IniDCSUnit --- @field IniDCSUnitName --- @field Wrapper.Unit#UNIT IniUnit --- @field #string IniUnitName --- @field IniDCSGroup --- @field IniDCSGroupName --- @field TgtDCSUnit --- @field TgtDCSUnitName --- @field Wrapper.Unit#UNIT TgtUnit --- @field #string TgtUnitName --- @field TgtDCSGroup --- @field TgtDCSGroupName +-- @field #number id The identifier of the event. +-- +-- @field Dcs.DCSUnit#Unit initiator (UNIT/STATIC) The initiating @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field Dcs.DCSObject#Object.Category IniCategory (UNIT/STATIC) The initiator object category ( Object.Category.UNIT or Object.Category.STATIC ). +-- @field Dcs.DCSUnit#Unit IniDCSUnit (UNIT/STATIC) The initiating @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field #string IniDCSUnitName (UNIT/STATIC) The initiating Unit name. +-- @field Wrapper.Unit#UNIT IniUnit (UNIT/STATIC) The initiating MOOSE wrapper @{Wrapper.Unit#UNIT} of the initiator Unit object. +-- @field #string IniUnitName (UNIT/STATIC) The initiating UNIT name (same as IniDCSUnitName). +-- @field Dcs.DCSGroup#Group IniDCSGroup (UNIT) The initiating {Dcs.DCSGroup#Group}. +-- @field #string IniDCSGroupName (UNIT) The initiating Group name. +-- @field Wrapper.Group#GROUP IniGroup (UNIT) The initiating MOOSE wrapper @{Wrapper.Group#GROUP} of the initiator Group object. +-- @field #string IniGroupName (UNIT) The initiating GROUP name (same as IniDCSGroupName). +-- @field #string IniPlayerName (UNIT) The name of the initiating player in case the Unit is a client or player slot. +-- +-- @field Dcs.DCSUnit#Unit target (UNIT/STATIC) The target @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field Dcs.DCSObject#Object.Category TgtCategory (UNIT/STATIC) The target object category ( Object.Category.UNIT or Object.Category.STATIC ). +-- @field Dcs.DCSUnit#Unit TgtDCSUnit (UNIT/STATIC) The target @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field #string TgtDCSUnitName (UNIT/STATIC) The target Unit name. +-- @field Wrapper.Unit#UNIT TgtUnit (UNIT/STATIC) The target MOOSE wrapper @{Wrapper.Unit#UNIT} of the target Unit object. +-- @field #string TgtUnitName (UNIT/STATIC) The target UNIT name (same as TgtDCSUnitName). +-- @field Dcs.DCSGroup#Group TgtDCSGroup (UNIT) The target {Dcs.DCSGroup#Group}. +-- @field #string TgtDCSGroupName (UNIT) The target Group name. +-- @field Wrapper.Group#GROUP TgtGroup (UNIT) The target MOOSE wrapper @{Wrapper.Group#GROUP} of the target Group object. +-- @field #string TgtGroupName (UNIT) The target GROUP name (same as TgtDCSGroupName). +-- @field #string TgtPlayerName (UNIT) The name of the target player in case the Unit is a client or player slot. +-- +-- @field weapon The weapon used during the event. -- @field Weapon -- @field WeaponName -- @field WeaponTgtDCSUnit @@ -1014,25 +1047,40 @@ function EVENT:onEvent( Event ) end if self and self.Events and self.Events[Event.id] then - if Event.initiator and Event.initiator:getCategory() == Object.Category.UNIT then - Event.IniDCSUnit = Event.initiator - Event.IniDCSGroup = Event.IniDCSUnit:getGroup() - Event.IniDCSUnitName = Event.IniDCSUnit:getName() - Event.IniUnitName = Event.IniDCSUnitName - Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName ) - if not Event.IniUnit then - -- Unit can be a CLIENT. Most likely this will be the case ... - Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true ) + + + if Event.initiator then + Event.IniCategory = Event.initiator:getCategory() + if Event.IniCategory == Object.Category.UNIT then + Event.IniDCSUnit = Event.initiator + Event.IniDCSUnitName = Event.IniDCSUnit:getName() + Event.IniUnitName = Event.IniDCSUnitName + Event.IniDCSGroup = Event.IniDCSUnit:getGroup() + Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName ) + if not Event.IniUnit then + -- Unit can be a CLIENT. Most likely this will be the case ... + Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true ) + end + Event.IniDCSGroupName = "" + if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then + Event.IniDCSGroupName = Event.IniDCSGroup:getName() + Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName ) + self:E( { IniGroup = Event.IniGroup } ) + end + Event.IniPlayerName = Event.IniDCSUnit:getPlayerName() end - Event.IniDCSGroupName = "" - if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then - Event.IniDCSGroupName = Event.IniDCSGroup:getName() - Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName ) - self:E( { IniGroup = Event.IniGroup } ) + + if Event.IniCategory == Object.Category.STATIC then + Event.IniDCSUnit = Event.initiator + Event.IniDCSUnitName = Event.IniDCSUnit:getName() + Event.IniUnitName = Event.IniDCSUnitName + Event.IniUnit = STATIC:FindByName( Event.IniDCSUnitName ) end end + if Event.target then - if Event.target and Event.target:getCategory() == Object.Category.UNIT then + Event.TgtCategory = Event.target:getCategory() + if Event.TgtCategory == Object.Category.UNIT then Event.TgtDCSUnit = Event.target Event.TgtDCSGroup = Event.TgtDCSUnit:getGroup() Event.TgtDCSUnitName = Event.TgtDCSUnit:getName() @@ -1042,8 +1090,19 @@ function EVENT:onEvent( Event ) if Event.TgtDCSGroup and Event.TgtDCSGroup:isExist() then Event.TgtDCSGroupName = Event.TgtDCSGroup:getName() end + Event.TgtPlayerName = Event.TgtDCSUnit:getPlayerName() + end + + if Event.TgtCategory == Object.Category.STATIC then + Event.TgtDCSUnit = Event.target + Event.TgtDCSUnitName = Event.TgtDCSUnit:getName() + Event.TgtUnitName = Event.TgtDCSUnitName + Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName ) end end + + + if Event.weapon then Event.Weapon = Event.weapon Event.WeaponName = Event.Weapon:getTypeName() diff --git a/Moose Development/Moose/Functional/Scoring.lua b/Moose Development/Moose/Functional/Scoring.lua index e2a6a5f46..7001aca89 100644 --- a/Moose Development/Moose/Functional/Scoring.lua +++ b/Moose Development/Moose/Functional/Scoring.lua @@ -122,7 +122,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) TargetUnitName = Event.IniDCSUnitName TargetGroup = Event.IniDCSGroup TargetGroupName = Event.IniDCSGroupName - TargetPlayerName = TargetUnit:getPlayerName() + TargetPlayerName = Event.IniPlayerName TargetCoalition = TargetUnit:getCoalition() --TargetCategory = TargetUnit:getCategory() @@ -369,7 +369,7 @@ function SCORING:_EventOnHit( Event ) InitUnitName = Event.IniDCSUnitName InitGroup = Event.IniDCSGroup InitGroupName = Event.IniDCSGroupName - InitPlayerName = InitUnit:getPlayerName() + InitPlayerName = Event.IniPlayerName InitCoalition = InitUnit:getCoalition() --TODO: Workaround Client DCS Bug @@ -391,7 +391,7 @@ function SCORING:_EventOnHit( Event ) TargetUnitName = Event.TgtDCSUnitName TargetGroup = Event.TgtDCSGroup TargetGroupName = Event.TgtDCSGroupName - TargetPlayerName = TargetUnit:getPlayerName() + TargetPlayerName = Event.TgtPlayerName TargetCoalition = TargetUnit:getCoalition() --TODO: Workaround Client DCS Bug diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 5fcd0cdb2..4a2a4d3f6 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -184,7 +184,7 @@ function GROUP:IsAlive() local DCSGroup = self:GetDCSObject() if DCSGroup then - local GroupIsAlive = DCSGroup:isExist() + local GroupIsAlive = DCSGroup:isExist() and DCSGroup:getUnit(1) ~= nil self:T3( GroupIsAlive ) return GroupIsAlive end diff --git a/Moose Development/Moose/XXX - Header Template.lua b/Moose Development/Moose/XXX - Header Template.lua new file mode 100644 index 000000000..c25e774fa --- /dev/null +++ b/Moose Development/Moose/XXX - Header Template.lua @@ -0,0 +1,14 @@ +--- +-- Name: XXX-999 - Title +-- Author: YYY +-- Date Created: DD Mmm YYYY +-- +-- # Situation: +-- +-- +-- +-- # Test cases: +-- +-- 1. + + diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index ba1037c31..748b350e2 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170221_1153' ) +env.info( 'Moose Generation Timestamp: 20170224_1222' ) local base = _G Include = {} @@ -4059,7 +4059,7 @@ end -- -- ![Objects](..\Presentations\EVENT\Dia6.JPG) -- --- For most DCS events, the above order of updating will be followed.1 +-- For most DCS events, the above order of updating will be followed. -- -- ![Objects](..\Presentations\EVENT\Dia7.JPG) -- @@ -4145,6 +4145,22 @@ end -- -- ![Objects](..\Presentations\EVENT\Dia14.JPG) -- +-- **IMPORTANT NOTE:** Some events can involve not just UNIT objects, but also STATIC objects!!! +-- In that case the initiator or target unit fields will refer to a STATIC object! +-- In case a STATIC object is involved, the documentation indicates which fields will and won't not be populated. +-- The fields **IniCategory** and **TgtCategory** contain the indicator which **kind of object is involved** in the event. +-- You can use the enumerator **Object.Category.UNIT** and **Object.Category.STATIC** to check on IniCategory and TgtCategory. +-- Example code snippet: +-- +-- if Event.IniCategory == Object.Category.UNIT then +-- ... +-- end +-- if Event.IniCategory == Object.Category.STATIC then +-- ... +-- end +-- +-- When a static object is involved in the event, the Group and Player fields won't be populated. +-- -- ==== -- -- # **API CHANGE HISTORY** @@ -4173,7 +4189,8 @@ end -- -- @module Event - +-- TODO: Need to update the EVENTDATA documentation with IniPlayerName and TgtPlayerName +-- TODO: Need to update the EVENTDATA documentation with IniCategory and TgtCategory @@ -4216,23 +4233,39 @@ EVENTS = { } --- The Event structure +-- Note that at the beginning of each field description, there is an indication which field will be populated depending on the object type involved in the Event: +-- +-- * A (Object.Category.)UNIT : A UNIT object type is involved in the Event. +-- * A (Object.Category.)STATIC : A STATIC object type is involved in the Event.µ +-- -- @type EVENTDATA --- @field id --- @field initiator --- @field target --- @field weapon --- @field IniDCSUnit --- @field IniDCSUnitName --- @field Wrapper.Unit#UNIT IniUnit --- @field #string IniUnitName --- @field IniDCSGroup --- @field IniDCSGroupName --- @field TgtDCSUnit --- @field TgtDCSUnitName --- @field Wrapper.Unit#UNIT TgtUnit --- @field #string TgtUnitName --- @field TgtDCSGroup --- @field TgtDCSGroupName +-- @field #number id The identifier of the event. +-- +-- @field Dcs.DCSUnit#Unit initiator (UNIT/STATIC) The initiating @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field Dcs.DCSObject#Object.Category IniCategory (UNIT/STATIC) The initiator object category ( Object.Category.UNIT or Object.Category.STATIC ). +-- @field Dcs.DCSUnit#Unit IniDCSUnit (UNIT/STATIC) The initiating @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field #string IniDCSUnitName (UNIT/STATIC) The initiating Unit name. +-- @field Wrapper.Unit#UNIT IniUnit (UNIT/STATIC) The initiating MOOSE wrapper @{Wrapper.Unit#UNIT} of the initiator Unit object. +-- @field #string IniUnitName (UNIT/STATIC) The initiating UNIT name (same as IniDCSUnitName). +-- @field Dcs.DCSGroup#Group IniDCSGroup (UNIT) The initiating {Dcs.DCSGroup#Group}. +-- @field #string IniDCSGroupName (UNIT) The initiating Group name. +-- @field Wrapper.Group#GROUP IniGroup (UNIT) The initiating MOOSE wrapper @{Wrapper.Group#GROUP} of the initiator Group object. +-- @field #string IniGroupName (UNIT) The initiating GROUP name (same as IniDCSGroupName). +-- @field #string IniPlayerName (UNIT) The name of the initiating player in case the Unit is a client or player slot. +-- +-- @field Dcs.DCSUnit#Unit target (UNIT/STATIC) The target @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field Dcs.DCSObject#Object.Category TgtCategory (UNIT/STATIC) The target object category ( Object.Category.UNIT or Object.Category.STATIC ). +-- @field Dcs.DCSUnit#Unit TgtDCSUnit (UNIT/STATIC) The target @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field #string TgtDCSUnitName (UNIT/STATIC) The target Unit name. +-- @field Wrapper.Unit#UNIT TgtUnit (UNIT/STATIC) The target MOOSE wrapper @{Wrapper.Unit#UNIT} of the target Unit object. +-- @field #string TgtUnitName (UNIT/STATIC) The target UNIT name (same as TgtDCSUnitName). +-- @field Dcs.DCSGroup#Group TgtDCSGroup (UNIT) The target {Dcs.DCSGroup#Group}. +-- @field #string TgtDCSGroupName (UNIT) The target Group name. +-- @field Wrapper.Group#GROUP TgtGroup (UNIT) The target MOOSE wrapper @{Wrapper.Group#GROUP} of the target Group object. +-- @field #string TgtGroupName (UNIT) The target GROUP name (same as TgtDCSGroupName). +-- @field #string TgtPlayerName (UNIT) The name of the target player in case the Unit is a client or player slot. +-- +-- @field weapon The weapon used during the event. -- @field Weapon -- @field WeaponName -- @field WeaponTgtDCSUnit @@ -5035,25 +5068,40 @@ function EVENT:onEvent( Event ) end if self and self.Events and self.Events[Event.id] then - if Event.initiator and Event.initiator:getCategory() == Object.Category.UNIT then - Event.IniDCSUnit = Event.initiator - Event.IniDCSGroup = Event.IniDCSUnit:getGroup() - Event.IniDCSUnitName = Event.IniDCSUnit:getName() - Event.IniUnitName = Event.IniDCSUnitName - Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName ) - if not Event.IniUnit then - -- Unit can be a CLIENT. Most likely this will be the case ... - Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true ) + + + if Event.initiator then + Event.IniCategory = Event.initiator:getCategory() + if Event.IniCategory == Object.Category.UNIT then + Event.IniDCSUnit = Event.initiator + Event.IniDCSUnitName = Event.IniDCSUnit:getName() + Event.IniUnitName = Event.IniDCSUnitName + Event.IniDCSGroup = Event.IniDCSUnit:getGroup() + Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName ) + if not Event.IniUnit then + -- Unit can be a CLIENT. Most likely this will be the case ... + Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true ) + end + Event.IniDCSGroupName = "" + if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then + Event.IniDCSGroupName = Event.IniDCSGroup:getName() + Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName ) + self:E( { IniGroup = Event.IniGroup } ) + end + Event.IniPlayerName = Event.IniDCSUnit:getPlayerName() end - Event.IniDCSGroupName = "" - if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then - Event.IniDCSGroupName = Event.IniDCSGroup:getName() - Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName ) - self:E( { IniGroup = Event.IniGroup } ) + + if Event.IniCategory == Object.Category.STATIC then + Event.IniDCSUnit = Event.initiator + Event.IniDCSUnitName = Event.IniDCSUnit:getName() + Event.IniUnitName = Event.IniDCSUnitName + Event.IniUnit = STATIC:FindByName( Event.IniDCSUnitName ) end end + if Event.target then - if Event.target and Event.target:getCategory() == Object.Category.UNIT then + Event.TgtCategory = Event.target:getCategory() + if Event.TgtCategory == Object.Category.UNIT then Event.TgtDCSUnit = Event.target Event.TgtDCSGroup = Event.TgtDCSUnit:getGroup() Event.TgtDCSUnitName = Event.TgtDCSUnit:getName() @@ -5063,8 +5111,19 @@ function EVENT:onEvent( Event ) if Event.TgtDCSGroup and Event.TgtDCSGroup:isExist() then Event.TgtDCSGroupName = Event.TgtDCSGroup:getName() end + Event.TgtPlayerName = Event.TgtDCSUnit:getPlayerName() + end + + if Event.TgtCategory == Object.Category.STATIC then + Event.TgtDCSUnit = Event.target + Event.TgtDCSUnitName = Event.TgtDCSUnit:getName() + Event.TgtUnitName = Event.TgtDCSUnitName + Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName ) end end + + + if Event.weapon then Event.Weapon = Event.weapon Event.WeaponName = Event.Weapon:getTypeName() @@ -15359,7 +15418,7 @@ function GROUP:IsAlive() local DCSGroup = self:GetDCSObject() if DCSGroup then - local GroupIsAlive = DCSGroup:isExist() + local GroupIsAlive = DCSGroup:isExist() and DCSGroup:getUnit(1) ~= nil self:T3( GroupIsAlive ) return GroupIsAlive end @@ -17726,7 +17785,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) TargetUnitName = Event.IniDCSUnitName TargetGroup = Event.IniDCSGroup TargetGroupName = Event.IniDCSGroupName - TargetPlayerName = TargetUnit:getPlayerName() + TargetPlayerName = Event.IniPlayerName TargetCoalition = TargetUnit:getCoalition() --TargetCategory = TargetUnit:getCategory() @@ -17973,7 +18032,7 @@ function SCORING:_EventOnHit( Event ) InitUnitName = Event.IniDCSUnitName InitGroup = Event.IniDCSGroup InitGroupName = Event.IniDCSGroupName - InitPlayerName = InitUnit:getPlayerName() + InitPlayerName = Event.IniPlayerName InitCoalition = InitUnit:getCoalition() --TODO: Workaround Client DCS Bug @@ -17995,7 +18054,7 @@ function SCORING:_EventOnHit( Event ) TargetUnitName = Event.TgtDCSUnitName TargetGroup = Event.TgtDCSGroup TargetGroupName = Event.TgtDCSGroupName - TargetPlayerName = TargetUnit:getPlayerName() + TargetPlayerName = Event.TgtPlayerName TargetCoalition = TargetUnit:getCoalition() --TODO: Workaround Client DCS Bug @@ -26119,8 +26178,8 @@ AI_CAS_ZONE = { -- @param Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol. -- @param Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h. -- @param Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h. +-- @param Core.Zone#ZONE_BASE EngageZone The zone where the engage will happen. -- @param Dcs.DCSTypes#AltitudeType PatrolAltType The altitude type ("RADIO"=="AGL", "BARO"=="ASL"). Defaults to RADIO --- @param Core.Zone#ZONE EngageZone -- @return #AI_CAS_ZONE self function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageZone, PatrolAltType ) diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index ba1037c31..748b350e2 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170221_1153' ) +env.info( 'Moose Generation Timestamp: 20170224_1222' ) local base = _G Include = {} @@ -4059,7 +4059,7 @@ end -- -- ![Objects](..\Presentations\EVENT\Dia6.JPG) -- --- For most DCS events, the above order of updating will be followed.1 +-- For most DCS events, the above order of updating will be followed. -- -- ![Objects](..\Presentations\EVENT\Dia7.JPG) -- @@ -4145,6 +4145,22 @@ end -- -- ![Objects](..\Presentations\EVENT\Dia14.JPG) -- +-- **IMPORTANT NOTE:** Some events can involve not just UNIT objects, but also STATIC objects!!! +-- In that case the initiator or target unit fields will refer to a STATIC object! +-- In case a STATIC object is involved, the documentation indicates which fields will and won't not be populated. +-- The fields **IniCategory** and **TgtCategory** contain the indicator which **kind of object is involved** in the event. +-- You can use the enumerator **Object.Category.UNIT** and **Object.Category.STATIC** to check on IniCategory and TgtCategory. +-- Example code snippet: +-- +-- if Event.IniCategory == Object.Category.UNIT then +-- ... +-- end +-- if Event.IniCategory == Object.Category.STATIC then +-- ... +-- end +-- +-- When a static object is involved in the event, the Group and Player fields won't be populated. +-- -- ==== -- -- # **API CHANGE HISTORY** @@ -4173,7 +4189,8 @@ end -- -- @module Event - +-- TODO: Need to update the EVENTDATA documentation with IniPlayerName and TgtPlayerName +-- TODO: Need to update the EVENTDATA documentation with IniCategory and TgtCategory @@ -4216,23 +4233,39 @@ EVENTS = { } --- The Event structure +-- Note that at the beginning of each field description, there is an indication which field will be populated depending on the object type involved in the Event: +-- +-- * A (Object.Category.)UNIT : A UNIT object type is involved in the Event. +-- * A (Object.Category.)STATIC : A STATIC object type is involved in the Event.µ +-- -- @type EVENTDATA --- @field id --- @field initiator --- @field target --- @field weapon --- @field IniDCSUnit --- @field IniDCSUnitName --- @field Wrapper.Unit#UNIT IniUnit --- @field #string IniUnitName --- @field IniDCSGroup --- @field IniDCSGroupName --- @field TgtDCSUnit --- @field TgtDCSUnitName --- @field Wrapper.Unit#UNIT TgtUnit --- @field #string TgtUnitName --- @field TgtDCSGroup --- @field TgtDCSGroupName +-- @field #number id The identifier of the event. +-- +-- @field Dcs.DCSUnit#Unit initiator (UNIT/STATIC) The initiating @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field Dcs.DCSObject#Object.Category IniCategory (UNIT/STATIC) The initiator object category ( Object.Category.UNIT or Object.Category.STATIC ). +-- @field Dcs.DCSUnit#Unit IniDCSUnit (UNIT/STATIC) The initiating @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field #string IniDCSUnitName (UNIT/STATIC) The initiating Unit name. +-- @field Wrapper.Unit#UNIT IniUnit (UNIT/STATIC) The initiating MOOSE wrapper @{Wrapper.Unit#UNIT} of the initiator Unit object. +-- @field #string IniUnitName (UNIT/STATIC) The initiating UNIT name (same as IniDCSUnitName). +-- @field Dcs.DCSGroup#Group IniDCSGroup (UNIT) The initiating {Dcs.DCSGroup#Group}. +-- @field #string IniDCSGroupName (UNIT) The initiating Group name. +-- @field Wrapper.Group#GROUP IniGroup (UNIT) The initiating MOOSE wrapper @{Wrapper.Group#GROUP} of the initiator Group object. +-- @field #string IniGroupName (UNIT) The initiating GROUP name (same as IniDCSGroupName). +-- @field #string IniPlayerName (UNIT) The name of the initiating player in case the Unit is a client or player slot. +-- +-- @field Dcs.DCSUnit#Unit target (UNIT/STATIC) The target @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field Dcs.DCSObject#Object.Category TgtCategory (UNIT/STATIC) The target object category ( Object.Category.UNIT or Object.Category.STATIC ). +-- @field Dcs.DCSUnit#Unit TgtDCSUnit (UNIT/STATIC) The target @{Dcs.DCSUnit#Unit} or @{Dcs.DCSStaticObject#StaticObject}. +-- @field #string TgtDCSUnitName (UNIT/STATIC) The target Unit name. +-- @field Wrapper.Unit#UNIT TgtUnit (UNIT/STATIC) The target MOOSE wrapper @{Wrapper.Unit#UNIT} of the target Unit object. +-- @field #string TgtUnitName (UNIT/STATIC) The target UNIT name (same as TgtDCSUnitName). +-- @field Dcs.DCSGroup#Group TgtDCSGroup (UNIT) The target {Dcs.DCSGroup#Group}. +-- @field #string TgtDCSGroupName (UNIT) The target Group name. +-- @field Wrapper.Group#GROUP TgtGroup (UNIT) The target MOOSE wrapper @{Wrapper.Group#GROUP} of the target Group object. +-- @field #string TgtGroupName (UNIT) The target GROUP name (same as TgtDCSGroupName). +-- @field #string TgtPlayerName (UNIT) The name of the target player in case the Unit is a client or player slot. +-- +-- @field weapon The weapon used during the event. -- @field Weapon -- @field WeaponName -- @field WeaponTgtDCSUnit @@ -5035,25 +5068,40 @@ function EVENT:onEvent( Event ) end if self and self.Events and self.Events[Event.id] then - if Event.initiator and Event.initiator:getCategory() == Object.Category.UNIT then - Event.IniDCSUnit = Event.initiator - Event.IniDCSGroup = Event.IniDCSUnit:getGroup() - Event.IniDCSUnitName = Event.IniDCSUnit:getName() - Event.IniUnitName = Event.IniDCSUnitName - Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName ) - if not Event.IniUnit then - -- Unit can be a CLIENT. Most likely this will be the case ... - Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true ) + + + if Event.initiator then + Event.IniCategory = Event.initiator:getCategory() + if Event.IniCategory == Object.Category.UNIT then + Event.IniDCSUnit = Event.initiator + Event.IniDCSUnitName = Event.IniDCSUnit:getName() + Event.IniUnitName = Event.IniDCSUnitName + Event.IniDCSGroup = Event.IniDCSUnit:getGroup() + Event.IniUnit = UNIT:FindByName( Event.IniDCSUnitName ) + if not Event.IniUnit then + -- Unit can be a CLIENT. Most likely this will be the case ... + Event.IniUnit = CLIENT:FindByName( Event.IniDCSUnitName, '', true ) + end + Event.IniDCSGroupName = "" + if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then + Event.IniDCSGroupName = Event.IniDCSGroup:getName() + Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName ) + self:E( { IniGroup = Event.IniGroup } ) + end + Event.IniPlayerName = Event.IniDCSUnit:getPlayerName() end - Event.IniDCSGroupName = "" - if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then - Event.IniDCSGroupName = Event.IniDCSGroup:getName() - Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName ) - self:E( { IniGroup = Event.IniGroup } ) + + if Event.IniCategory == Object.Category.STATIC then + Event.IniDCSUnit = Event.initiator + Event.IniDCSUnitName = Event.IniDCSUnit:getName() + Event.IniUnitName = Event.IniDCSUnitName + Event.IniUnit = STATIC:FindByName( Event.IniDCSUnitName ) end end + if Event.target then - if Event.target and Event.target:getCategory() == Object.Category.UNIT then + Event.TgtCategory = Event.target:getCategory() + if Event.TgtCategory == Object.Category.UNIT then Event.TgtDCSUnit = Event.target Event.TgtDCSGroup = Event.TgtDCSUnit:getGroup() Event.TgtDCSUnitName = Event.TgtDCSUnit:getName() @@ -5063,8 +5111,19 @@ function EVENT:onEvent( Event ) if Event.TgtDCSGroup and Event.TgtDCSGroup:isExist() then Event.TgtDCSGroupName = Event.TgtDCSGroup:getName() end + Event.TgtPlayerName = Event.TgtDCSUnit:getPlayerName() + end + + if Event.TgtCategory == Object.Category.STATIC then + Event.TgtDCSUnit = Event.target + Event.TgtDCSUnitName = Event.TgtDCSUnit:getName() + Event.TgtUnitName = Event.TgtDCSUnitName + Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName ) end end + + + if Event.weapon then Event.Weapon = Event.weapon Event.WeaponName = Event.Weapon:getTypeName() @@ -15359,7 +15418,7 @@ function GROUP:IsAlive() local DCSGroup = self:GetDCSObject() if DCSGroup then - local GroupIsAlive = DCSGroup:isExist() + local GroupIsAlive = DCSGroup:isExist() and DCSGroup:getUnit(1) ~= nil self:T3( GroupIsAlive ) return GroupIsAlive end @@ -17726,7 +17785,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) TargetUnitName = Event.IniDCSUnitName TargetGroup = Event.IniDCSGroup TargetGroupName = Event.IniDCSGroupName - TargetPlayerName = TargetUnit:getPlayerName() + TargetPlayerName = Event.IniPlayerName TargetCoalition = TargetUnit:getCoalition() --TargetCategory = TargetUnit:getCategory() @@ -17973,7 +18032,7 @@ function SCORING:_EventOnHit( Event ) InitUnitName = Event.IniDCSUnitName InitGroup = Event.IniDCSGroup InitGroupName = Event.IniDCSGroupName - InitPlayerName = InitUnit:getPlayerName() + InitPlayerName = Event.IniPlayerName InitCoalition = InitUnit:getCoalition() --TODO: Workaround Client DCS Bug @@ -17995,7 +18054,7 @@ function SCORING:_EventOnHit( Event ) TargetUnitName = Event.TgtDCSUnitName TargetGroup = Event.TgtDCSGroup TargetGroupName = Event.TgtDCSGroupName - TargetPlayerName = TargetUnit:getPlayerName() + TargetPlayerName = Event.TgtPlayerName TargetCoalition = TargetUnit:getCoalition() --TODO: Workaround Client DCS Bug @@ -26119,8 +26178,8 @@ AI_CAS_ZONE = { -- @param Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol. -- @param Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h. -- @param Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h. +-- @param Core.Zone#ZONE_BASE EngageZone The zone where the engage will happen. -- @param Dcs.DCSTypes#AltitudeType PatrolAltType The altitude type ("RADIO"=="AGL", "BARO"=="ASL"). Defaults to RADIO --- @param Core.Zone#ZONE EngageZone -- @return #AI_CAS_ZONE self function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageZone, PatrolAltType ) diff --git a/Moose Test Missions/GRP - Group Commands/GRP-100 - IsAlive/GRP-100 - IsAlive.lua b/Moose Test Missions/GRP - Group Commands/GRP-100 - IsAlive/GRP-100 - IsAlive.lua new file mode 100644 index 000000000..7f33d42f2 --- /dev/null +++ b/Moose Test Missions/GRP - Group Commands/GRP-100 - IsAlive/GRP-100 - IsAlive.lua @@ -0,0 +1,32 @@ +--- +-- Name: GRP-100 - IsAlive +-- Author: FlightControl +-- Date Created: 23 Feb 2017 +-- +-- # Situation: +-- +-- This test is about checking if IsAlive on GROUP level is working correctly. +-- Two ground forces GROUPS are shooting each other. +-- Check the IsAlive status in the logging of the survivor and the defeat. +-- +-- # Test cases: +-- +-- 1. Observe the IsAlive statuses in the dcs.log file. + + + +--Create Spawn Groups +local GroupBlue = GROUP:FindByName( "Blue" ) +local GroupRed = GROUP:FindByName( "Red" ) + +local Schedule, ScheduleID = SCHEDULER:New( nil, + --- Variable Declarations + -- @param Wrapper.Group#GROUP GroupBlue + -- @param Wrapper.Group#GROUP GroupRed + function( GroupBlue, GroupRed ) + local IsAliveBlue = GroupBlue:IsAlive() + local IsAliveRed = GroupRed:IsAlive() + BASE:E( { IsAliveBlue = IsAliveBlue, IsAliveRed = IsAliveRed } ) + end, { GroupBlue, GroupRed }, 1, 1 +) + diff --git a/Moose Test Missions/GRP - Group Commands/GRP-100 - IsAlive/GRP-100 - IsAlive.miz b/Moose Test Missions/GRP - Group Commands/GRP-100 - IsAlive/GRP-100 - IsAlive.miz new file mode 100644 index 000000000..162e39f32 Binary files /dev/null and b/Moose Test Missions/GRP - Group Commands/GRP-100 - IsAlive/GRP-100 - IsAlive.miz differ diff --git a/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.lua b/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.lua new file mode 100644 index 000000000..7c2f7a85e --- /dev/null +++ b/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.lua @@ -0,0 +1,21 @@ +--- +-- Name: SCO-100 - Scoring of Statics +-- Author: FlightControl +-- Date Created: 21 Feb 2017 +-- +-- # Situation: +-- +-- A shooting range has been setup. Fly the Ka-50 or the Su-25T to the statics located near the airport, and shoot them. +-- +-- # Test cases: +-- +-- 1. Observe the scoring granted to your flight when you hit and kill targets. + + +local HQ = GROUP:FindByName( "HQ", "Bravo HQ" ) + +local CommandCenter = COMMANDCENTER:New( HQ, "Lima" ) + +local Scoring = SCORING:New( "Detect Demo" ) + + diff --git a/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.miz b/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.miz new file mode 100644 index 000000000..4d904901c Binary files /dev/null and b/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.miz differ diff --git a/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz b/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz index 3ece6f709..0d41439b2 100644 Binary files a/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz differ