diff --git a/Documentation/Base.html b/Documentation/Base.html index c691d7457..cec5967a3 100644 --- a/Documentation/Base.html +++ b/Documentation/Base.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/CARGO.html b/Documentation/CARGO.html index dbce3e8d9..3927ac107 100644 --- a/Documentation/CARGO.html +++ b/Documentation/CARGO.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/CLEANUP.html b/Documentation/CLEANUP.html index 6946d1aa9..4e3e55cb0 100644 --- a/Documentation/CLEANUP.html +++ b/Documentation/CLEANUP.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Client.html b/Documentation/Client.html index f19da4d0b..b45d4be53 100644 --- a/Documentation/Client.html +++ b/Documentation/Client.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • @@ -164,24 +165,12 @@ Note that clients are NOT the same as Units, they are NOT necessarily alive.

    CLIENT.ClientParameters - - - - CLIENT:ClientPosition() - -

    Returns the position of the CLIENT in DCSTypes#Vec3 format.

    CLIENT.ClientTransport - - - - CLIENT:GetAltitude() - -

    Returns the altitude of the CLIENT.

    @@ -212,48 +201,6 @@ Note that clients are NOT the same as Units, they are NOT necessarily alive.

    CLIENT:GetDCSGroup()

    Return the DCSGroup of a Client.

    - - - - CLIENT:GetID() - - - - - - CLIENT:GetName() - - - - - - CLIENT:GetPointVec2() - -

    Returns the position of the CLIENT in DCSTypes#Vec2 format..

    - - - - CLIENT:GetPositionVec3() - - - - - - CLIENT:GetTypeName() - - - - - - CLIENT:GetUnit() - - - - - - CLIENT:IsAlive() - -

    Checks if client is alive and returns true or false.

    @@ -290,6 +237,12 @@ Note that clients are NOT the same as Units, they are NOT necessarily alive.

    CLIENT:Message(Message, MessageDuration, MessageId, MessageCategory, MessageInterval)

    The main message driver for the CLIENT.

    + + + + CLIENT.MessageSwitch + + @@ -308,6 +261,12 @@ Note that clients are NOT the same as Units, they are NOT necessarily alive.

    CLIENT.ONBOARDSIDE + + + + CLIENT:Register(ClientName) + + @@ -577,6 +536,7 @@ Function.

    + CLIENT.ClientName @@ -599,24 +559,6 @@ Function.

    - -
    -
    -
    - - -CLIENT:ClientPosition() - -
    -
    - -

    Returns the position of the CLIENT in DCSTypes#Vec3 format.

    - -

    Return value

    - -

    DCSTypes#Vec3:

    - -
    @@ -631,24 +573,6 @@ Function.

    - -
    -
    -
    - - -CLIENT:GetAltitude() - -
    -
    - -

    Returns the altitude of the CLIENT.

    - -

    Return value

    - -

    DCSTypes#Distance:

    - -
    @@ -743,105 +667,6 @@ Function.

    DCSGroup#Group:

    - -
    -
    -
    - - -CLIENT:GetID() - -
    -
    - - - -
    -
    -
    -
    - - -CLIENT:GetName() - -
    -
    - - - -
    -
    -
    -
    - - -CLIENT:GetPointVec2() - -
    -
    - -

    Returns the position of the CLIENT in DCSTypes#Vec2 format..

    - -

    Return value

    - -

    DCSTypes#Vec2:

    - - -
    -
    -
    -
    - - -CLIENT:GetPositionVec3() - -
    -
    - - - -
    -
    -
    -
    - - -CLIENT:GetTypeName() - -
    -
    - - - -
    -
    -
    -
    - - -CLIENT:GetUnit() - -
    -
    - - - - -

    TODO what is this??? check. possible double function.

    - -
    -
    -
    -
    - - -CLIENT:IsAlive() - -
    -
    - -

    Checks if client is alive and returns true or false.

    -
    @@ -969,6 +794,20 @@ is the interval in seconds between the display of the +
    + + #boolean + +CLIENT.MessageSwitch + +
    +
    + + +
    @@ -1040,6 +879,27 @@ Text that describes the briefing of the mission when a Player logs into the Clie + +
    +
    +
    + + +CLIENT:Register(ClientName) + +
    +
    + + + +

    Parameter

    +
    diff --git a/Documentation/DEPLOYTASK.html b/Documentation/DEPLOYTASK.html index 2d68b6cfa..8f8bebbc4 100644 --- a/Documentation/DEPLOYTASK.html +++ b/Documentation/DEPLOYTASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/DESTROYBASETASK.html b/Documentation/DESTROYBASETASK.html index 32d486ea6..2fdf173df 100644 --- a/Documentation/DESTROYBASETASK.html +++ b/Documentation/DESTROYBASETASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/DESTROYGROUPSTASK.html b/Documentation/DESTROYGROUPSTASK.html index 01411a4f9..88cb8aba6 100644 --- a/Documentation/DESTROYGROUPSTASK.html +++ b/Documentation/DESTROYGROUPSTASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/DESTROYRADARSTASK.html b/Documentation/DESTROYRADARSTASK.html index 6cb878888..e7de3a904 100644 --- a/Documentation/DESTROYRADARSTASK.html +++ b/Documentation/DESTROYRADARSTASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/DESTROYUNITTYPESTASK.html b/Documentation/DESTROYUNITTYPESTASK.html index 9890c4507..cb581bed7 100644 --- a/Documentation/DESTROYUNITTYPESTASK.html +++ b/Documentation/DESTROYUNITTYPESTASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Database.html b/Documentation/Database.html index 8192f0de6..07554c5b7 100644 --- a/Documentation/Database.html +++ b/Documentation/Database.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • @@ -139,6 +140,18 @@ The following iterator methods are currently available within the DATABASE:

    Type DATABASE

    + + + + + + + + - - - - @@ -175,39 +182,15 @@ The following iterator methods are currently available within the DATABASE:

    - + - - - - - - - - - - - - - - - - @@ -217,21 +200,15 @@ The following iterator methods are currently available within the DATABASE:

    - + - + - - - - @@ -247,7 +224,7 @@ The following iterator methods are currently available within the DATABASE:

    - + @@ -268,12 +245,6 @@ The following iterator methods are currently available within the DATABASE:

    - - - - @@ -340,12 +311,6 @@ The following iterator methods are currently available within the DATABASE:

    - - - - @@ -435,6 +400,53 @@ The following iterator methods are currently available within the DATABASE:

    + +DATABASE:AddClient(ClientName) + +
    +
    + +

    Adds a CLIENT based on the ClientName in the DATABASE.

    + +

    Parameter

    +
      +
    • + +

      ClientName :

      + +
    • +
    +
    +
    +
    +
    + + +DATABASE:AddUnit(DCSUnit, DCSUnitName) + +
    +
    + +

    Adds a Unit based on the Unit Name in the DATABASE.

    + +

    Parameters

    +
      +
    • + +

      DCSUnit :

      + +
    • +
    • + +

      DCSUnitName :

      + +
    • +
    +
    +
    +
    +
    + #string DATABASE.ClassName @@ -486,20 +498,6 @@ The following iterator methods are currently available within the DATABASE:

    - -
    -
    -
    - - - -DATABASE.DCSGroupsAlive - -
    -
    - - -
    @@ -519,15 +517,22 @@ The following iterator methods are currently available within the DATABASE:

    - - -DATABASE.DCSUnitsAlive + +DATABASE:DeleteUnit(DCSUnitName)
    +

    Deletes a Unit from the DATABASE based on the Unit Name.

    +

    Parameter

    +
      +
    • + +

      DCSUnitName :

      +
    • +
    @@ -542,126 +547,6 @@ The following iterator methods are currently available within the DATABASE:

    - -
    -
    -
    - - -DATABASE:FilterCategories(Categories) - -
    -
    - -

    Builds a set of units out of categories.

    - - -

    Possible current categories are plane, helicopter, ground, ship.

    - -

    Parameter

    -
      -
    • - -

      #string Categories : -Can take the following values: "plane", "helicopter", "ground", "ship".

      - -
    • -
    -

    Return value

    - -

    #DATABASE: -self

    - -
    -
    -
    -
    - - -DATABASE:FilterCoalitions(Coalitions) - -
    -
    - -

    Builds a set of units of coalitons.

    - - -

    Possible current coalitions are red, blue and neutral.

    - -

    Parameter

    -
      -
    • - -

      #string Coalitions : -Can take the following values: "red", "blue", "neutral".

      - -
    • -
    -

    Return value

    - -

    #DATABASE: -self

    - -
    -
    -
    -
    - - -DATABASE:FilterCountries(Countries) - -
    -
    - -

    Builds a set of units of defined countries.

    - - -

    Possible current countries are those known within DCS world.

    - -

    Parameter

    -
      -
    • - -

      #string Countries : -Can take those country strings known within DCS world.

      - -
    • -
    -

    Return value

    - -

    #DATABASE: -self

    - -
    -
    -
    -
    - - -DATABASE:FilterGroupPrefixes(Prefixes) - -
    -
    - -

    Builds a set of units of defined group prefixes.

    - - -

    All the units starting with the given group prefixes will be included within the set.

    - -

    Parameter

    -
      -
    • - -

      #string Prefixes : -The prefix of which the group name where the unit belongs to starts with.

      - -
    • -
    -

    Return value

    - -

    #DATABASE: -self

    -
    @@ -681,78 +566,52 @@ self

    - -DATABASE:FilterStart() + +DATABASE:FindClient(ClientName)
    -

    Starts the filtering.

    +

    Finds a CLIENT based on the ClientName.

    +

    Parameter

    +
      +
    • + +

      #string ClientName :

      + +
    • +

    Return value

    -

    #DATABASE: -self

    +

    Client#CLIENT: +The found CLIENT.

    - -DATABASE:FilterTypes(Types) + +DATABASE:FindUnit(UnitName)
    -

    Builds a set of units of defined unit types.

    - - -

    Possible current types are those types known within DCS world.

    +

    Finds a Unit based on the Unit Name.

    Parameter

    • -

      #string Types : -Can take those type strings known within DCS world.

      +

      #string UnitName :

    Return value

    -

    #DATABASE: -self

    - -
    -
    -
    -
    - - -DATABASE:FilterUnitPrefixes(Prefixes) - -
    -
    - -

    Builds a set of units of defined unit prefixes.

    - - -

    All the units starting with the given prefixes will be included within the set.

    - -

    Parameter

    -
      -
    • - -

      #string Prefixes : -The prefix of which the unit name starts with.

      - -
    • -
    -

    Return value

    - -

    #DATABASE: -self

    +

    Unit#UNIT: +The found Unit.

    @@ -828,8 +687,8 @@ self

    - -DATABASE:ForEachDCSUnitAlive(IteratorFunction, ...) + +DATABASE:ForEachDCSUnit(IteratorFunction, ...)
    @@ -922,20 +781,6 @@ self

    -
    -
    -
    -
    - - - -DATABASE.GroupsAlive - -
    -
    - - -
    @@ -1133,20 +978,6 @@ self

    - -
    -
    -
    - - - -DATABASE.UnitsAlive - -
    -
    - - -
    diff --git a/Documentation/Escort.html b/Documentation/Escort.html index b1fe8f549..5c70cc46c 100644 --- a/Documentation/Escort.html +++ b/Documentation/Escort.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • @@ -1835,7 +1836,6 @@ self

    - ESCORT.ReportTargetsScheduler diff --git a/Documentation/Event.html b/Documentation/Event.html index b05cb6788..ce93521fd 100644 --- a/Documentation/Event.html +++ b/Documentation/Event.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/GOHOMETASK.html b/Documentation/GOHOMETASK.html index 4b63dc32e..a2aedee46 100644 --- a/Documentation/GOHOMETASK.html +++ b/Documentation/GOHOMETASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Group.html b/Documentation/Group.html index be3012b46..eccd41bc8 100644 --- a/Documentation/Group.html +++ b/Documentation/Group.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • @@ -213,7 +214,7 @@ Note that this destroy method also raises a destroy event at run-time.

    - + @@ -1147,8 +1148,8 @@ Current x,y and z position of the group.

    - -GROUP:GetPositionVec3() + +GROUP:GetPointVec3()
    diff --git a/Documentation/MISSION.html b/Documentation/MISSION.html index 9de091e4d..d20297316 100644 --- a/Documentation/MISSION.html +++ b/Documentation/MISSION.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/MOVEMENT.html b/Documentation/MOVEMENT.html index 98df22b0c..2e1825e50 100644 --- a/Documentation/MOVEMENT.html +++ b/Documentation/MOVEMENT.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Menu.html b/Documentation/Menu.html index 58ccee4f5..c2e778b76 100644 --- a/Documentation/Menu.html +++ b/Documentation/Menu.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Message.html b/Documentation/Message.html index dd4087bf7..ecaa029d9 100644 --- a/Documentation/Message.html +++ b/Documentation/Message.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/MissileTrainer.html b/Documentation/MissileTrainer.html index e97906500..54a295ba7 100644 --- a/Documentation/MissileTrainer.html +++ b/Documentation/MissileTrainer.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/NOTASK.html b/Documentation/NOTASK.html index d49ebedf5..d56be9578 100644 --- a/Documentation/NOTASK.html +++ b/Documentation/NOTASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/PICKUPTASK.html b/Documentation/PICKUPTASK.html index d888999c0..3b5c01584 100644 --- a/Documentation/PICKUPTASK.html +++ b/Documentation/PICKUPTASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/ROUTETASK.html b/Documentation/ROUTETASK.html index c95432e3e..9ab3852b2 100644 --- a/Documentation/ROUTETASK.html +++ b/Documentation/ROUTETASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/STAGE.html b/Documentation/STAGE.html index fd2ceedc0..985997808 100644 --- a/Documentation/STAGE.html +++ b/Documentation/STAGE.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Scheduler.html b/Documentation/Scheduler.html index 10a410720..cb5845838 100644 --- a/Documentation/Scheduler.html +++ b/Documentation/Scheduler.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Scoring.html b/Documentation/Scoring.html index 34d058056..ad5556374 100644 --- a/Documentation/Scoring.html +++ b/Documentation/Scoring.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Sead.html b/Documentation/Sead.html index d4631a922..55b652c23 100644 --- a/Documentation/Sead.html +++ b/Documentation/Sead.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Set.html b/Documentation/Set.html new file mode 100644 index 000000000..078f9d754 --- /dev/null +++ b/Documentation/Set.html @@ -0,0 +1,1318 @@ + + + + + + +
    +
    + +
    +
    +
    +
    + +
    +

    Module Set

    + +

    Manage sets of units and groups.

    + + + +

    #Set class

    +

    Mission designers can use the SET class to build sets of units belonging to certain:

    + +
      +
    • Coalitions
    • +
    • Categories
    • +
    • Countries
    • +
    • Unit types
    • +
    • Starting with certain prefix strings.
    • +
    + +

    This list will grow over time. Planned developments are to include filters and iterators. +Additional filters will be added around Zone#ZONEs, Radiuses, Active players, ... +More iterators will be implemented in the near future ...

    + +

    Administers the Initial Sets of the Mission Templates as defined within the Mission Editor.

    + +

    SET construction methods:

    +

    Create a new SET object with the SET.New method:

    + +
      +
    • SET.New: Creates a new SET object.
    • +
    + + +

    SET filter criteria:

    +

    You can set filter criteria to define the set of units within the SET. +Filter criteria are defined by:

    + + + +

    Once the filter criteria have been set for the SET, you can start filtering using:

    + + + +

    Planned filter criteria within development are (so these are not yet available):

    + + + + +

    SET iterators:

    +

    Once the filters have been defined and the SET has been built, you can iterate the SET with the available iterator methods. +The iterator methods will walk the SET set, and call for each element within the set a function that you provide. +The following iterator methods are currently available within the SET:

    + + + +

    Planned iterators methods in development are (so these are not yet available):

    + +
      +
    • SET.ForEachUnit: Calls a function for each unit contained within the SET.
    • +
    • SET.ForEachGroup: Calls a function for each group contained within the SET.
    • +
    • SET.ForEachUnitInZone: Calls a function for each unit within a certain zone contained within the SET.
    • +
    + +
    + +

    Global(s)

    +
    DATABASE:AddClient(ClientName) +

    Adds a CLIENT based on the ClientName in the DATABASE.

    +
    DATABASE:AddUnit(DCSUnit, DCSUnitName) +

    Adds a Unit based on the Unit Name in the DATABASE.

    +
    DATABASE.ClassName @@ -160,12 +173,6 @@ The following iterator methods are currently available within the DATABASE:

    DATABASE.DCSGroups -
    DATABASE.DCSGroupsAlive -
    DATABASE.DCSUnitsAliveDATABASE:DeleteUnit(DCSUnitName) - +

    Deletes a Unit from the DATABASE based on the Unit Name.

    DATABASE.Filter -
    DATABASE:FilterCategories(Categories) -

    Builds a set of units out of categories.

    -
    DATABASE:FilterCoalitions(Coalitions) -

    Builds a set of units of coalitons.

    -
    DATABASE:FilterCountries(Countries) -

    Builds a set of units of defined countries.

    -
    DATABASE:FilterGroupPrefixes(Prefixes) -

    Builds a set of units of defined group prefixes.

    DATABASE:FilterStart()DATABASE:FindClient(ClientName) -

    Starts the filtering.

    +

    Finds a CLIENT based on the ClientName.

    DATABASE:FilterTypes(Types)DATABASE:FindUnit(UnitName) -

    Builds a set of units of defined unit types.

    -
    DATABASE:FilterUnitPrefixes(Prefixes) -

    Builds a set of units of defined unit prefixes.

    +

    Finds a Unit based on the Unit Name.

    DATABASE:ForEachDCSUnitAlive(IteratorFunction, ...)DATABASE:ForEachDCSUnit(IteratorFunction, ...)

    Interate the DATABASE and call an interator function for each alive unit, providing the Unit and optional parameters.

    DATABASE.Groups -
    DATABASE.GroupsAlive -
    DATABASE.Units -
    DATABASE.UnitsAlive -
    GROUP:GetPositionVec3()GROUP:GetPointVec3()

    Gets the current Point of the GROUP in VEC3 format.

    + + + + +
    SET + +
    +

    Type SET

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    SET:AddUnit(UnitToAdd) +

    Finds a Unit based on the Unit Name.

    +
    SET.ClassName + +
    SET.Clients + +
    SET.ClientsAlive + +
    SET.DCSGroups + +
    SET.DCSGroupsAlive + +
    SET.DCSUnits + +
    SET.DCSUnitsAlive + +
    SET.Filter + +
    SET:FilterCategories(Categories) +

    Builds a set of units out of categories.

    +
    SET:FilterCoalitions(Coalitions) +

    Builds a set of units of coalitons.

    +
    SET:FilterCountries(Countries) +

    Builds a set of units of defined countries.

    +
    SET:FilterGroupPrefixes(Prefixes) +

    Builds a set of units of defined group prefixes.

    +
    SET.FilterMeta + +
    SET:FilterStart() +

    Starts the filtering.

    +
    SET:FilterTypes(Types) +

    Builds a set of units of defined unit types.

    +
    SET:FilterUnitPrefixes(Prefixes) +

    Builds a set of units of defined unit prefixes.

    +
    SET:FindUnit(UnitName) +

    Finds a Unit based on the Unit Name.

    +
    SET:ForEach(IteratorFunction, arg, Set) +

    Interate the SET and call an interator function for the given set, providing the Object for each element within the set and optional parameters.

    +
    SET:ForEachClient(IteratorFunction, ...) +

    Interate the SET and call an interator function for each client, providing the Client to the function and optional parameters.

    +
    SET:ForEachDCSUnitAlive(IteratorFunction, ...) +

    Interate the SET and call an interator function for each alive unit, providing the Unit and optional parameters.

    +
    SET:ForEachPlayer(IteratorFunction, ...) +

    Interate the SET and call an interator function for each alive player, providing the Unit of the player and optional parameters.

    +
    SET.Groups + +
    SET.GroupsAlive + +
    SET.NavPoints + +
    SET:New() +

    Creates a new SET object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.

    +
    SET.Players + +
    SET.PlayersAlive + +
    SET:ScanEnvironment() + +
    SET.Statics + +
    SET.Templates + +
    SET:TraceDatabase() +

    Traces the current SET contents in the log ...

    +
    SET.Units + +
    SET.UnitsAlive + +
    SET:_EventOnBirth(Event) +

    Handles the OnBirth event for the alive units set.

    +
    SET:_EventOnDeadOrCrash(Event) +

    Handles the OnDead or OnCrash event for alive units set.

    +
    SET:_EventOnPlayerEnterUnit(Event) +

    Handles the OnPlayerEnterUnit event to fill the active players table (with the unit filter applied).

    +
    SET:_EventOnPlayerLeaveUnit(Event) +

    Handles the OnPlayerLeaveUnit event to clean the active players table.

    +
    SET:_IsAliveDCSGroup(DCSGroup) + +
    SET:_IsAliveDCSUnit(DCSUnit) + +
    SET:_IsIncludeDCSUnit(DCSUnit) + +
    SET:_RegisterDatabase() +

    Private method that registers all datapoints within in the mission.

    +
    SET:_RegisterPlayers() +

    Private method that registers all alive players in the mission.

    +
    + +

    Global(s)

    +
    +
    + + #SET + +SET + +
    +
    + + + +
    +
    +

    Type Set

    + +

    Type SET

    + +

    SET class

    + +

    Field(s)

    +
    +
    + + +SET:AddUnit(UnitToAdd) + +
    +
    + +

    Finds a Unit based on the Unit Name.

    + +

    Parameter

    + +

    Return value

    + +

    Unit#UNIT: +The added Unit.

    + +
    +
    +
    +
    + + #string + +SET.ClassName + +
    +
    + + + +
    +
    +
    +
    + + + +SET.Clients + +
    +
    + + + +
    +
    +
    +
    + + + +SET.ClientsAlive + +
    +
    + + + +
    +
    +
    +
    + + + +SET.DCSGroups + +
    +
    + + + +
    +
    +
    +
    + + + +SET.DCSGroupsAlive + +
    +
    + + + +
    +
    +
    +
    + + + +SET.DCSUnits + +
    +
    + + + +
    +
    +
    +
    + + + +SET.DCSUnitsAlive + +
    +
    + + + +
    +
    +
    +
    + + + +SET.Filter + +
    +
    + + + +
    +
    +
    +
    + + +SET:FilterCategories(Categories) + +
    +
    + +

    Builds a set of units out of categories.

    + + +

    Possible current categories are plane, helicopter, ground, ship.

    + +

    Parameter

    +
      +
    • + +

      #string Categories : +Can take the following values: "plane", "helicopter", "ground", "ship".

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:FilterCoalitions(Coalitions) + +
    +
    + +

    Builds a set of units of coalitons.

    + + +

    Possible current coalitions are red, blue and neutral.

    + +

    Parameter

    +
      +
    • + +

      #string Coalitions : +Can take the following values: "red", "blue", "neutral".

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:FilterCountries(Countries) + +
    +
    + +

    Builds a set of units of defined countries.

    + + +

    Possible current countries are those known within DCS world.

    + +

    Parameter

    +
      +
    • + +

      #string Countries : +Can take those country strings known within DCS world.

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:FilterGroupPrefixes(Prefixes) + +
    +
    + +

    Builds a set of units of defined group prefixes.

    + + +

    All the units starting with the given group prefixes will be included within the set.

    + +

    Parameter

    +
      +
    • + +

      #string Prefixes : +The prefix of which the group name where the unit belongs to starts with.

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + + +SET.FilterMeta + +
    +
    + + + +
    +
    +
    +
    + + +SET:FilterStart() + +
    +
    + +

    Starts the filtering.

    + +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:FilterTypes(Types) + +
    +
    + +

    Builds a set of units of defined unit types.

    + + +

    Possible current types are those types known within DCS world.

    + +

    Parameter

    +
      +
    • + +

      #string Types : +Can take those type strings known within DCS world.

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:FilterUnitPrefixes(Prefixes) + +
    +
    + +

    Builds a set of units of defined unit prefixes.

    + + +

    All the units starting with the given prefixes will be included within the set.

    + +

    Parameter

    +
      +
    • + +

      #string Prefixes : +The prefix of which the unit name starts with.

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:FindUnit(UnitName) + +
    +
    + +

    Finds a Unit based on the Unit Name.

    + +

    Parameter

    +
      +
    • + +

      #string UnitName :

      + +
    • +
    +

    Return value

    + +

    Unit#UNIT: +The found Unit.

    + +
    +
    +
    +
    + + +SET:ForEach(IteratorFunction, arg, Set) + +
    +
    + +

    Interate the SET and call an interator function for the given set, providing the Object for each element within the set and optional parameters.

    + +

    Parameters

    +
      +
    • + +

      #function IteratorFunction : +The function that will be called when there is an alive player in the SET.

      + +
    • +
    • + +

      arg :

      + +
    • +
    • + +

      Set :

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:ForEachClient(IteratorFunction, ...) + +
    +
    + +

    Interate the SET and call an interator function for each client, providing the Client to the function and optional parameters.

    + +

    Parameters

    +
      +
    • + +

      #function IteratorFunction : +The function that will be called when there is an alive player in the SET. The function needs to accept a CLIENT parameter.

      + +
    • +
    • + +

      ... :

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:ForEachDCSUnitAlive(IteratorFunction, ...) + +
    +
    + +

    Interate the SET and call an interator function for each alive unit, providing the Unit and optional parameters.

    + +

    Parameters

    +
      +
    • + +

      #function IteratorFunction : +The function that will be called when there is an alive unit in the SET. The function needs to accept a UNIT parameter.

      + +
    • +
    • + +

      ... :

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:ForEachPlayer(IteratorFunction, ...) + +
    +
    + +

    Interate the SET and call an interator function for each alive player, providing the Unit of the player and optional parameters.

    + +

    Parameters

    +
      +
    • + +

      #function IteratorFunction : +The function that will be called when there is an alive player in the SET. The function needs to accept a UNIT parameter.

      + +
    • +
    • + +

      ... :

      + +
    • +
    +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + + +SET.Groups + +
    +
    + + + +
    +
    +
    +
    + + + +SET.GroupsAlive + +
    +
    + + + +
    +
    +
    +
    + + + +SET.NavPoints + +
    +
    + + + +
    +
    +
    +
    + + +SET:New() + +
    +
    + +

    Creates a new SET object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.

    + +

    Return value

    + +

    #SET:

    + + +

    Usage:

    +
    -- Define a new SET Object. This DBObject will contain a reference to all Group and Unit Templates defined within the ME and the DCSRTE.
    +DBObject = SET:New()
    + +
    +
    +
    +
    + + + +SET.Players + +
    +
    + + + +
    +
    +
    +
    + + + +SET.PlayersAlive + +
    +
    + + + +
    +
    +
    +
    + + +SET:ScanEnvironment() + +
    +
    + + + +
    +
    +
    +
    + + + +SET.Statics + +
    +
    + + + +
    +
    +
    +
    + + + +SET.Templates + +
    +
    + + + +
    +
    +
    +
    + + +SET:TraceDatabase() + +
    +
    + +

    Traces the current SET contents in the log ...

    + + +

    (for debug reasons).

    + +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + + +SET.Units + +
    +
    + + + +
    +
    +
    +
    + + + +SET.UnitsAlive + +
    +
    + + + +
    +
    +
    +
    + + +SET:_EventOnBirth(Event) + +
    +
    + +

    Handles the OnBirth event for the alive units set.

    + +

    Parameter

    + +
    +
    +
    +
    + + +SET:_EventOnDeadOrCrash(Event) + +
    +
    + +

    Handles the OnDead or OnCrash event for alive units set.

    + +

    Parameter

    + +
    +
    +
    +
    + + +SET:_EventOnPlayerEnterUnit(Event) + +
    +
    + +

    Handles the OnPlayerEnterUnit event to fill the active players table (with the unit filter applied).

    + +

    Parameter

    + +
    +
    +
    +
    + + +SET:_EventOnPlayerLeaveUnit(Event) + +
    +
    + +

    Handles the OnPlayerLeaveUnit event to clean the active players table.

    + +

    Parameter

    + +
    +
    +
    +
    + + +SET:_IsAliveDCSGroup(DCSGroup) + +
    +
    + + + +

    Parameter

    + +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:_IsAliveDCSUnit(DCSUnit) + +
    +
    + + + +

    Parameter

    + +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:_IsIncludeDCSUnit(DCSUnit) + +
    +
    + + + +

    Parameter

    + +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:_RegisterDatabase() + +
    +
    + +

    Private method that registers all datapoints within in the mission.

    + +

    Return value

    + +

    #SET: +self

    + +
    +
    +
    +
    + + +SET:_RegisterPlayers() + +
    +
    + +

    Private method that registers all alive players in the mission.

    + +

    Return value

    + +

    #SET: +self

    + +
    +
    + + + + + + diff --git a/Documentation/Spawn.html b/Documentation/Spawn.html index 2f5ba12ef..b0c92b062 100644 --- a/Documentation/Spawn.html +++ b/Documentation/Spawn.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/TASK.html b/Documentation/TASK.html index d18c673ff..fee28dd8f 100644 --- a/Documentation/TASK.html +++ b/Documentation/TASK.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Documentation/Unit.html b/Documentation/Unit.html index f08c9006c..c55741f7e 100644 --- a/Documentation/Unit.html +++ b/Documentation/Unit.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • @@ -53,7 +54,43 @@

    Module Unit

    -

    UNIT Classes

    +

    UNIT Class

    + +

    UNIT class

    +

    The UNIT class is a wrapper class to handle the DCS Unit objects:

    + + + + + + + +

    UNIT reference methods

    +

    For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _DATABASE object. +This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the SPAWN class).

    + +

    The UNIT class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference +using the DCS Unit or the DCS UnitName.

    + +

    Another thing to know is that UNIT objects do not "contain" the DCS Unit object. +The UNIT methods will reference the DCS Unit object by name when it is needed during API execution. +If the DCS Unit object does not exist or is nil, the UNIT methods will return nil and log an exception in the DCS.log file.

    + +

    The UNIT class provides the following functions to retrieve quickly the relevant UNIT instance:

    + + + +

    IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil).

    +

    Global(s)

    @@ -76,6 +113,18 @@ + + + + + + + + @@ -112,6 +161,12 @@ + + + + @@ -129,7 +184,7 @@ @@ -189,7 +244,7 @@ @@ -207,19 +262,25 @@ + + + + @@ -241,19 +302,19 @@ @@ -272,24 +333,18 @@ - - - - - - - - + + + + @@ -446,6 +501,60 @@ + + +
    +
    + + +UNIT:Find(DCSUnit) + +
    +
    + +

    Finds a UNIT from the _DATABASE using a DCSUnit object.

    + +

    Parameter

    +
      +
    • + +

      DCSUnit#Unit DCSUnit : +An existing DCS Unit object reference.

      + +
    • +
    +

    Return value

    + +

    Unit#UNIT: +self

    + +
    +
    +
    +
    + + +UNIT:FindByName(UnitName) + +
    +
    + +

    Find a UNIT in the _DATABASE using the name of an existing DCS Unit.

    + +

    Parameter

    +
      +
    • + +

      #string UnitName : +The Unit Name.

      + +
    • +
    +

    Return value

    + +

    Unit#UNIT: +self

    +
    @@ -538,6 +647,34 @@
    + +UNIT:GetAltitude() + +
    +
    + +

    Returns the altitude of the DCS Unit.

    + +

    Return values

    +
      +
    1. + +

      DCSTypes#Distance: +The altitude of the DCS Unit.

      + +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    +
    +
    +
    +
    + UNIT:GetAmmo() @@ -546,11 +683,21 @@

    Returns the Unit's ammunition.

    -

    Return value

    +

    Return values

    +
      +
    1. DCSUnit#Unit.Ammo:

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -564,11 +711,21 @@

    Returns the unit's callsign - the localized string.

    -

    Return value

    +

    Return values

    +
      +
    1. #string: The Callsign of the Unit.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -580,12 +737,12 @@ The Callsign of the Unit.

    -

    Returns the Unit's Category Name as defined within the Unit's Descriptor.

    +

    Returns the DCS Unit category name as defined within the DCS Unit Descriptor.

    Return value

    #string: -Unit's Category Name

    +The DCS Unit Category Name

    @@ -600,11 +757,21 @@ Unit's Category Name

    Returns coalition of the Unit.

    -

    Return value

    +

    Return values

    +
      +
    1. -

      DCSCoalitionObject#coalition.side:

      +

      DCSCoalitionObject#coalition.side: +The side of the coalition.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      +
    4. +
    @@ -618,11 +785,21 @@ Unit's Category Name

    Returns country of the Unit.

    -

    Return value

    +

    Return values

    +
      +
    1. DCScountry#country.id: -The country identifyer.

      +The country identifier.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -652,11 +829,21 @@ The country identifyer.

    Descriptor type depends on unit category.

    -

    Return value

    +

    Return values

    +
      +
    1. DCSUnit#Unit.Desc: The Unit descriptor.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -673,11 +860,21 @@ The Unit descriptor.

    If there are additional fuel tanks the value may be greater than 1.0.

    -

    Return value

    +

    Return values

    +
      +
    1. #number: The relative amount of fuel (from 0.0 to 1.0).

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -691,11 +888,21 @@ The relative amount of fuel (from 0.0 to 1.0).

    Returns the unit's group if it exist and nil otherwise.

    -

    Return value

    +

    Return values

    +
      +
    1. Group#GROUP: The Group of the Unit.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -709,11 +916,21 @@ The Group of the Unit.

    Returns the unit's unique identifier.

    -

    Return value

    +

    Return values

    +
      +
    1. DCSUnit#Unit.ID: Unit ID

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -730,11 +947,21 @@ Unit ID

    Dead units has health <= 1.0.

    -

    Return value

    +

    Return values

    +
      +
    1. #number: The Unit's health value.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -748,11 +975,21 @@ The Unit's health value.

    Returns the Unit's initial health.

    -

    Return value

    +

    Return values

    +
      +
    1. #number: The Unit's initial health value.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -764,13 +1001,26 @@ The Unit's initial health value.

    -

    Returns unit object by the name assigned to the unit in Mission Editor.

    +

    Returns DCS Unit object name.

    -

    If there is unit with such name or the unit is destroyed the function will return nil. -The function provides access to non-activated units too. -

    +

    The function provides access to non-activated units too.

    +

    Return values

    +
      +
    1. + +

      #string: +The name of the DCS Unit.

      + +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -789,11 +1039,21 @@ The function provides access to non-activated units too. It may not be changed during the mission. If any unit in the group is destroyed, the numbers of another units will not be changed.

    -

    Return value

    +

    Return values

    +
      +
    1. #number: The Unit number.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -807,11 +1067,21 @@ The Unit number.

    Returns name of the player that control the unit or nil if the unit is controlled by A.I.

    -

    Return value

    +

    Return values

    +
      +
    1. #string: Player Name

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -823,8 +1093,51 @@ Player Name

    +

    Returns the DCSTypes#Vec2 vector indicating the point in 2D of the DCS Unit within the mission.

    +

    Return values

    +
      +
    1. + +

      DCSTypes#Vec2: +The 2D point vector of the DCS Unit.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    +
    +
    +
    +
    + + +UNIT:GetPointVec3() + +
    +
    + +

    Returns the DCSTypes#Vec3 vector indicating the point in 3D of the DCS Unit within the mission.

    + +

    Return values

    +
      +
    1. + +

      DCSTypes#Vec3: +The 3D point vector of the DCS Unit.

      + +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -836,8 +1149,23 @@ Player Name

    +

    Returns the DCSTypes#Position3 position vectors indicating the point and direction vectors in 3D of the DCS Unit within the mission.

    +

    Return values

    +
      +
    1. + +

      DCSTypes#Position: +The 3D position vectors of the DCS Unit.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -849,8 +1177,28 @@ Player Name

    +

    Returns the prefix name of the DCS Unit.

    + +

    A prefix name is a part of the name before a '#'-sign. +DCS Units spawned with the SPAWN class contain a '#'-sign to indicate the end of the (base) DCS Unit name. +The spawn sequence number and unit number are contained within the name after the '#' sign.

    +

    Return values

    +
      +
    1. + +

      #string: +The name of the DCS Unit.

      + +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -886,6 +1234,12 @@ Player Name

    DCSObject#Object: The object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.

    + +
  • + +

    #nil: +The DCS Unit is not existing or alive.

    +
  • @@ -901,11 +1255,21 @@ The object of the radar's interest. Not nil only if at least one radar of the un

    Returns the unit sensors.

    -

    Return value

    +

    Return values

    +
      +
    1. DCSUnit#Unit.Sensors:

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -917,8 +1281,23 @@ The object of the radar's interest. Not nil only if at least one radar of the un
    +

    Returns the type name of the DCS Unit.

    +

    Return values

    +
      +
    1. + +

      #string: +The type name of the DCS Unit.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -930,13 +1309,23 @@ The object of the radar's interest. Not nil only if at least one radar of the un
    -

    Returns the unit's velocity vector.

    +

    Returns the DCS Unit velocity vector.

    -

    Return value

    +

    Return values

    +
      +
    1. DCSTypes#Vec3: -Velocity Vector

      +The velocity vector

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -948,13 +1337,23 @@ Velocity Vector

    -

    Returns true if the Unit is in air.

    +

    Returns true if the DCS Unit is in the air.

    -

    Return value

    +

    Return values

    +
      +
    1. #boolean: true if in the air.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -968,11 +1367,21 @@ true if in the air.

    Returns if the unit is activated.

    -

    Return value

    +

    Return values

    +
      +
    1. #boolean: true if Unit is activated.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    @@ -1007,56 +1416,87 @@ Air category evaluation result.

    Returns if the unit is alive.

    -

    Return value

    +

    Return values

    +
      +
    1. #boolean: true if Unit is alive.

      +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    - -UNIT:New(DCSUnit) + +UNIT:OtherUnitInRadius(AwaitUnit, Radius) + +
    +
    + +

    Returns true if there is an other DCS Unit within a radius of the current 2D point of the DCS Unit.

    + +

    Parameters

    +
      +
    • + +

      Unit#UNIT AwaitUnit : +The other UNIT wrapper object.

      + +
    • +
    • + +

      Radius : +The radius in meters with the DCS Unit in the centre.

      + +
    • +
    +

    Return values

    +
      +
    1. + + +

      true If the other DCS Unit is within the radius of the 2D point of the DCS Unit.

      + +
    2. +
    3. + +

      #nil: +The DCS Unit is not existing or alive.

      + +
    4. +
    +
    +
    +
    +
    + + +UNIT:Register(DCSUnit, Database, UnitName)

    Create a new UNIT from DCSUnit.

    -

    Parameter

    +

    Parameters

    -

    Return value

    - -

    Unit#UNIT:

    - - -
    -
    -
    -
    - - -UNIT:NewFromName(Unit, UnitName) - -
    -
    - -

    Create a new UNIT from a Unit Name.

    - -

    Parameters

    -
    + + + + @@ -224,7 +231,14 @@ diff --git a/Documentation/routines.html b/Documentation/routines.html index 806bd57e3..6dd92ef95 100644 --- a/Documentation/routines.html +++ b/Documentation/routines.html @@ -43,6 +43,7 @@
  • Scheduler
  • Scoring
  • Sead
  • +
  • Set
  • Spawn
  • TASK
  • Unit
  • diff --git a/Moose/Unit.lua b/Moose/Unit.lua index 16e585f5e..99d13daf2 100644 --- a/Moose/Unit.lua +++ b/Moose/Unit.lua @@ -1,5 +1,36 @@ ---- UNIT Classes +--- UNIT Class +-- +-- @{UNIT} class +-- ============== +-- The @{UNIT} class is a wrapper class to handle the DCS Unit objects: +-- +-- * Support all DCS Unit APIs. +-- * Enhance with Unit specific APIs not in the DCS Unit API set. +-- * Handle local Unit Controller. +-- * Manage the "state" of the objects. +-- +-- +-- UNIT reference methods +-- ====================== +-- For each DCS Unit object alive within a running mission, a UNIT wrapper object (instance) will be created within the _@{DATABASE} object. +-- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Unit objects are spawned (using the @{SPAWN} class). +-- +-- The UNIT class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference +-- using the DCS Unit or the DCS UnitName. +-- +-- Another thing to know is that UNIT objects do not "contain" the DCS Unit object. +-- The UNIT methods will reference the DCS Unit object by name when it is needed during API execution. +-- If the DCS Unit object does not exist or is nil, the UNIT methods will return nil and log an exception in the DCS.log file. +-- +-- The UNIT class provides the following functions to retrieve quickly the relevant UNIT instance: +-- +-- * @{#UNIT.Find}(): Find a UNIT instance from the _DATABASE object using a DCS Unit object. +-- * @{#UNIT.FindByName}(): Find a UNIT instance from the _DATABASE object using a DCS Unit object. +-- +-- IMPORTANT: ONE SHOULD NEVER SANATIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil). +-- -- @module Unit +-- @author FlightControl Include.File( "Routines" ) Include.File( "Base" ) @@ -65,8 +96,8 @@ end --- Finds a UNIT from the _DATABASE using a DCSUnit object. -- @param #UNIT self --- @param DCSUnit#Unit DCSUnit --- @return Unit#UNIT +-- @param DCSUnit#Unit DCSUnit An existing DCS Unit object reference. +-- @return Unit#UNIT self function UNIT:Find( DCSUnit ) local UnitName = DCSUnit:getName() @@ -74,10 +105,10 @@ function UNIT:Find( DCSUnit ) return UnitFound end ---- Find a UNIT in the _DATABASE using the name of the UNIT. +--- Find a UNIT in the _DATABASE using the name of an existing DCS Unit. -- @param #UNIT self --- @param #string Unit Name --- @return Unit#UNIT +-- @param #string UnitName The Unit Name. +-- @return Unit#UNIT self function UNIT:FindByName( UnitName ) -- self:F( UnitName ) @@ -97,7 +128,8 @@ end --- Returns coalition of the Unit. -- @param Unit#UNIT self --- @return DCSCoalitionObject#coalition.side +-- @return DCSCoalitionObject#coalition.side The side of the coalition. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetCoalition() self:F( self.UnitName ) @@ -114,7 +146,8 @@ end --- Returns country of the Unit. -- @param Unit#UNIT self --- @return DCScountry#country.id The country identifyer. +-- @return DCScountry#country.id The country identifier. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetCountry() self:F( self.UnitName ) @@ -130,10 +163,11 @@ function UNIT:GetCountry() end ---- Returns unit object by the name assigned to the unit in Mission Editor. --- If there is unit with such name or the unit is destroyed the function will return nil. +--- Returns DCS Unit object name. -- The function provides access to non-activated units too. --- +-- @param Unit#UNIT self +-- @return #string The name of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetName() self:F( self.UnitName ) @@ -151,6 +185,7 @@ end --- Returns if the unit is alive. -- @param Unit#UNIT self -- @return #boolean true if Unit is alive. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:IsAlive() self:F( self.UnitName ) @@ -167,6 +202,7 @@ end --- Returns if the unit is activated. -- @param Unit#UNIT self -- @return #boolean true if Unit is activated. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:IsActive() self:F( self.UnitName ) @@ -184,6 +220,7 @@ end --- Returns name of the player that control the unit or nil if the unit is controlled by A.I. -- @param Unit#UNIT self -- @return #string Player Name +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetPlayerName() self:F( self.UnitName ) @@ -204,6 +241,7 @@ end --- Returns the unit's unique identifier. -- @param Unit#UNIT self -- @return DCSUnit#Unit.ID Unit ID +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetID() self:F( self.UnitName ) @@ -223,6 +261,7 @@ end -- If any unit in the group is destroyed, the numbers of another units will not be changed. -- @param Unit#UNIT self -- @return #number The Unit number. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetNumber() self:F( self.UnitName ) @@ -239,6 +278,7 @@ end --- Returns the unit's group if it exist and nil otherwise. -- @param Unit#UNIT self -- @return Group#GROUP The Group of the Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetGroup() self:F( self.UnitName ) @@ -256,6 +296,7 @@ end --- Returns the unit's callsign - the localized string. -- @param Unit#UNIT self -- @return #string The Callsign of the Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetCallSign() self:F( self.UnitName ) @@ -272,6 +313,7 @@ end --- Returns the unit's health. Dead units has health <= 1.0. -- @param Unit#UNIT self -- @return #number The Unit's health value. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetLife() self:F( self.UnitName ) @@ -288,6 +330,7 @@ end --- Returns the Unit's initial health. -- @param Unit#UNIT self -- @return #number The Unit's initial health value. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetLife0() self:F( self.UnitName ) @@ -304,6 +347,7 @@ end --- Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks. If there are additional fuel tanks the value may be greater than 1.0. -- @param Unit#UNIT self -- @return #number The relative amount of fuel (from 0.0 to 1.0). +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetFuel() self:F( self.UnitName ) @@ -320,6 +364,7 @@ end --- Returns the Unit's ammunition. -- @param Unit#UNIT self -- @return DCSUnit#Unit.Ammo +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetAmmo() self:F( self.UnitName ) @@ -336,6 +381,7 @@ end --- Returns the unit sensors. -- @param Unit#UNIT self -- @return DCSUnit#Unit.Sensors +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetSensors() self:F( self.UnitName ) @@ -359,6 +405,7 @@ end -- @param Unit#UNIT self -- @return #boolean Indicates if at least one of the unit's radar(s) is on. -- @return DCSObject#Object The object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetRadar() self:F( self.UnitName ) @@ -377,6 +424,7 @@ end --- Returns unit descriptor. Descriptor type depends on unit category. -- @param Unit#UNIT self -- @return DCSUnit#Unit.Desc The Unit descriptor. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetDesc() self:F( self.UnitName ) @@ -391,7 +439,10 @@ function UNIT:GetDesc() end - +--- Returns the type name of the DCS Unit. +-- @param Unit#UNIT self +-- @return #string The type name of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetTypeName() self:F( self.UnitName ) @@ -406,16 +457,34 @@ function UNIT:GetTypeName() return nil end + + +--- Returns the prefix name of the DCS Unit. A prefix name is a part of the name before a '#'-sign. +-- DCS Units spawned with the @{SPAWN} class contain a '#'-sign to indicate the end of the (base) DCS Unit name. +-- The spawn sequence number and unit number are contained within the name after the '#' sign. +-- @param Unit#UNIT self +-- @return #string The name of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetPrefix() self:F( self.UnitName ) + + local DCSUnit = self:GetDCSUnit() - local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 ) - self:T( UnitPrefix ) - return UnitPrefix + if DCSUnit then + local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 ) + self:T( UnitPrefix ) + return UnitPrefix + end + + return nil end +--- Returns the @{DCSTypes#Vec2} vector indicating the point in 2D of the DCS Unit within the mission. +-- @param Unit#UNIT self +-- @return DCSTypes#Vec2 The 2D point vector of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetPointVec2() self:F( self.UnitName ) @@ -436,6 +505,10 @@ function UNIT:GetPointVec2() end +--- Returns the @{DCSTypes#Vec3} vector indicating the point in 3D of the DCS Unit within the mission. +-- @param Unit#UNIT self +-- @return DCSTypes#Vec3 The 3D point vector of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetPointVec3() self:F( self.UnitName ) @@ -450,6 +523,10 @@ function UNIT:GetPointVec3() return nil end +--- Returns the @{DCSTypes#Position3} position vectors indicating the point and direction vectors in 3D of the DCS Unit within the mission. +-- @param Unit#UNIT self +-- @return DCSTypes#Position The 3D position vectors of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetPositionVec3() self:F( self.UnitName ) @@ -464,9 +541,10 @@ function UNIT:GetPositionVec3() return nil end ---- Returns the unit's velocity vector. +--- Returns the DCS Unit velocity vector. -- @param Unit#UNIT self --- @return DCSTypes#Vec3 Velocity Vector +-- @return DCSTypes#Vec3 The velocity vector +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetVelocity() self:F( self.UnitName ) @@ -481,9 +559,10 @@ function UNIT:GetVelocity() return nil end ---- Returns true if the Unit is in air. +--- Returns true if the DCS Unit is in the air. -- @param Unit#UNIT self -- @return #boolean true if in the air. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:InAir() self:F( self.UnitName ) @@ -498,9 +577,10 @@ function UNIT:InAir() return nil end ---- Returns the altitude of the UNIT. --- @param #UNIT self --- @return DCSTypes#Distance +--- Returns the altitude of the DCS Unit. +-- @param Unit#UNIT self +-- @return DCSTypes#Distance The altitude of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:GetAltitude() self:F() @@ -514,27 +594,36 @@ function UNIT:GetAltitude() return nil end +--- Returns true if there is an **other** DCS Unit within a radius of the current 2D point of the DCS Unit. +-- @param Unit#UNIT self +-- @param Unit#UNIT AwaitUnit The other UNIT wrapper object. +-- @param Radius The radius in meters with the DCS Unit in the centre. +-- @return true If the other DCS Unit is within the radius of the 2D point of the DCS Unit. +-- @return #nil The DCS Unit is not existing or alive. function UNIT:OtherUnitInRadius( AwaitUnit, Radius ) self:F( { self.UnitName, AwaitUnit.UnitName, Radius } ) - local UnitPos = self:GetPointVec3() - local AwaitUnitPos = AwaitUnit:GetPointVec3() + local DCSUnit = self:GetDCSUnit() + + if DCSUnit then + local UnitPos = self:GetPointVec3() + local AwaitUnitPos = AwaitUnit:GetPointVec3() + + if (((UnitPos.x - AwaitUnitPos.x)^2 + (UnitPos.z - AwaitUnitPos.z)^2)^0.5 <= Radius) then + self:T( "true" ) + return true + else + self:T( "false" ) + return false + end + end - if (((UnitPos.x - AwaitUnitPos.x)^2 + (UnitPos.z - AwaitUnitPos.z)^2)^0.5 <= Radius) then - self:T( "true" ) - return true - else - self:T( "false" ) - return false - end - - self:T( "false" ) - return false + return nil end ---- Returns the Unit's Category Name as defined within the Unit's Descriptor. +--- Returns the DCS Unit category name as defined within the DCS Unit Descriptor. -- @param Unit#UNIT self --- @return #string Unit's Category Name +-- @return #string The DCS Unit Category Name function UNIT:GetCategoryName() local DCSUnit = self:GetDCSUnit() diff --git a/Presentations/DCS World - MOOSE - Development - Part 3 - The DATABASE - UNIT - CLIENT - GROUP - ZONE, .pptx b/Presentations/DCS World - MOOSE - Development - Part 3 - The DATABASE - UNIT - CLIENT - GROUP - ZONE, .pptx index 26c9e4bc1..fbb0df741 100644 Binary files a/Presentations/DCS World - MOOSE - Development - Part 3 - The DATABASE - UNIT - CLIENT - GROUP - ZONE, .pptx and b/Presentations/DCS World - MOOSE - Development - Part 3 - The DATABASE - UNIT - CLIENT - GROUP - ZONE, .pptx differ
    UNIT.ClassName +
    UNIT:Find(DCSUnit) +

    Finds a UNIT from the _DATABASE using a DCSUnit object.

    +
    UNIT:FindByName(UnitName) +

    Find a UNIT in the _DATABASE using the name of an existing DCS Unit.

    UNIT:FlareYellow()

    Signal a yellow flare at the position of the UNIT.

    +
    UNIT:GetAltitude() +

    Returns the altitude of the DCS Unit.

    UNIT:GetCategoryName() -

    Returns the Unit's Category Name as defined within the Unit's Descriptor.

    +

    Returns the DCS Unit category name as defined within the DCS Unit Descriptor.

    UNIT:GetName() -

    Returns unit object by the name assigned to the unit in Mission Editor.

    +

    Returns DCS Unit object name.

    UNIT:GetPointVec2() - +

    Returns the DCSTypes#Vec2 vector indicating the point in 2D of the DCS Unit within the mission.

    +
    UNIT:GetPointVec3() +

    Returns the DCSTypes#Vec3 vector indicating the point in 3D of the DCS Unit within the mission.

    UNIT:GetPositionVec3() - +

    Returns the DCSTypes#Position3 position vectors indicating the point and direction vectors in 3D of the DCS Unit within the mission.

    UNIT:GetPrefix() - +

    Returns the prefix name of the DCS Unit.

    UNIT:GetTypeName() - +

    Returns the type name of the DCS Unit.

    UNIT:GetVelocity() -

    Returns the unit's velocity vector.

    +

    Returns the DCS Unit velocity vector.

    UNIT:InAir() -

    Returns true if the Unit is in air.

    +

    Returns true if the DCS Unit is in the air.

    UNIT:IsAlive()

    Returns if the unit is alive.

    -
    UNIT:New(DCSUnit) -

    Create a new UNIT from DCSUnit.

    -
    UNIT:NewFromName(Unit, UnitName) -

    Create a new UNIT from a Unit Name.

    UNIT:OtherUnitInRadius(AwaitUnit, Radius) - +

    Returns true if there is an other DCS Unit within a radius of the current 2D point of the DCS Unit.

    +
    UNIT:Register(DCSUnit, Database, UnitName) +

    Create a new UNIT from DCSUnit.

    Sead

    Provides defensive behaviour to a set of SAM sites within a running Mission.

    +
    Set +

    Manage sets of units and groups.

    Unit -

    UNIT Classes

    +

    UNIT Class

    + +

    UNIT class

    +

    The UNIT class is a wrapper class to handle the DCS Unit objects:

    + +
      +
    • Support all DCS Unit APIs.
    • +