diff --git a/Documentation/Base.html b/Documentation/Base.html index acc2db22f..de608bcaf 100644 --- a/Documentation/Base.html +++ b/Documentation/Base.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -127,6 +130,12 @@ BASE:EnableEvents()

    Enable the event listeners for the class.

    + + + + BASE:Event() + +

    Returns the event dispatcher

    @@ -467,6 +476,24 @@ A #table or any field.

    #BASE:

    + + +
    +
    + + +BASE:Event() + +
    +
    + +

    Returns the event dispatcher

    + +

    Return value

    + +

    Event#EVENT:

    + +
    diff --git a/Documentation/CARGO.html b/Documentation/CARGO.html index d8ed385dc..30d778ea2 100644 --- a/Documentation/CARGO.html +++ b/Documentation/CARGO.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/CLEANUP.html b/Documentation/CLEANUP.html index 38ddbe76b..4d2aa04a7 100644 --- a/Documentation/CLEANUP.html +++ b/Documentation/CLEANUP.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -139,27 +142,33 @@ - CLEANUP:_EventAddForCleanUp(event) + CLEANUP:_EventAddForCleanUp(event, Event)

    Detects if the Unit has an SEVENTENGINESHUTDOWN or an SEVENT_HIT within the given ZoneNames.

    - CLEANUP:_EventCrash(event) + CLEANUP:_EventCrash(event, Event)

    Detects if a crash event occurs.

    - CLEANUP:_EventHitCleanUp(event) + CLEANUP:_EventHitCleanUp(event, Event)

    Detects if the Unit has an SEVENTHIT within the given ZoneNames.

    - CLEANUP:_EventShot(event) + CLEANUP:_EventShot(event, Event)

    Detects if a unit shoots a missile.

    + + + + CLEANUP:_OnEventBirth(Event) + + @@ -394,7 +403,7 @@ The Unit name ...

    -CLEANUP:_EventAddForCleanUp(event) +CLEANUP:_EventAddForCleanUp(event, Event)
    @@ -404,12 +413,17 @@ The Unit name ...

    If this is the case, add the Group to the CLEANUP List.

    -

    Parameter

    +

    Parameters

    @@ -418,7 +432,7 @@ The Unit name ...

    -CLEANUP:_EventCrash(event) +CLEANUP:_EventCrash(event, Event)
    @@ -428,12 +442,17 @@ The Unit name ...

    Crashed units go into a CleanUpList for removal.

    -

    Parameter

    +

    Parameters

    @@ -442,7 +461,7 @@ The Unit name ...

    -CLEANUP:_EventHitCleanUp(event) +CLEANUP:_EventHitCleanUp(event, Event)
    @@ -452,12 +471,17 @@ The Unit name ...

    If this is the case, destroy the unit.

    -

    Parameter

    +

    Parameters

    @@ -466,7 +490,7 @@ The Unit name ...

    -CLEANUP:_EventShot(event) +CLEANUP:_EventShot(event, Event)
    @@ -476,12 +500,38 @@ The Unit name ...

    If this occurs within one of the zones, then the weapon used must be destroyed.

    -

    Parameter

    +

    Parameters

    +
    +
    +
    +
    + + +CLEANUP:_OnEventBirth(Event) + +
    +
    + + + +

    Parameter

    +
    diff --git a/Documentation/Client.html b/Documentation/Client.html index 267f2232c..6ea751dae 100644 --- a/Documentation/Client.html +++ b/Documentation/Client.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -92,7 +95,7 @@ Note that clients are NOT the same as groups, they are NOT necessarily alive. - CLIENT:Alive(CallBack) + CLIENT:Alive(CallBack, ...)

    Checks for a client alive event and calls a function on a continuous basis.

    @@ -167,6 +170,12 @@ Note that clients are NOT the same as groups, they are NOT necessarily alive. CLIENT.ClientName + + + + CLIENT.ClientParameters + + @@ -400,20 +409,25 @@ is the text defining the Mission briefing.

    -CLIENT:Alive(CallBack) +CLIENT:Alive(CallBack, ...)

    Checks for a client alive event and calls a function on a continuous basis.

    -

    Parameter

    +

    Parameters

    Return value

    @@ -587,6 +601,20 @@ Function.

    +
    +
    +
    +
    + + + +CLIENT.ClientParameters + +
    +
    + + +
    diff --git a/Documentation/DCSAirbase.html b/Documentation/DCSAirbase.html index 06def6538..5ba906d1e 100644 --- a/Documentation/DCSAirbase.html +++ b/Documentation/DCSAirbase.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSCoalitionObject.html b/Documentation/DCSCoalitionObject.html index 620eb80ef..e0a1741e8 100644 --- a/Documentation/DCSCoalitionObject.html +++ b/Documentation/DCSCoalitionObject.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSCommand.html b/Documentation/DCSCommand.html index 3e3bda254..e5cb77601 100644 --- a/Documentation/DCSCommand.html +++ b/Documentation/DCSCommand.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSController.html b/Documentation/DCSController.html index c82205e73..05bd95b0e 100644 --- a/Documentation/DCSController.html +++ b/Documentation/DCSController.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSGroup.html b/Documentation/DCSGroup.html index 95570211c..9f2258624 100644 --- a/Documentation/DCSGroup.html +++ b/Documentation/DCSGroup.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSObject.html b/Documentation/DCSObject.html index e91080656..017a27b88 100644 --- a/Documentation/DCSObject.html +++ b/Documentation/DCSObject.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSTask.html b/Documentation/DCSTask.html index f61a7da26..4f42d8760 100644 --- a/Documentation/DCSTask.html +++ b/Documentation/DCSTask.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSTypes.html b/Documentation/DCSTypes.html index 65ec9e2d2..7eb5381e2 100644 --- a/Documentation/DCSTypes.html +++ b/Documentation/DCSTypes.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSUnit.html b/Documentation/DCSUnit.html index 36e77d5a5..7b78a1fd6 100644 --- a/Documentation/DCSUnit.html +++ b/Documentation/DCSUnit.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DCSWorld.html b/Documentation/DCSWorld.html new file mode 100644 index 000000000..e1dc25088 --- /dev/null +++ b/Documentation/DCSWorld.html @@ -0,0 +1,609 @@ + + + + + + +
    +
    + +
    +
    +
    +
    + +
    +

    Module DCSWorld

    + + + +

    Global(s)

    + + + + + +
    world + +
    +

    Type world

    + + + + + +
    world.event + +
    + +

    Type world.event

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    world.event.S_EVENT_BASE_CAPTURED + +
    world.event.S_EVENT_BIRTH + +
    world.event.S_EVENT_CRASH + +
    world.event.S_EVENT_DEAD + +
    world.event.S_EVENT_EJECTION + +
    world.event.S_EVENT_ENGINE_SHUTDOWN + +
    world.event.S_EVENT_ENGINE_STARTUP + +
    world.event.S_EVENT_HIT + +
    world.event.S_EVENT_HUMAN_FAILURE + +
    world.event.S_EVENT_INVALID + +
    world.event.S_EVENT_LAND + +
    world.event.S_EVENT_MAX + +
    world.event.S_EVENT_MISSION_END + +
    world.event.S_EVENT_MISSION_START + +
    world.event.S_EVENT_PILOT_DEAD + +
    world.event.S_EVENT_PLAYER_COMMENT + +
    world.event.S_EVENT_PLAYER_ENTER_UNIT + +
    world.event.S_EVENT_PLAYER_LEAVE_UNIT + +
    world.event.S_EVENT_REFUELING + +
    world.event.S_EVENT_REFUELING_STOP + +
    world.event.S_EVENT_SHOOTING_END + +
    world.event.S_EVENT_SHOOTING_START + +
    world.event.S_EVENT_SHOT + +
    world.event.S_EVENT_TAKEOFF + +
    world.event.S_EVENT_TOOK_CONTROL + +
    + +

    Global(s)

    +
    +
    + + #world + +world + +
    +
    + + + +
    +
    +

    Type DCSWorld

    + +

    Type world

    +

    Field(s)

    +
    +
    + + #world.event + +world.event + +
    +
    + + + +
    +
    + +

    Type world.event

    +

    Field(s)

    +
    +
    + + +world.event.S_EVENT_BASE_CAPTURED + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_BIRTH + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_CRASH + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_DEAD + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_EJECTION + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_ENGINE_SHUTDOWN + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_ENGINE_STARTUP + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_HIT + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_HUMAN_FAILURE + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_INVALID + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_LAND + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_MAX + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_MISSION_END + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_MISSION_START + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_PILOT_DEAD + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_PLAYER_COMMENT + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_PLAYER_ENTER_UNIT + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_PLAYER_LEAVE_UNIT + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_REFUELING + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_REFUELING_STOP + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_SHOOTING_END + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_SHOOTING_START + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_SHOT + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_TAKEOFF + +
    +
    + + + +
    +
    +
    +
    + + +world.event.S_EVENT_TOOK_CONTROL + +
    +
    + + + +
    +
    + +
    + +
    + + diff --git a/Documentation/DCStimer.html b/Documentation/DCStimer.html index f0d1c0309..1ee0f7a2c 100644 --- a/Documentation/DCStimer.html +++ b/Documentation/DCStimer.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DEPLOYTASK.html b/Documentation/DEPLOYTASK.html index ca255eb58..846eb6968 100644 --- a/Documentation/DEPLOYTASK.html +++ b/Documentation/DEPLOYTASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DESTROYBASETASK.html b/Documentation/DESTROYBASETASK.html index acfceb720..e239668bd 100644 --- a/Documentation/DESTROYBASETASK.html +++ b/Documentation/DESTROYBASETASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -97,7 +100,7 @@ - DESTROYBASETASK.EventDead(event, self) + DESTROYBASETASK:EventDead(Event)

    Handle the SEVENTDEAD events to validate the destruction of units for the task monitoring.

    @@ -109,7 +112,7 @@ - DESTROYBASETASK.New(string, string, table, ?, self, DestroyGroupType, DestroyUnitType, DestroyGroupPrefixes, DestroyPercentage) + DESTROYBASETASK:New(DestroyGroupType, DestroyUnitType, <, DestroyPercentage, DestroyGroupPrefixes)

    Creates a new DESTROYBASETASK.

    @@ -188,25 +191,19 @@
    -DESTROYBASETASK.EventDead(event, self) +DESTROYBASETASK:EventDead(Event)

    Handle the SEVENTDEAD events to validate the destruction of units for the task monitoring.

    -

    Parameters

    +

    Parameter

    • -

      event :

      -
          Event structure of DCS world.
      -
      - -
    • -
    • - -

      self :

      +

      Event#EVENTDATA Event : +structure of MOOSE.

    @@ -230,7 +227,7 @@
    -DESTROYBASETASK.New(string, string, table, ?, self, DestroyGroupType, DestroyUnitType, DestroyGroupPrefixes, DestroyPercentage) +DESTROYBASETASK:New(DestroyGroupType, DestroyUnitType, <, DestroyPercentage, DestroyGroupPrefixes)
    @@ -241,52 +238,32 @@
    • -

      string : -DestroyGroupType Text describing the group to be destroyed. f.e. "Radar Installations", "Ships", "Vehicles", "Command Centers".

      +

      #string DestroyGroupType : +Text describing the group to be destroyed. f.e. "Radar Installations", "Ships", "Vehicles", "Command Centers".

    • -

      string : -DestroyUnitType Text describing the unit types to be destroyed. f.e. "SA-6", "Row Boats", "Tanks", "Tents".

      +

      #string DestroyUnitType : +Text describing the unit types to be destroyed. f.e. "SA-6", "Row Boats", "Tanks", "Tents".

    • -

      table : -string,...} DestroyGroupPrefixes Table of Prefixes of the Groups to be destroyed before task is completed.

      +

      #list < : +string> DestroyGroupPrefixes Table of Prefixes of the Groups to be destroyed before task is completed.

    • -

      ? : -umber DestroyPercentage defines the %-tage that needs to be destroyed to achieve mission success. eg. If in the Group there are 10 units, then a value of 75 would require 8 units to be destroyed from the Group to complete the TASK.

      - -
    • -
    • - -

      self :

      - -
    • -
    • - -

      DestroyGroupType :

      - -
    • -
    • - -

      DestroyUnitType :

      +

      #number DestroyPercentage : +defines the %-tage that needs to be destroyed to achieve mission success. eg. If in the Group there are 10 units, then a value of 75 would require 8 units to be destroyed from the Group to complete the TASK.

    • DestroyGroupPrefixes :

      -
    • -
    • - -

      DestroyPercentage :

      -

    Return value

    @@ -332,6 +309,8 @@ umber DestroyPercentage defines the %-tage that needs to be destroyed to achieve
    +

    Type list

    + diff --git a/Documentation/DESTROYGROUPSTASK.html b/Documentation/DESTROYGROUPSTASK.html index dd4fc57c6..0307805d5 100644 --- a/Documentation/DESTROYGROUPSTASK.html +++ b/Documentation/DESTROYGROUPSTASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -88,13 +91,13 @@ - DESTROYGROUPSTASK.New(string, string, table, ?, self, DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage) + DESTROYGROUPSTASK:New(DestroyGroupType, DestroyUnitType, <, DestroyPercentage, DestroyGroupNames)

    Creates a new DESTROYGROUPSTASK.

    - DESTROYGROUPSTASK.ReportGoalProgress(Group, Unit, self, DestroyGroup, DestroyUnit) + DESTROYGROUPSTASK:ReportGoalProgress(DestroyGroup, DestroyUnit)

    Report Goal Progress.

    @@ -150,7 +153,7 @@
    -DESTROYGROUPSTASK.New(string, string, table, ?, self, DestroyGroupType, DestroyUnitType, DestroyGroupNames, DestroyPercentage) +DESTROYGROUPSTASK:New(DestroyGroupType, DestroyUnitType, <, DestroyPercentage, DestroyGroupNames)
    @@ -161,53 +164,35 @@
    @@ -216,7 +201,7 @@ umber DestroyPercentage defines the %-tage that needs to be destroyed to achieve
    -DESTROYGROUPSTASK.ReportGoalProgress(Group, Unit, self, DestroyGroup, DestroyUnit) +DESTROYGROUPSTASK:ReportGoalProgress(DestroyGroup, DestroyUnit)
    @@ -227,35 +212,27 @@ umber DestroyPercentage defines the %-tage that needs to be destroyed to achieve +

    Return value

    + +

    #number: +The DestroyCount reflecting the amount of units destroyed within the group.

    +
    +

    Type list

    + diff --git a/Documentation/DESTROYRADARSTASK.html b/Documentation/DESTROYRADARSTASK.html index d95a35e7d..26d37714a 100644 --- a/Documentation/DESTROYRADARSTASK.html +++ b/Documentation/DESTROYRADARSTASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/DESTROYUNITTYPESTASK.html b/Documentation/DESTROYUNITTYPESTASK.html index 77cd3064d..48e9b5d50 100644 --- a/Documentation/DESTROYUNITTYPESTASK.html +++ b/Documentation/DESTROYUNITTYPESTASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/Database.html b/Documentation/Database.html index e66bf3247..0e988cba7 100644 --- a/Documentation/Database.html +++ b/Documentation/Database.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -69,12 +72,6 @@

    Global(s)

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -190,60 +133,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -268,30 +163,6 @@ - - - - - - - - - - - - - - - - @@ -306,20 +177,6 @@
    - - -ClientGroup - -
    -
    - - - -
    -
    -
    -
    - #DATABASE DATABASE @@ -334,134 +191,9 @@
    - - -DATABASECategory - -
    -
    - - - -
    -
    -
    -
    - - - -DATABASECoalition - -
    -
    - - - -
    -
    -
    -
    - - - -InitGroup - -
    -
    - - - -
    -
    -
    -
    - - - -InitUnitDesc - -
    -
    - - - -
    -
    -
    -
    - - -LogClose() - -
    -
    - - - -
    -
    -
    -
    - - - -TargetGroup - -
    -
    - - - -
    -
    -
    -
    - - - -TargetUnitDesc - -
    -
    - - - -
    -
    -
    -
    - - - -nHours - -
    -
    - - - -
    -
    -
    -
    - - - -nMins - -
    -
    - - - -
    -
    -
    -
    - - - -nSecs + Database#DATABASE + +_Database
    @@ -602,48 +334,6 @@
    -- Define a new DATABASE Object. This DBObject will contain a reference to all Group and Unit Templates defined within the ME and the DCSRTE.
     DBObject = DATABASE:New()
    -
    -
    -
    -
    - - -DATABASE:OnDeadOrCrash(event) - -
    -
    - -

    Track DCSRTE DEAD or CRASH events for the internal scoring.

    - -

    Parameter

    -
      -
    • - -

      event :

      - -
    • -
    -
    -
    -
    -
    - - -DATABASE:OnHit(event) - -
    -
    - - - -

    Parameter

    -
      -
    • - -

      event :

      - -
    • -
    @@ -658,155 +348,6 @@ DBObject = DATABASE:New() - -
    -
    -
    - - -DATABASE:ReportScoreAll() - -
    -
    - - - -
    -
    -
    -
    - - -DATABASE:ReportScorePlayer() - -
    -
    - - - -
    -
    -
    -
    - - -DATABASE:ScoreAdd(PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType) - -
    -
    - - - -

    Parameters

    -
      -
    • - -

      PlayerName :

      - -
    • -
    • - -

      ScoreType :

      - -
    • -
    • - -

      ScoreTimes :

      - -
    • -
    • - -

      ScoreAmount :

      - -
    • -
    • - -

      PlayerUnitName :

      - -
    • -
    • - -

      PlayerUnitCoalition :

      - -
    • -
    • - -

      PlayerUnitCategory :

      - -
    • -
    • - -

      PlayerUnitType :

      - -
    • -
    • - -

      TargetUnitName :

      - -
    • -
    • - -

      TargetUnitCoalition :

      - -
    • -
    • - -

      TargetUnitCategory :

      - -
    • -
    • - -

      TargetUnitType :

      - -
    • -
    -
    -
    -
    -
    - - -DATABASE:ScoreMenu() - -
    -
    - - - -
    -
    -
    -
    - - -DATABASE:ScoreOpen() - -
    -
    - - - -
    -
    -
    -
    - - -DATABASE:SecondsToClock(sSeconds) - -
    -
    - - - -

    Parameter

    -
      -
    • - -

      sSeconds :

      - -
    • -
    @@ -887,97 +428,6 @@ This method is used by the SPAWN class.

    - -
    -
    -
    - - -DATABASE:_AddMissionScore(MissionName, Score) - -
    -
    - -

    Registers Mission Scores for possible multiple players that contributed in the Mission.

    - -

    Parameters

    -
      -
    • - -

      MissionName :

      - -
    • -
    • - -

      Score :

      - -
    • -
    -
    -
    -
    -
    - - -DATABASE:_AddMissionTaskScore(PlayerUnit, MissionName, Score) - -
    -
    - -

    Registers Scores the players completing a Mission Task.

    - -

    Parameters

    -
      -
    • - -

      PlayerUnit :

      - -
    • -
    • - -

      MissionName :

      - -
    • -
    • - -

      Score :

      - -
    • -
    -
    -
    -
    -
    - - -DATABASE:_AddPlayerFromUnit(UnitData) - -
    -
    - -

    Add a new player entering a Unit.

    - -

    Parameter

    -
      -
    • - -

      UnitData :

      - -
    • -
    -
    -
    -
    -
    - - -DATABASE:_FollowPlayers() - -
    -
    - -

    Follows new players entering Clients within the DCSRTE.

    -
    diff --git a/Documentation/Escort.html b/Documentation/Escort.html index 3afd42ee6..a75e3f26f 100644 --- a/Documentation/Escort.html +++ b/Documentation/Escort.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/Event.html b/Documentation/Event.html new file mode 100644 index 000000000..9e5bd862b --- /dev/null +++ b/Documentation/Event.html @@ -0,0 +1,1678 @@ + + + + + + +
    +
    + +
    +
    +
    +
    + +
    +

    Module Event

    + +

    The EVENT class models an efficient event handling process between other classes and its units, weapons.

    + +

    Global(s)

    +
    ClientGroup - -
    DATABASE @@ -82,61 +79,7 @@
    DATABASECategory - -
    DATABASECoalition - -
    InitGroup - -
    InitUnitDesc - -
    LogClose() - -
    TargetGroup - -
    TargetUnitDesc - -
    nHours - -
    nMins - -
    nSecs_Database DATABASE:New()

    Creates a new DATABASE Object to administer the Groups defined and alive within the DCSRTE.

    -
    DATABASE:OnDeadOrCrash(event) -

    Track DCSRTE DEAD or CRASH events for the internal scoring.

    -
    DATABASE:OnHit(event) -
    DATABASE.Players -
    DATABASE:ReportScoreAll() - -
    DATABASE:ReportScorePlayer() - -
    DATABASE:ScoreAdd(PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType) - -
    DATABASE:ScoreMenu() - -
    DATABASE:ScoreOpen() - -
    DATABASE:SecondsToClock(sSeconds) -
    DATABASE.Units -
    DATABASE:_AddMissionScore(MissionName, Score) -

    Registers Mission Scores for possible multiple players that contributed in the Mission.

    -
    DATABASE:_AddMissionTaskScore(PlayerUnit, MissionName, Score) -

    Registers Scores the players completing a Mission Task.

    -
    DATABASE:_AddPlayerFromUnit(UnitData) -

    Add a new player entering a Unit.

    -
    DATABASE:_FollowPlayers() -

    Follows new players entering Clients within the DCSRTE.

    + + + + + + + + +
    EVENT + +
    _EVENTDISPATCHER +

    Declare the event dispatcher based on the EVENT class

    +
    +

    Type EVENT

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EVENT.ClassID + +
    EVENT.ClassName + +
    EVENT:EventText(EventID) + +
    EVENT.Events + +
    EVENT:Init(EventID, EventClass) +

    Initializes the Events structure for the event

    +
    EVENT:New() + +
    EVENT:OnBirth(EventFunction, EventSelf) +

    Set a new listener for an SEVENTBIRTH event, and registers the unit born.

    +
    EVENT:OnBirthForTemplate(EventGroup, EventFunction, EventSelf, EventTemplate) +

    Create an OnBirth event handler for a group

    +
    EVENT:OnBirthForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTBIRTH event.

    +
    EVENT:OnCrash(EventFunction, EventSelf) +

    Set a new listener for an SEVENTCRASH event.

    +
    EVENT:OnCrashForTemplate(EventGroup, EventFunction, EventSelf, EventTemplate) +

    Create an OnCrash event handler for a group

    +
    EVENT:OnCrashForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTCRASH event.

    +
    EVENT:OnDead(EventFunction, EventSelf) +

    Set a new listener for an SEVENTDEAD event.

    +
    EVENT:OnDeadForTemplate(EventGroup, EventFunction, EventSelf, EventTemplate) +

    Create an OnDead event handler for a group

    +
    EVENT:OnDeadForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTDEAD event.

    +
    EVENT:OnEngineShutDownForTemplate(EventTemplate, EventFunction, EventSelf) +

    Create an OnDead event handler for a group

    +
    EVENT:OnEngineShutDownForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTENGINE_SHUTDOWN event.

    +
    EVENT:OnEngineStartUpForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTENGINE_STARTUP event.

    +
    EVENT:OnEventForTemplate(EventTemplate, EventFunction, EventSelf, OnEventFunction) +

    Create an OnDead event handler for a group

    +
    EVENT:OnEventForUnit(EventDCSUnitName, EventFunction, EventSelf, EventID) +

    Set a new listener for an SEVENTX event

    +
    EVENT:OnEventGeneric(EventFunction, EventSelf, EventID) +

    Set a new listener for an SEVENTX event independent from a unit or a weapon.

    +
    EVENT:OnHit(EventFunction, EventSelf) +

    Set a new listener for an SEVENTHIT event.

    +
    EVENT:OnHitForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTHIT event.

    +
    EVENT:OnLandForTemplate(EventTemplate, EventFunction, EventSelf) +

    Create an OnDead event handler for a group

    +
    EVENT:OnLandForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTLAND event.

    +
    EVENT:OnPilotDeadForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTPILOT_DEAD event.

    +
    EVENT:OnShot(EventFunction, EventSelf) +

    Set a new listener for an SEVENTSHOT event.

    +
    EVENT:OnShotForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTSHOT event for a unit.

    +
    EVENT:OnTakeOffForTemplate(EventTemplate, EventFunction, EventSelf) +

    Create an OnDead event handler for a group

    +
    EVENT:OnTakeOffForUnit(EventDCSUnitName, EventFunction, EventSelf) +

    Set a new listener for an SEVENTTAKEOFF event.

    +
    EVENT:onEvent(Event) + +
    + +

    Type EVENT.Events

    + + + + + +
    EVENT.Events.IniUnit + +
    + +

    Type EVENTDATA

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EVENTDATA.IniDCSGroup + +
    EVENTDATA.IniDCSGroupName + +
    EVENTDATA.IniDCSUnit + +
    EVENTDATA.IniDCSUnitName + +
    EVENTDATA.TgtDCSGroup + +
    EVENTDATA.TgtDCSGroupName + +
    EVENTDATA.TgtDCSUnit + +
    EVENTDATA.TgtDCSUnitName + +
    EVENTDATA.Weapon + +
    EVENTDATA.WeaponName + +
    EVENTDATA.WeaponTgtDCSUnit + +
    EVENTDATA.id + +
    EVENTDATA.initiator + +
    EVENTDATA.target + +
    EVENTDATA.weapon + +
    + +

    Global(s)

    +
    +
    + + #EVENT + +EVENT + +
    +
    + + + +
    +
    +
    +
    + + #EVENT + +_EVENTDISPATCHER + +
    +
    + +

    Declare the event dispatcher based on the EVENT class

    + +
    +
    +

    Type Event

    + +

    Type EVENT

    + +

    The EVENT structure

    + +

    Field(s)

    +
    +
    + + #number + +EVENT.ClassID + +
    +
    + + + +
    +
    +
    +
    + + #string + +EVENT.ClassName + +
    +
    + + + +
    +
    +
    +
    + + +EVENT:EventText(EventID) + +
    +
    + + + +

    Parameter

    + +
    +
    +
    +
    + + #EVENT.Events + +EVENT.Events + +
    +
    + + + +
    +
    +
    +
    + + +EVENT:Init(EventID, EventClass) + +
    +
    + +

    Initializes the Events structure for the event

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT.Events:

    + + +
    +
    +
    +
    + + +EVENT:New() + +
    +
    + + + +
    +
    +
    +
    + + +EVENT:OnBirth(EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTBIRTH event, and registers the unit born.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnBirthForTemplate(EventGroup, EventFunction, EventSelf, EventTemplate) + +
    +
    + +

    Create an OnBirth event handler for a group

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnBirthForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTBIRTH event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnCrash(EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTCRASH event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnCrashForTemplate(EventGroup, EventFunction, EventSelf, EventTemplate) + +
    +
    + +

    Create an OnCrash event handler for a group

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnCrashForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTCRASH event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnDead(EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTDEAD event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnDeadForTemplate(EventGroup, EventFunction, EventSelf, EventTemplate) + +
    +
    + +

    Create an OnDead event handler for a group

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnDeadForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTDEAD event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnEngineShutDownForTemplate(EventTemplate, EventFunction, EventSelf) + +
    +
    + +

    Create an OnDead event handler for a group

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnEngineShutDownForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTENGINE_SHUTDOWN event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnEngineStartUpForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTENGINE_STARTUP event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnEventForTemplate(EventTemplate, EventFunction, EventSelf, OnEventFunction) + +
    +
    + +

    Create an OnDead event handler for a group

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnEventForUnit(EventDCSUnitName, EventFunction, EventSelf, EventID) + +
    +
    + +

    Set a new listener for an SEVENTX event

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnEventGeneric(EventFunction, EventSelf, EventID) + +
    +
    + +

    Set a new listener for an SEVENTX event independent from a unit or a weapon.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnHit(EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTHIT event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnHitForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTHIT event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnLandForTemplate(EventTemplate, EventFunction, EventSelf) + +
    +
    + +

    Create an OnDead event handler for a group

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnLandForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTLAND event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnPilotDeadForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTPILOT_DEAD event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnShot(EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTSHOT event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnShotForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTSHOT event for a unit.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnTakeOffForTemplate(EventTemplate, EventFunction, EventSelf) + +
    +
    + +

    Create an OnDead event handler for a group

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:OnTakeOffForUnit(EventDCSUnitName, EventFunction, EventSelf) + +
    +
    + +

    Set a new listener for an SEVENTTAKEOFF event.

    + +

    Parameters

    + +

    Return value

    + +

    #EVENT:

    + + +
    +
    +
    +
    + + +EVENT:onEvent(Event) + +
    +
    + + + +

    Parameter

    + +
    +
    + +

    Type EVENT.Events

    + +

    The Events structure

    + +

    Field(s)

    +
    +
    + + #number + +EVENT.Events.IniUnit + +
    +
    + + + +
    +
    + +

    Type EVENTDATA

    + +

    The Event structure

    + +

    Field(s)

    +
    +
    + + +EVENTDATA.IniDCSGroup + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.IniDCSGroupName + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.IniDCSUnit + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.IniDCSUnitName + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.TgtDCSGroup + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.TgtDCSGroupName + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.TgtDCSUnit + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.TgtDCSUnitName + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.Weapon + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.WeaponName + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.WeaponTgtDCSUnit + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.id + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.initiator + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.target + +
    +
    + + + +
    +
    +
    +
    + + +EVENTDATA.weapon + +
    +
    + + + +
    +
    + + + + + + diff --git a/Documentation/GOHOMETASK.html b/Documentation/GOHOMETASK.html index fdacc71a3..b1ebecdcd 100644 --- a/Documentation/GOHOMETASK.html +++ b/Documentation/GOHOMETASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/Group.html b/Documentation/Group.html index 91a991562..3298e9321 100644 --- a/Documentation/Group.html +++ b/Documentation/Group.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/MISSION.html b/Documentation/MISSION.html index de9f3738d..81752775f 100644 --- a/Documentation/MISSION.html +++ b/Documentation/MISSION.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -387,6 +390,12 @@ A CLIENT needs to be registered within the MISSIONSCHEDULER.SchedulerId + + + + MISSIONSCHEDULER:Scoring(Scoring) + +

    Adds a mission scoring to the game.

    @@ -1522,6 +1531,27 @@ MISSIONSCHEDULER:RemoveMission( 'Russia Transport Troops SA-6' ) + + +
    +
    + + +MISSIONSCHEDULER:Scoring(Scoring) + +
    +
    + +

    Adds a mission scoring to the game.

    + +

    Parameter

    +
    diff --git a/Documentation/MOVEMENT.html b/Documentation/MOVEMENT.html index 6441a29d3..1fd0bfce1 100644 --- a/Documentation/MOVEMENT.html +++ b/Documentation/MOVEMENT.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -94,13 +97,13 @@ on defined intervals (currently every minute).

    - MOVEMENT:OnBirth(event) + MOVEMENT:OnBirth(Event)

    Captures the birth events when new Units were spawned.

    - MOVEMENT:OnDeadOrCrash(event) + MOVEMENT:OnDeadOrCrash(Event)

    Captures the Dead or Crash events when Units crash or are destroyed.

    @@ -186,7 +189,7 @@ on defined intervals (currently every minute).

    -MOVEMENT:OnBirth(event) +MOVEMENT:OnBirth(Event)
    @@ -197,7 +200,7 @@ on defined intervals (currently every minute).

    @@ -207,7 +210,7 @@ on defined intervals (currently every minute).

    -MOVEMENT:OnDeadOrCrash(event) +MOVEMENT:OnDeadOrCrash(Event)
    @@ -218,7 +221,7 @@ on defined intervals (currently every minute).

    diff --git a/Documentation/Menu.html b/Documentation/Menu.html index 533f237b1..a82742975 100644 --- a/Documentation/Menu.html +++ b/Documentation/Menu.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/Message.html b/Documentation/Message.html index fa82240cd..66c9d6c91 100644 --- a/Documentation/Message.html +++ b/Documentation/Message.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/NOTASK.html b/Documentation/NOTASK.html index d75b1a592..4fa604429 100644 --- a/Documentation/NOTASK.html +++ b/Documentation/NOTASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/PICKUPTASK.html b/Documentation/PICKUPTASK.html index c16da51ec..e9fcbf698 100644 --- a/Documentation/PICKUPTASK.html +++ b/Documentation/PICKUPTASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/ROUTETASK.html b/Documentation/ROUTETASK.html index da4d521b2..87dc106be 100644 --- a/Documentation/ROUTETASK.html +++ b/Documentation/ROUTETASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/STAGE.html b/Documentation/STAGE.html index fd863de03..bc38980e4 100644 --- a/Documentation/STAGE.html +++ b/Documentation/STAGE.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/Scoring.html b/Documentation/Scoring.html new file mode 100644 index 000000000..b70b673fb --- /dev/null +++ b/Documentation/Scoring.html @@ -0,0 +1,791 @@ + + + + + + +
    +
    + +
    +
    +
    +
    + +
    +

    Module Scoring

    + +

    Scoring system for MOOSE.

    + + +

    This scoring class calculates the hits and kills that players make within a simulation session. +Scoring is calculated using a defined algorithm. +With a small change in MissionScripting.lua, the scoring can also be logged in a CSV file, that can then be uploaded +to a database or a BI tool to publish the scoring results to the player community.

    + +

    Global(s)

    + + + + + + + + + + + + + + + + + + + + + +
    ClientGroup + +
    SCORING + +
    nHours + +
    nMins + +
    nSecs + +
    +

    Type SCORING

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    SCORING.AllScoresMenu + +
    SCORING.ClassID + +
    SCORING.ClassName + +
    SCORING:CloseCSV() + +
    SCORING.Menu + +
    SCORING:New(GameName) +

    Creates a new SCORING object to administer the scoring achieved by players.

    +
    SCORING:OpenCSV(ScoringCSV) +

    Opens a score CSV file to log the scores.

    +
    SCORING.Players +

    A collection of the current players that have joined the game.

    +
    SCORING:ReportScoreAll() + +
    SCORING:ReportScorePlayer() + +
    SCORING.RunTime + +
    SCORING:ScoreCSV(PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType) +

    Registers a score for a player.

    +
    SCORING:ScoreMenu() +

    Creates a score radio menu.

    +
    SCORING.ScoringCSV + +
    SCORING:SecondsToClock(sSeconds) + +
    SCORING:_AddMissionScore(MissionName, Score) +

    Registers Mission Scores for possible multiple players that contributed in the Mission.

    +
    SCORING:_AddMissionTaskScore(PlayerUnit, MissionName, Score) +

    Registers Scores the players completing a Mission Task.

    +
    SCORING:_AddPlayerFromUnit(UnitData) +

    Add a new player entering a Unit.

    +
    SCORING:_EventOnDeadOrCrash(Event) +

    Track DEAD or CRASH events for the scoring.

    +
    SCORING:_EventOnHit(Event) +

    Handles the OnHit event for the scoring.

    +
    SCORING:_FollowPlayersScheduled() +

    Follows new players entering Clients within the DCSRTE.

    +
    + +

    Global(s)

    +
    +
    + + + +ClientGroup + +
    +
    + + + +
    +
    +
    +
    + + #SCORING + +SCORING + +
    +
    + + + +
    +
    +
    +
    + + + +nHours + +
    +
    + + + +
    +
    +
    +
    + + + +nMins + +
    +
    + + + +
    +
    +
    +
    + + + +nSecs + +
    +
    + + + +
    +
    +

    Type Scoring

    + +

    Type SCORING

    + +

    The Scoring class

    + +

    Field(s)

    +
    +
    + + + +SCORING.AllScoresMenu + +
    +
    + + + +
    +
    +
    +
    + + #number + +SCORING.ClassID + +
    +
    + + + +
    +
    +
    +
    + + #string + +SCORING.ClassName + +
    +
    + + + +
    +
    +
    +
    + + +SCORING:CloseCSV() + +
    +
    + + + +
    +
    +
    +
    + + + +SCORING.Menu + +
    +
    + + + +
    +
    +
    +
    + + +SCORING:New(GameName) + +
    +
    + +

    Creates a new SCORING object to administer the scoring achieved by players.

    + +

    Parameter

    +
      +
    • + +

      #string GameName : +The name of the game. This name is also logged in the CSV score file.

      + +
    • +
    +

    Return value

    + +

    #SCORING: +self

    + +

    Usage:

    +
    -- Define a new scoring object for the mission Gori Valley.
    +ScoringObject = SCORING:New( "Gori Valley" )
    + +
    +
    +
    +
    + + +SCORING:OpenCSV(ScoringCSV) + +
    +
    + +

    Opens a score CSV file to log the scores.

    + +

    Parameter

    +
      +
    • + +

      #string ScoringCSV :

      + +
    • +
    +

    Return value

    + +

    #SCORING: +self

    + +

    Usage:

    +
    -- Open a new CSV file to log the scores of the game Gori Valley. Let the name of the CSV file begin with "Player Scores".
    +ScoringObject = SCORING:New( "Gori Valley" )
    +ScoringObject:OpenCSV( "Player Scores" )
    + +
    +
    +
    +
    + + +SCORING.Players + +
    +
    + +

    A collection of the current players that have joined the game.

    + +
    +
    +
    +
    + + +SCORING:ReportScoreAll() + +
    +
    + + + +
    +
    +
    +
    + + +SCORING:ReportScorePlayer() + +
    +
    + + + +
    +
    +
    +
    + + + +SCORING.RunTime + +
    +
    + + + +
    +
    +
    +
    + + +SCORING:ScoreCSV(PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType) + +
    +
    + +

    Registers a score for a player.

    + +

    Parameters

    +
      +
    • + +

      #string PlayerName : +The name of the player.

      + +
    • +
    • + +

      #string ScoreType : +The type of the score.

      + +
    • +
    • + +

      #string ScoreTimes : +The amount of scores achieved.

      + +
    • +
    • + +

      #string ScoreAmount : +The score given.

      + +
    • +
    • + +

      #string PlayerUnitName : +The unit name of the player.

      + +
    • +
    • + +

      #string PlayerUnitCoalition : +The coalition of the player unit.

      + +
    • +
    • + +

      #string PlayerUnitCategory : +The category of the player unit.

      + +
    • +
    • + +

      #string PlayerUnitType : +The type of the player unit.

      + +
    • +
    • + +

      #string TargetUnitName : +The name of the target unit.

      + +
    • +
    • + +

      #string TargetUnitCoalition : +The coalition of the target unit.

      + +
    • +
    • + +

      #string TargetUnitCategory : +The category of the target unit.

      + +
    • +
    • + +

      #string TargetUnitType : +The type of the target unit.

      + +
    • +
    +

    Return value

    + +

    #SCORING: +self

    + +
    +
    +
    +
    + + +SCORING:ScoreMenu() + +
    +
    + +

    Creates a score radio menu.

    + + +

    Can be accessed using Radio -> F10.

    + +

    Return value

    + +

    #SCORING: +self

    + +
    +
    +
    +
    + + + +SCORING.ScoringCSV + +
    +
    + + + +
    +
    +
    +
    + + +SCORING:SecondsToClock(sSeconds) + +
    +
    + + + +

    Parameter

    +
      +
    • + +

      sSeconds :

      + +
    • +
    +
    +
    +
    +
    + + +SCORING:_AddMissionScore(MissionName, Score) + +
    +
    + +

    Registers Mission Scores for possible multiple players that contributed in the Mission.

    + +

    Parameters

    +
      +
    • + +

      MissionName :

      + +
    • +
    • + +

      Score :

      + +
    • +
    +
    +
    +
    +
    + + +SCORING:_AddMissionTaskScore(PlayerUnit, MissionName, Score) + +
    +
    + +

    Registers Scores the players completing a Mission Task.

    + +

    Parameters

    +
      +
    • + +

      PlayerUnit :

      + +
    • +
    • + +

      MissionName :

      + +
    • +
    • + +

      Score :

      + +
    • +
    +
    +
    +
    +
    + + +SCORING:_AddPlayerFromUnit(UnitData) + +
    +
    + +

    Add a new player entering a Unit.

    + +

    Parameter

    +
      +
    • + +

      UnitData :

      + +
    • +
    +
    +
    +
    +
    + + +SCORING:_EventOnDeadOrCrash(Event) + +
    +
    + +

    Track DEAD or CRASH events for the scoring.

    + +

    Parameter

    + +
    +
    +
    +
    + + +SCORING:_EventOnHit(Event) + +
    +
    + +

    Handles the OnHit event for the scoring.

    + +

    Parameter

    + +
    +
    +
    +
    + + +SCORING:_FollowPlayersScheduled() + +
    +
    + +

    Follows new players entering Clients within the DCSRTE.

    + + +

    TODO: Need to see if i can catch this also with an event. It will eliminate the schedule ...

    + +
    +
    + +
    + +
    + + diff --git a/Documentation/Sead.html b/Documentation/Sead.html index d11fc919f..95c47ee9e 100644 --- a/Documentation/Sead.html +++ b/Documentation/Sead.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -82,7 +85,7 @@ - SEAD:EventShot(event) + SEAD:EventShot(Event)

    Detects if an SA site was shot with an anti radiation missile.

    @@ -147,7 +150,7 @@
    -SEAD:EventShot(event) +SEAD:EventShot(Event)
    @@ -161,7 +164,7 @@ diff --git a/Documentation/Spawn.html b/Documentation/Spawn.html index e2427bf1a..21d159c33 100644 --- a/Documentation/Spawn.html +++ b/Documentation/Spawn.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -326,9 +329,9 @@ You can use the GROUP object to do further actions with - SPAWN:SpawnInZone(Zone, SpawnIndex) + SPAWN:SpawnInZone(Zone, ZoneRandomize, SpawnIndex) -

    Will spawn a Group within a given ZONE.

    +

    Will spawn a Group within a given Zone#ZONE.

    @@ -1420,23 +1423,33 @@ SpawnGroupName

    -SPAWN:SpawnInZone(Zone, SpawnIndex) +SPAWN:SpawnInZone(Zone, ZoneRandomize, SpawnIndex)
    -

    Will spawn a Group within a given ZONE.

    +

    Will spawn a Group within a given Zone#ZONE.

    + + +

    Once the group is spawned within the zone, it will continue on its route. +The first waypoint (where the group is spawned) is replaced with the zone coordinates.

    Parameters

    -

    Type ZONE

    - diff --git a/Documentation/StaticObject.html b/Documentation/StaticObject.html index b5f1e3915..9f6847026 100644 --- a/Documentation/StaticObject.html +++ b/Documentation/StaticObject.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/TASK.html b/Documentation/TASK.html index 12c34a734..bc244726c 100644 --- a/Documentation/TASK.html +++ b/Documentation/TASK.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -217,7 +220,7 @@ - TASK.Goal(?, self, GoalVerb) + TASK:Goal(GoalVerb)

    Returns if a TASK has Goal(s).

    @@ -1147,29 +1150,19 @@ tring GoalVerb is the name of the Goal of the TASK. If the GoalVerb is not given
    -TASK.Goal(?, self, GoalVerb) +TASK:Goal(GoalVerb)

    Returns if a TASK has Goal(s).

    -

    Parameters

    +

    Parameter

    diff --git a/Documentation/Unit.html b/Documentation/Unit.html index 0f36031dd..985e6a1e7 100644 --- a/Documentation/Unit.html +++ b/Documentation/Unit.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/Zone.html b/Documentation/Zone.html index 10d8c170a..1b9c3cb4b 100644 --- a/Documentation/Zone.html +++ b/Documentation/Zone.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/env.html b/Documentation/env.html index 665f4519f..959ef7350 100644 --- a/Documentation/env.html +++ b/Documentation/env.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/index.html b/Documentation/index.html index 63942937d..50958b731 100644 --- a/Documentation/index.html +++ b/Documentation/index.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • @@ -138,6 +141,12 @@ DCSUnit + + + + DCSWorld + + @@ -186,6 +195,12 @@ Escort

    Taking the lead of AI escorting your flight.

    + + + + Event + +

    The EVENT class models an efficient event handling process between other classes and its units, weapons.

    @@ -246,6 +261,12 @@ STAGE

    Stages within a TASK within a MISSION.

    + + + + Scoring + +

    Scoring system for MOOSE.

    diff --git a/Documentation/land.html b/Documentation/land.html index 630ebb3b9..5399503ee 100644 --- a/Documentation/land.html +++ b/Documentation/land.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Documentation/routines.html b/Documentation/routines.html index 1125b647e..d33caf801 100644 --- a/Documentation/routines.html +++ b/Documentation/routines.html @@ -30,6 +30,7 @@
  • DCSTask
  • DCSTypes
  • DCSUnit
  • +
  • DCSWorld
  • DCStimer
  • DEPLOYTASK
  • DESTROYBASETASK
  • @@ -38,6 +39,7 @@
  • DESTROYUNITTYPESTASK
  • Database
  • Escort
  • +
  • Event
  • GOHOMETASK
  • Group
  • MISSION
  • @@ -48,6 +50,7 @@
  • PICKUPTASK
  • ROUTETASK
  • STAGE
  • +
  • Scoring
  • Sead
  • Spawn
  • StaticObject
  • diff --git a/Embedded/Moose_Create_Embedded.bat b/Embedded/Moose_Create_Embedded.bat index 7dfa51470..f434c274b 100644 --- a/Embedded/Moose_Create_Embedded.bat +++ b/Embedded/Moose_Create_Embedded.bat @@ -1,32 +1,32 @@ -rem Generate Moose_Embedded.lua +del Moose_Embedded.lua -copy /b ..\Moose\Routines.lua ^ - + ..\Moose\Base.lua ^ - + ..\Moose\Event.lua ^ - + ..\Moose\Menu.lua ^ - + ..\Moose\Group.lua ^ - + ..\Moose\Unit.lua ^ - + ..\Moose\Zone.lua ^ - + ..\Moose\Database.lua ^ - + ..\Moose\Cargo.lua ^ - + ..\Moose\Client.lua ^ - + ..\Moose\Message.lua ^ - + ..\Moose\Stage.lua ^ - + ..\Moose\Task.lua ^ - + ..\Moose\GoHomeTask.lua ^ - + ..\Moose\DestroyBaseTask.lua ^ - + ..\Moose\DestroyGroupsTask.lua ^ - + ..\Moose\DestroyRadarsTask.lua ^ - + ..\Moose\DestroyUnitTypesTask.lua ^ - + ..\Moose\PickupTask.lua ^ - + ..\Moose\DeployTask.lua ^ - + ..\Moose\NoTask.lua ^ - + ..\Moose\RouteTask.lua ^ - + ..\Moose\Mission.lua ^ - + ..\Moose\CleanUp.lua ^ - + ..\Moose\Spawn.lua ^ - + ..\Moose\Movement.lua ^ - + ..\Moose\Sead.lua ^ - + ..\Moose\Escort.lua ^ - Moose_Embedded.lua /y - \ No newline at end of file +echo env.info( 'Moose Embedded' ) > Moose_Embedded.lua + +copy /b Moose_Embedded.lua + ..\Moose\Routines.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Base.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Event.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Group.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Unit.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Zone.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Database.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Scoring.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Cargo.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Client.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Message.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Stage.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Task.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\GoHomeTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\DestroyBaseTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\DestroyGroupsTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\DestroyRadarsTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\DestroyUnitTypesTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\PickupTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\DeployTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\NoTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\RouteTask.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Mission.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\CleanUp.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Spawn.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Movement.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Sead.lua Moose_Embedded.lua +copy /b Moose_Embedded.lua + ..\Moose\Escort.lua Moose_Embedded.lua diff --git a/Embedded/Moose_Embedded.lua b/Embedded/Moose_Embedded.lua index 93a3994b7..df0080676 100644 --- a/Embedded/Moose_Embedded.lua +++ b/Embedded/Moose_Embedded.lua @@ -1,3 +1,4 @@ +env.info( 'Moose Embedded' ) --- Various routines -- @module routines -- @author Flightcontrol @@ -3508,253 +3509,6 @@ end --- Declare the event dispatcher based on the EVENT class _EVENTDISPATCHER = EVENT:New() -- #EVENT ---- Encapsulation of DCS World Menu system in a set of MENU classes. --- @module Menu - -Include.File( "Routines" ) -Include.File( "Base" ) - ---- The MENU class --- @type MENU --- @extends Base#BASE -MENU = { - ClassName = "MENU", - MenuPath = nil, - MenuText = "", - MenuParentPath = nil -} - ---- -function MENU:New( MenuText, MenuParentPath ) - - -- Arrange meta tables - local Child = BASE:Inherit( self, BASE:New() ) - - Child.MenuPath = nil - Child.MenuText = MenuText - Child.MenuParentPath = MenuParentPath - return Child -end - ---- The COMMANDMENU class --- @type COMMANDMENU --- @extends Menu#MENU -COMMANDMENU = { - ClassName = "COMMANDMENU", - CommandMenuFunction = nil, - CommandMenuArgument = nil -} - -function COMMANDMENU:New( MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument ) - - -- Arrange meta tables - - local MenuParentPath = nil - if ParentMenu ~= nil then - MenuParentPath = ParentMenu.MenuPath - end - - local Child = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) ) - - Child.MenuPath = missionCommands.addCommand( MenuText, MenuParentPath, CommandMenuFunction, CommandMenuArgument ) - Child.CommandMenuFunction = CommandMenuFunction - Child.CommandMenuArgument = CommandMenuArgument - return Child -end - ---- The SUBMENU class --- @type SUBMENU --- @extends Menu#MENU -SUBMENU = { - ClassName = "SUBMENU" -} - -function SUBMENU:New( MenuText, ParentMenu ) - - -- Arrange meta tables - local MenuParentPath = nil - if ParentMenu ~= nil then - MenuParentPath = ParentMenu.MenuPath - end - - local Child = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) ) - - Child.MenuPath = missionCommands.addSubMenu( MenuText, MenuParentPath ) - return Child -end - --- This local variable is used to cache the menus registered under clients. --- Menus don't dissapear when clients are destroyed and restarted. --- So every menu for a client created must be tracked so that program logic accidentally does not create --- the same menus twice during initialization logic. --- These menu classes are handling this logic with this variable. -local _MENUCLIENTS = {} - ---- The MENU_CLIENT class --- @type MENU_CLIENT --- @extends Menu#MENU -MENU_CLIENT = { - ClassName = "MENU_CLIENT" -} - ---- Creates a new menu item for a group --- @param self --- @param Client#CLIENT MenuClient The Client owning the menu. --- @param #string MenuText The text for the menu. --- @param #table ParentMenu The parent menu. --- @return #MENU_CLIENT self -function MENU_CLIENT:New( MenuClient, MenuText, ParentMenu ) - - -- Arrange meta tables - local MenuParentPath = {} - if ParentMenu ~= nil then - MenuParentPath = ParentMenu.MenuPath - end - - local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) ) - self:F( { MenuClient, MenuText, ParentMenu } ) - - self.MenuClient = MenuClient - self.MenuClientGroupID = MenuClient:GetClientGroupID() - self.MenuParentPath = MenuParentPath - self.MenuText = MenuText - self.ParentMenu = ParentMenu - - self.Menus = {} - - if not _MENUCLIENTS[self.MenuClientGroupID] then - _MENUCLIENTS[self.MenuClientGroupID] = {} - end - - local MenuPath = _MENUCLIENTS[self.MenuClientGroupID] - - self:T( { MenuClient:GetClientGroupName(), MenuPath[table.concat(MenuParentPath)], MenuParentPath, MenuText } ) - - local MenuPathID = table.concat(MenuParentPath) .. "/" .. MenuText - if MenuPath[MenuPathID] then - missionCommands.removeItemForGroup( self.MenuClient:GetClientGroupID(), MenuPath[MenuPathID] ) - end - - self.MenuPath = missionCommands.addSubMenuForGroup( self.MenuClient:GetClientGroupID(), MenuText, MenuParentPath ) - MenuPath[MenuPathID] = self.MenuPath - - self:T( { MenuClient:GetClientGroupName(), self.MenuPath } ) - - if ParentMenu and ParentMenu.Menus then - ParentMenu.Menus[self.MenuPath] = self - end - return self -end - ---- Removes the sub menus recursively of this MENU_CLIENT. --- @param #MENU_CLIENT self --- @return #MENU_CLIENT self -function MENU_CLIENT:RemoveSubMenus() - self:F( self.MenuPath ) - - for MenuID, Menu in pairs( self.Menus ) do - Menu:Remove() - end - -end - ---- Removes the sub menus recursively of this MENU_CLIENT. --- @param #MENU_CLIENT self --- @return #MENU_CLIENT self -function MENU_CLIENT:Remove() - self:F( self.MenuPath ) - - self:RemoveSubMenus() - - if not _MENUCLIENTS[self.MenuClientGroupID] then - _MENUCLIENTS[self.MenuClientGroupID] = {} - end - - local MenuPath = _MENUCLIENTS[self.MenuClientGroupID] - - if MenuPath[table.concat(self.MenuParentPath) .. "/" .. self.MenuText] then - MenuPath[table.concat(self.MenuParentPath) .. "/" .. self.MenuText] = nil - end - - missionCommands.removeItemForGroup( self.MenuClient:GetClientGroupID(), self.MenuPath ) - self.ParentMenu.Menus[self.MenuPath] = nil - return nil -end - - ---- The MENU_CLIENT_COMMAND class --- @type MENU_CLIENT_COMMAND --- @extends Menu#MENU -MENU_CLIENT_COMMAND = { - ClassName = "MENU_CLIENT_COMMAND" -} - ---- Creates a new radio command item for a group --- @param self --- @param Client#CLIENT MenuClient The Client owning the menu. --- @param MenuText The text for the menu. --- @param ParentMenu The parent menu. --- @param CommandMenuFunction A function that is called when the menu key is pressed. --- @param CommandMenuArgument An argument for the function. --- @return Menu#MENU_CLIENT_COMMAND self -function MENU_CLIENT_COMMAND:New( MenuClient, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument ) - - -- Arrange meta tables - - local MenuParentPath = {} - if ParentMenu ~= nil then - MenuParentPath = ParentMenu.MenuPath - end - - local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) ) - - self.MenuClient = MenuClient - self.MenuClientGroupID = MenuClient:GetClientGroupID() - self.MenuParentPath = MenuParentPath - self.MenuText = MenuText - self.ParentMenu = ParentMenu - - if not _MENUCLIENTS[self.MenuClientGroupID] then - _MENUCLIENTS[self.MenuClientGroupID] = {} - end - - local MenuPath = _MENUCLIENTS[self.MenuClientGroupID] - - self:T( { MenuClient:GetClientGroupName(), MenuPath[table.concat(MenuParentPath)], MenuParentPath, MenuText, CommandMenuFunction, CommandMenuArgument } ) - - local MenuPathID = table.concat(MenuParentPath) .. "/" .. MenuText - if MenuPath[MenuPathID] then - missionCommands.removeItemForGroup( self.MenuClient:GetClientGroupID(), MenuPath[MenuPathID] ) - end - - self.MenuPath = missionCommands.addCommandForGroup( self.MenuClient:GetClientGroupID(), MenuText, MenuParentPath, CommandMenuFunction, CommandMenuArgument ) - MenuPath[MenuPathID] = self.MenuPath - - self.CommandMenuFunction = CommandMenuFunction - self.CommandMenuArgument = CommandMenuArgument - - ParentMenu.Menus[self.MenuPath] = self - - return self -end - -function MENU_CLIENT_COMMAND:Remove() - self:F( self.MenuPath ) - - if not _MENUCLIENTS[self.MenuClientGroupID] then - _MENUCLIENTS[self.MenuClientGroupID] = {} - end - - local MenuPath = _MENUCLIENTS[self.MenuClientGroupID] - - if MenuPath[table.concat(self.MenuParentPath) .. "/" .. self.MenuText] then - MenuPath[table.concat(self.MenuParentPath) .. "/" .. self.MenuText] = nil - end - - missionCommands.removeItemForGroup( self.MenuClient:GetClientGroupID(), self.MenuPath ) - self.ParentMenu.Menus[self.MenuPath] = nil - return nil -end --- A GROUP class abstraction of a DCSGroup class. -- The GROUP class will take an abstraction of the DCSGroup class, providing more methods that can be done with a GROUP. -- @module Group @@ -5599,15 +5353,6 @@ function DATABASE:New() end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then end --for coa_name, coa_data in pairs(mission.coalition) do - --self:AddEvent( world.event.S_EVENT_BIRTH, self.OnBirth ) - _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self ) - _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self ) - _EVENTDISPATCHER:OnHit( self._EventOnHit, self ) - - self.SchedulerId = routines.scheduleFunction( DATABASE._FollowPlayers, { self }, 0, 5 ) - - self:ScoreMenu() - return self end @@ -5663,11 +5408,6 @@ function DATABASE:GetStatusGroup( GroupName ) end end - ---- Private --- @section Private - - --- Registers new Group Templates within the DATABASE Object. function DATABASE:_RegisterGroup( GroupTemplate ) @@ -5702,15 +5442,115 @@ function DATABASE:_RegisterGroup( GroupTemplate ) end end - ---- Events --- @section Events +_Database = DATABASE:New() -- Database#DATABASE ---- Track DCSRTE DEAD or CRASH events for the internal scoring. --- @param #DATABASE self +--- Scoring system for MOOSE. +-- This scoring class calculates the hits and kills that players make within a simulation session. +-- Scoring is calculated using a defined algorithm. +-- With a small change in MissionScripting.lua, the scoring can also be logged in a CSV file, that can then be uploaded +-- to a database or a BI tool to publish the scoring results to the player community. +-- @module Scoring +-- @author FlightControl + + +Include.File( "Routines" ) +Include.File( "Base" ) +Include.File( "Menu" ) +Include.File( "Group" ) +Include.File( "Event" ) + + +--- The Scoring class +-- @type SCORING +-- @field Players A collection of the current players that have joined the game. +-- @extends Base#BASE +SCORING = { + ClassName = "SCORING", + ClassID = 0, + Players = {}, +} + +local _SCORINGCoalition = + { + [1] = "Red", + [2] = "Blue", + } + +local _SCORINGCategory = + { + [Unit.Category.AIRPLANE] = "Plane", + [Unit.Category.HELICOPTER] = "Helicopter", + [Unit.Category.GROUND_UNIT] = "Vehicle", + [Unit.Category.SHIP] = "Ship", + [Unit.Category.STRUCTURE] = "Structure", + } + +--- Creates a new SCORING object to administer the scoring achieved by players. +-- @param #SCORING self +-- @param #string GameName The name of the game. This name is also logged in the CSV score file. +-- @return #SCORING self +-- @usage +-- -- Define a new scoring object for the mission Gori Valley. +-- ScoringObject = SCORING:New( "Gori Valley" ) +function SCORING:New( GameName ) + + -- Inherits from BASE + local self = BASE:Inherit( self, BASE:New() ) + + if GameName then + self.GameName = GameName + else + error( "A game name must be given to register the scoring results" ) + end + + + _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self ) + _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self ) + _EVENTDISPATCHER:OnHit( self._EventOnHit, self ) + + self.SchedulerId = routines.scheduleFunction( SCORING._FollowPlayersScheduled, { self }, 0, 5 ) + + self:ScoreMenu() + + return self + +end + +--- Creates a score radio menu. Can be accessed using Radio -> F10. +-- @param #SCORING self +-- @return #SCORING self +function SCORING:ScoreMenu() + self.Menu = SUBMENU:New( 'Scoring' ) + self.AllScoresMenu = COMMANDMENU:New( 'Score All Active Players', self.Menu, SCORING.ReportScoreAll, self ) + --- = COMMANDMENU:New('Your Current Score', ReportScore, SCORING.ReportScorePlayer, self ) + return self +end + +--- Follows new players entering Clients within the DCSRTE. +-- TODO: Need to see if i can catch this also with an event. It will eliminate the schedule ... +function SCORING:_FollowPlayersScheduled() + self:F3( "_FollowPlayersScheduled" ) + + local ClientUnit = 0 + local CoalitionsData = { AlivePlayersRed = coalition.getPlayers(coalition.side.RED), AlivePlayersBlue = coalition.getPlayers(coalition.side.BLUE) } + local unitId + local unitData + local AlivePlayerUnits = {} + + for CoalitionId, CoalitionData in pairs( CoalitionsData ) do + self:T3( { "_FollowPlayersScheduled", CoalitionData } ) + for UnitId, UnitData in pairs( CoalitionData ) do + self:_AddPlayerFromUnit( UnitData ) + end + end +end + + +--- Track DEAD or CRASH events for the scoring. +-- @param #SCORING self -- @param Event#EVENTDATA Event -function DATABASE:_EventOnDeadOrCrash( Event ) +function SCORING:_EventOnDeadOrCrash( Event ) self:F( { Event } ) local TargetUnit = nil @@ -5738,8 +5578,8 @@ function DATABASE:_EventOnDeadOrCrash( Event ) TargetCategory = TargetUnit:getDesc().category -- Workaround TargetType = TargetUnit:getTypeName() - TargetUnitCoalition = _DATABASECoalition[TargetCoalition] - TargetUnitCategory = _DATABASECategory[T1argetCategory] + TargetUnitCoalition = _SCORINGCoalition[TargetCoalition] + TargetUnitCategory = _SCORINGCategory[TargetCategory] TargetUnitType = TargetType self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } ) @@ -5754,8 +5594,8 @@ function DATABASE:_EventOnDeadOrCrash( Event ) local InitUnitType = PlayerData.UnitType local InitCoalition = PlayerData.UnitCoalition local InitCategory = PlayerData.UnitCategory - local InitUnitCoalition = _DATABASECoalition[InitCoalition] - local InitUnitCategory = _DATABASECategory[InitCategory] + local InitUnitCoalition = _SCORINGCoalition[InitCoalition] + local InitUnitCategory = _SCORINGCategory[InitCategory] self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } ) @@ -5781,7 +5621,7 @@ function DATABASE:_EventOnDeadOrCrash( Event ) PlayerData.Kill[TargetCategory][TargetType].PenaltyKill .. " times. Penalty: -" .. PlayerData.Kill[TargetCategory][TargetType].Penalty .. ". Score Total:" .. PlayerData.Score - PlayerData.Penalty, "", 5, "/PENALTY" .. PlayerName .. "/" .. InitUnitName ):ToAll() - self:ScoreAdd( PlayerName, "KILL_PENALTY", 1, -125, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + self:ScoreCSV( PlayerName, "KILL_PENALTY", 1, -125, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else PlayerData.Score = PlayerData.Score + 10 PlayerData.Kill[TargetCategory][TargetType].Score = PlayerData.Kill[TargetCategory][TargetType].Score + 10 @@ -5790,7 +5630,7 @@ function DATABASE:_EventOnDeadOrCrash( Event ) PlayerData.Kill[TargetCategory][TargetType].ScoreKill .. " times. Score: " .. PlayerData.Kill[TargetCategory][TargetType].Score .. ". Score Total:" .. PlayerData.Score - PlayerData.Penalty, "", 5, "/SCORE" .. PlayerName .. "/" .. InitUnitName ):ToAll() - self:ScoreAdd( PlayerName, "KILL_SCORE", 1, 10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + self:ScoreCSV( PlayerName, "KILL_SCORE", 1, 10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) end end end @@ -5799,35 +5639,9 @@ function DATABASE:_EventOnDeadOrCrash( Event ) end ---- Scheduled --- @section Scheduled - - ---- Follows new players entering Clients within the DCSRTE. -function DATABASE:_FollowPlayers() - self:F3( "_FollowPlayers" ) - - local ClientUnit = 0 - local CoalitionsData = { AlivePlayersRed = coalition.getPlayers(coalition.side.RED), AlivePlayersBlue = coalition.getPlayers(coalition.side.BLUE) } - local unitId - local unitData - local AlivePlayerUnits = {} - - for CoalitionId, CoalitionData in pairs( CoalitionsData ) do - self:T3( { "_FollowPlayers", CoalitionData } ) - for UnitId, UnitData in pairs( CoalitionData ) do - self:_AddPlayerFromUnit( UnitData ) - end - end -end - - ---- Private --- @section Private - --- Add a new player entering a Unit. -function DATABASE:_AddPlayerFromUnit( UnitData ) +function SCORING:_AddPlayerFromUnit( UnitData ) self:F( UnitData ) if UnitData:isExist() then @@ -5846,7 +5660,7 @@ function DATABASE:_AddPlayerFromUnit( UnitData ) self.Players[PlayerName].Kill = {} self.Players[PlayerName].Mission = {} - -- for CategoryID, CategoryName in pairs( DATABASECategory ) do + -- for CategoryID, CategoryName in pairs( SCORINGCategory ) do -- self.Players[PlayerName].Hit[CategoryID] = {} -- self.Players[PlayerName].Kill[CategoryID] = {} -- end @@ -5864,14 +5678,14 @@ function DATABASE:_AddPlayerFromUnit( UnitData ) if self.Players[PlayerName].UnitCoalition ~= UnitCoalition then self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + 50 self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1 - MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. _DATABASECoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. _DATABASECoalition[UnitCoalition] .. + MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. _SCORINGCoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. _SCORINGCoalition[UnitCoalition] .. "(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.", "", 2, "/PENALTYCOALITION" .. PlayerName ):ToAll() - self:ScoreAdd( PlayerName, "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, _DATABASECoalition[self.Players[PlayerName].UnitCoalition], _DATABASECategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType, - UnitName, _DATABASECoalition[UnitCoalition], _DATABASECategory[UnitCategory], UnitData:getTypeName() ) + self:ScoreCSV( PlayerName, "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, _SCORINGCoalition[self.Players[PlayerName].UnitCoalition], _SCORINGCategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType, + UnitName, _SCORINGCoalition[UnitCoalition], _SCORINGCategory[UnitCategory], UnitData:getTypeName() ) end end self.Players[PlayerName].UnitName = UnitName @@ -5905,7 +5719,7 @@ end --- Registers Scores the players completing a Mission Task. -function DATABASE:_AddMissionTaskScore( PlayerUnit, MissionName, Score ) +function SCORING:_AddMissionTaskScore( PlayerUnit, MissionName, Score ) self:F( { PlayerUnit, MissionName, Score } ) local PlayerName = PlayerUnit:getPlayerName() @@ -5926,13 +5740,13 @@ function DATABASE:_AddMissionTaskScore( PlayerUnit, MissionName, Score ) Score .. " Score points added.", "", 20, "/SCORETASK" .. PlayerName ):ToAll() - _Database:ScoreAdd( PlayerName, "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score, PlayerUnit:getName() ) + self:ScoreCSV( PlayerName, "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score, PlayerUnit:getName() ) end --- Registers Mission Scores for possible multiple players that contributed in the Mission. -function DATABASE:_AddMissionScore( MissionName, Score ) - self:F( { PlayerUnit, MissionName, Score } ) +function SCORING:_AddMissionScore( MissionName, Score ) + self:F( { MissionName, Score } ) for PlayerName, PlayerData in pairs( self.Players ) do @@ -5942,20 +5756,15 @@ function DATABASE:_AddMissionScore( MissionName, Score ) MESSAGE:New( "Player '" .. PlayerName .. "' has finished Mission '" .. MissionName .. "'. " .. Score .. " Score points added.", "", 20, "/SCOREMISSION" .. PlayerName ):ToAll() - _Database:ScoreAdd( PlayerName, "MISSION_" .. MissionName:gsub( ' ', '_' ), 1, Score ) + self:ScoreCSV( PlayerName, "MISSION_" .. MissionName:gsub( ' ', '_' ), 1, Score ) end end end - ---- Events --- @section Events - - --- Handles the OnHit event for the scoring. --- @param #DATABASE self +-- @param #SCORING self -- @param Event#EVENTDATA Event -function DATABASE:_EventOnHit( Event ) +function SCORING:_EventOnHit( Event ) self:F( { Event } ) local InitUnit = nil @@ -5998,8 +5807,8 @@ function DATABASE:_EventOnHit( Event ) InitCategory = InitUnit:getDesc().category InitType = InitUnit:getTypeName() - InitUnitCoalition = _DATABASECoalition[InitCoalition] - InitUnitCategory = _DATABASECategory[InitCategory] + InitUnitCoalition = _SCORINGCoalition[InitCoalition] + InitUnitCategory = _SCORINGCategory[InitCategory] InitUnitType = InitType self:T( { InitUnitName, InitGroupName, InitPlayerName, InitCoalition, InitCategory, InitType , InitUnitCoalition, InitUnitCategory, InitUnitType } ) @@ -6020,8 +5829,8 @@ function DATABASE:_EventOnHit( Event ) TargetCategory = TargetUnit:getDesc().category TargetType = TargetUnit:getTypeName() - TargetUnitCoalition = _DATABASECoalition[TargetCoalition] - TargetUnitCategory = _DATABASECategory[TargetCategory] + TargetUnitCoalition = _SCORINGCoalition[TargetCoalition] + TargetUnitCategory = _SCORINGCategory[TargetCategory] TargetUnitType = TargetType self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType, TargetUnitCoalition, TargetUnitCategory, TargetUnitType } ) @@ -6060,7 +5869,7 @@ function DATABASE:_EventOnHit( Event ) 2, "/PENALTY" .. InitPlayerName .. "/" .. InitUnitName ):ToAll() - self:ScoreAdd( InitPlayerName, "HIT_PENALTY", 1, -25, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + self:ScoreCSV( InitPlayerName, "HIT_PENALTY", 1, -25, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else self.Players[InitPlayerName].Score = self.Players[InitPlayerName].Score + 10 self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Score = self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Score + 1 @@ -6072,7 +5881,7 @@ function DATABASE:_EventOnHit( Event ) 2, "/SCORE" .. InitPlayerName .. "/" .. InitUnitName ):ToAll() - self:ScoreAdd( InitPlayerName, "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + self:ScoreCSV( InitPlayerName, "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) end end end @@ -6082,7 +5891,7 @@ function DATABASE:_EventOnHit( Event ) end -function DATABASE:ReportScoreAll() +function SCORING:ReportScoreAll() env.info( "Hello World " ) @@ -6096,8 +5905,8 @@ function DATABASE:ReportScoreAll() self:T( "Score Player: " .. PlayerName ) -- Some variables - local InitUnitCoalition = _DATABASECoalition[PlayerData.UnitCoalition] - local InitUnitCategory = _DATABASECategory[PlayerData.UnitCategory] + local InitUnitCoalition = _SCORINGCoalition[PlayerData.UnitCoalition] + local InitUnitCategory = _SCORINGCategory[PlayerData.UnitCategory] local InitUnitType = PlayerData.UnitType local InitUnitName = PlayerData.UnitName @@ -6108,7 +5917,7 @@ function DATABASE:ReportScoreAll() local ScoreMessageHits = "" - for CategoryID, CategoryName in pairs( _DATABASECategory ) do + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do self:T( CategoryName ) if PlayerData.Hit[CategoryID] then local Score = 0 @@ -6136,7 +5945,7 @@ function DATABASE:ReportScoreAll() end local ScoreMessageKills = "" - for CategoryID, CategoryName in pairs( _DATABASECategory ) do + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do self:T( "Kill scores exist for player " .. PlayerName ) if PlayerData.Kill[CategoryID] then local Score = 0 @@ -6195,7 +6004,7 @@ function DATABASE:ReportScoreAll() end -function DATABASE:ReportScorePlayer() +function SCORING:ReportScorePlayer() env.info( "Hello World " ) @@ -6209,8 +6018,8 @@ function DATABASE:ReportScorePlayer() self:T( "Score Player: " .. PlayerName ) -- Some variables - local InitUnitCoalition = _DATABASECoalition[PlayerData.UnitCoalition] - local InitUnitCategory = _DATABASECategory[PlayerData.UnitCategory] + local InitUnitCoalition = _SCORINGCoalition[PlayerData.UnitCoalition] + local InitUnitCategory = _SCORINGCategory[PlayerData.UnitCategory] local InitUnitType = PlayerData.UnitType local InitUnitName = PlayerData.UnitName @@ -6221,7 +6030,7 @@ function DATABASE:ReportScorePlayer() local ScoreMessageHits = "" - for CategoryID, CategoryName in pairs( _DATABASECategory ) do + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do self:T( CategoryName ) if PlayerData.Hit[CategoryID] then local Score = 0 @@ -6249,7 +6058,7 @@ function DATABASE:ReportScorePlayer() end local ScoreMessageKills = "" - for CategoryID, CategoryName in pairs( _DATABASECategory ) do + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do self:T( "Kill scores exist for player " .. PlayerName ) if PlayerData.Kill[CategoryID] then local Score = 0 @@ -6309,18 +6118,7 @@ function DATABASE:ReportScorePlayer() end -function DATABASE:ScoreMenu() - local ReportScore = SUBMENU:New( 'Scoring' ) - local ReportAllScores = COMMANDMENU:New( 'Score All Active Players', ReportScore, DATABASE.ReportScoreAll, self ) - local ReportPlayerScores = COMMANDMENU:New('Your Current Score', ReportScore, DATABASE.ReportScorePlayer, self ) -end - - - - --- File Logic for tracking the scores - -function DATABASE:SecondsToClock(sSeconds) +function SCORING:SecondsToClock(sSeconds) local nSeconds = sSeconds if nSeconds == 0 then --return nil; @@ -6333,24 +6131,58 @@ function DATABASE:SecondsToClock(sSeconds) end end +--- Opens a score CSV file to log the scores. +-- @param #SCORING self +-- @param #string ScoringCSV +-- @return #SCORING self +-- @usage +-- -- Open a new CSV file to log the scores of the game Gori Valley. Let the name of the CSV file begin with "Player Scores". +-- ScoringObject = SCORING:New( "Gori Valley" ) +-- ScoringObject:OpenCSV( "Player Scores" ) +function SCORING:OpenCSV( ScoringCSV ) + self:F( ScoringCSV ) + + if lfs and io and os then + if ScoringCSV then + self.ScoringCSV = ScoringCSV + local fdir = lfs.writedir() .. [[Logs\]] .. self.ScoringCSV .. " " .. os.date( "%Y-%m-%d %H-%M-%S" ) .. ".csv" -function DATABASE:ScoreOpen() - if lfs then - local fdir = lfs.writedir() .. [[Logs\]] .. "Player_Scores_" .. os.date( "%Y-%m-%d_%H-%M-%S" ) .. ".csv" - self.StatFile, self.err = io.open(fdir,"w+") - if not self.StatFile then - error( "Error: Cannot open 'Player Scores.csv' file in " .. lfs.writedir() ) + self.CSVFile, self.err = io.open( fdir, "w+" ) + if not self.CSVFile then + error( "Error: Cannot open CSV file in " .. lfs.writedir() ) + end + + self.CSVFile:write( '"GameName","RunTime","Time","PlayerName","ScoreType","PlayerUnitCoaltion","PlayerUnitCategory","PlayerUnitType","PlayerUnitName","TargetUnitCoalition","TargetUnitCategory","TargetUnitType","TargetUnitName","Times","Score"\n' ) + + self.RunTime = os.date("%y-%m-%d_%H-%M-%S") + else + error( "A string containing the CSV file name must be given." ) end - self.StatFile:write( '"RunID","Time","PlayerName","ScoreType","PlayerUnitCoaltion","PlayerUnitCategory","PlayerUnitType","PlayerUnitName","TargetUnitCoalition","TargetUnitCategory","TargetUnitType","TargetUnitName","Times","Score"\n' ) - - self.RunID = os.date("%y-%m-%d_%H-%M-%S") + else + self:E( "The MissionScripting.lua file has not been changed to allow lfs, io and os modules to be used..." ) end + return self end -function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) +--- Registers a score for a player. +-- @param #SCORING self +-- @param #string PlayerName The name of the player. +-- @param #string ScoreType The type of the score. +-- @param #string ScoreTimes The amount of scores achieved. +-- @param #string ScoreAmount The score given. +-- @param #string PlayerUnitName The unit name of the player. +-- @param #string PlayerUnitCoalition The coalition of the player unit. +-- @param #string PlayerUnitCategory The category of the player unit. +-- @param #string PlayerUnitType The type of the player unit. +-- @param #string TargetUnitName The name of the target unit. +-- @param #string TargetUnitCoalition The coalition of the target unit. +-- @param #string TargetUnitCategory The category of the target unit. +-- @param #string TargetUnitType The type of the target unit. +-- @return #SCORING self +function SCORING:ScoreCSV( PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) --write statistic information to file - local ScoreTime = self:SecondsToClock(timer.getTime()) + local ScoreTime = self:SecondsToClock( timer.getTime() ) PlayerName = PlayerName:gsub( '"', '_' ) if PlayerUnitName and PlayerUnitName ~= '' then @@ -6358,12 +6190,12 @@ function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, Play if PlayerUnit then if not PlayerUnitCategory then - --PlayerUnitCategory = DATABASECategory[PlayerUnit:getCategory()] - PlayerUnitCategory = _DATABASECategory[PlayerUnit:getDesc().category] + --PlayerUnitCategory = SCORINGCategory[PlayerUnit:getCategory()] + PlayerUnitCategory = _SCORINGCategory[PlayerUnit:getDesc().category] end if not PlayerUnitCoalition then - PlayerUnitCoalition = _DATABASECoalition[PlayerUnit:getCoalition()] + PlayerUnitCoalition = _SCORINGCoalition[PlayerUnit:getCoalition()] end if not PlayerUnitType then @@ -6398,9 +6230,10 @@ function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, Play TargetUnitName = '' end - if lfs then - self.StatFile:write( - '"' .. self.RunID .. '"' .. ',' .. + if lfs and io and os then + self.CSVFile:write( + '"' .. self.GameName .. '"' .. ',' .. + '"' .. self.RunTime .. '"' .. ',' .. '' .. ScoreTime .. '' .. ',' .. '"' .. PlayerName .. '"' .. ',' .. '"' .. ScoreType .. '"' .. ',' .. @@ -6416,21 +6249,17 @@ function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, Play '' .. ScoreAmount ) - self.StatFile:write( "\n" ) + self.CSVFile:write( "\n" ) end end -function LogClose() - if lfs then - self.StatFile:close() +function SCORING:CloseCSV() + if lfs and io and os then + self.CSVFile:close() end end -_Database = DATABASE:New() -- Database#DATABASE -_Database:ScoreOpen() - - --- CARGO Classes -- @module CARGO @@ -6950,7 +6779,7 @@ function CARGO_GROUP:Spawn( Client ) self.CargoGroupName = self.CargoSpawn:SpawnFromUnit( self.CargoZone:GetCargoHostUnit(), 60, 30, 1 ):GetName() else --- ReSpawn the Cargo in the CargoZone without a host ... - self.CargoGroupName = self.CargoSpawn:SpawnInZone( self.CargoZone, 1 ):GetName() + self.CargoGroupName = self.CargoSpawn:SpawnInZone( self.CargoZone, true, 1 ):GetName() end self:StatusNone() end @@ -10605,7 +10434,9 @@ function MISSIONSCHEDULER.Scheduler() if MissionComplete then Mission:Completed() - _Database:_AddMissionScore( Mission.Name, 100 ) + if MISSIONSCHEDULER.Scoring then + MISSIONSCHEDULER.Scoring:_AddMissionScore( Mission.Name, 100 ) + end else if TaskComplete then -- Reset for new tasking of active client @@ -10769,6 +10600,12 @@ function MISSIONSCHEDULER:Time( TimeSeconds, TimeIntervalShow, TimeShow ) self.TimeShow = TimeShow end +--- Adds a mission scoring to the game. +function MISSIONSCHEDULER:Scoring( Scoring ) + + self.Scoring = Scoring +end + --- The CLEANUP class keeps an area clean of crashing or colliding airplanes. It also prevents airplanes from firing within this area. -- @module CleanUp -- @author Flightcontrol @@ -11732,14 +11569,17 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex ) return nil end ---- Will spawn a Group within a given @{ZONE}. +--- Will spawn a Group within a given @{Zone#ZONE}. +-- Once the group is spawned within the zone, it will continue on its route. +-- The first waypoint (where the group is spawned) is replaced with the zone coordinates. -- @param #SPAWN self --- @param #ZONE Zone The zone where the group is to be spawned. +-- @param Zone#ZONE Zone The zone where the group is to be spawned. +-- @param #number ZoneRandomize (Optional) Set to true if you want to randomize the starting point in the zone. -- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. -- @return Group#GROUP that was spawned. -- @return #nil when nothing was spawned. -function SPAWN:SpawnInZone( Zone, SpawnIndex ) - self:F( { self.SpawnTemplatePrefix, Zone, SpawnIndex } ) +function SPAWN:SpawnInZone( Zone, ZoneRandomize, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Zone, ZoneRandomize, SpawnIndex } ) if Zone then @@ -11754,11 +11594,14 @@ function SPAWN:SpawnInZone( Zone, SpawnIndex ) if SpawnTemplate then - local ZonePoint = Zone:GetPointVec2() + local ZonePoint + + if ZoneRandomize == true then + ZonePoint = Zone:GetRandomPointVec2() + else + ZonePoint = Zone:GetPointVec2() + end - SpawnTemplate.route.points = nil - SpawnTemplate.route.points = {} - SpawnTemplate.route.points[1] = {} SpawnTemplate.route.points[1].x = ZonePoint.x SpawnTemplate.route.points[1].y = ZonePoint.y @@ -11768,17 +11611,7 @@ function SPAWN:SpawnInZone( Zone, SpawnIndex ) SpawnTemplate.units[UnitID].y = ZonePoint.y self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) end - - local SpawnPos = Zone:GetRandomPointVec2() - local Point = {} - Point.type = "Turning Point" - Point.x = SpawnPos.x - Point.y = SpawnPos.y - Point.action = "Cone" - Point.speed = 5 - - table.insert( SpawnTemplate.route.points, 2, Point ) - + return self:SpawnWithIndex( self.SpawnIndex ) end end @@ -11789,6 +11622,7 @@ end + --- Will spawn a plane group in uncontrolled mode... -- This will be similar to the uncontrolled flag setting in the ME. -- @return #SPAWN self diff --git a/Moose/Cargo.lua b/Moose/Cargo.lua index e9d815870..c9e09135d 100644 --- a/Moose/Cargo.lua +++ b/Moose/Cargo.lua @@ -517,7 +517,7 @@ function CARGO_GROUP:Spawn( Client ) self.CargoGroupName = self.CargoSpawn:SpawnFromUnit( self.CargoZone:GetCargoHostUnit(), 60, 30, 1 ):GetName() else --- ReSpawn the Cargo in the CargoZone without a host ... - self.CargoGroupName = self.CargoSpawn:SpawnInZone( self.CargoZone, 1 ):GetName() + self.CargoGroupName = self.CargoSpawn:SpawnInZone( self.CargoZone, true, 1 ):GetName() end self:StatusNone() end diff --git a/Moose/Database.lua b/Moose/Database.lua index 31437191d..34a313931 100644 --- a/Moose/Database.lua +++ b/Moose/Database.lua @@ -191,6 +191,7 @@ function DATABASE:ScanEnvironment() end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then end --for coa_name, coa_data in pairs(mission.coalition) do + return self end --- Instantiate new Groups within the DCSRTE. @@ -279,4 +280,3 @@ function DATABASE:_RegisterGroup( GroupTemplate ) end - diff --git a/Moose/Mission.lua b/Moose/Mission.lua index 2420ff755..61b10e7a0 100644 --- a/Moose/Mission.lua +++ b/Moose/Mission.lua @@ -497,7 +497,9 @@ function MISSIONSCHEDULER.Scheduler() if MissionComplete then Mission:Completed() - _DATABASE:_AddMissionScore( Mission.Name, 100 ) + if MISSIONSCHEDULER.Scoring then + MISSIONSCHEDULER.Scoring:_AddMissionScore( Mission.Name, 100 ) + end else if TaskComplete then -- Reset for new tasking of active client @@ -661,3 +663,9 @@ function MISSIONSCHEDULER:Time( TimeSeconds, TimeIntervalShow, TimeShow ) self.TimeShow = TimeShow end +--- Adds a mission scoring to the game. +function MISSIONSCHEDULER:Scoring( Scoring ) + + self.Scoring = Scoring +end + diff --git a/Moose/Scoring.lua b/Moose/Scoring.lua new file mode 100644 index 000000000..53f05a831 --- /dev/null +++ b/Moose/Scoring.lua @@ -0,0 +1,815 @@ +--- Scoring system for MOOSE. +-- This scoring class calculates the hits and kills that players make within a simulation session. +-- Scoring is calculated using a defined algorithm. +-- With a small change in MissionScripting.lua, the scoring can also be logged in a CSV file, that can then be uploaded +-- to a database or a BI tool to publish the scoring results to the player community. +-- @module Scoring +-- @author FlightControl + + +Include.File( "Routines" ) +Include.File( "Base" ) +Include.File( "Menu" ) +Include.File( "Group" ) +Include.File( "Event" ) + + +--- The Scoring class +-- @type SCORING +-- @field Players A collection of the current players that have joined the game. +-- @extends Base#BASE +SCORING = { + ClassName = "SCORING", + ClassID = 0, + Players = {}, +} + +local _SCORINGCoalition = + { + [1] = "Red", + [2] = "Blue", + } + +local _SCORINGCategory = + { + [Unit.Category.AIRPLANE] = "Plane", + [Unit.Category.HELICOPTER] = "Helicopter", + [Unit.Category.GROUND_UNIT] = "Vehicle", + [Unit.Category.SHIP] = "Ship", + [Unit.Category.STRUCTURE] = "Structure", + } + +--- Creates a new SCORING object to administer the scoring achieved by players. +-- @param #SCORING self +-- @param #string GameName The name of the game. This name is also logged in the CSV score file. +-- @return #SCORING self +-- @usage +-- -- Define a new scoring object for the mission Gori Valley. +-- ScoringObject = SCORING:New( "Gori Valley" ) +function SCORING:New( GameName ) + + -- Inherits from BASE + local self = BASE:Inherit( self, BASE:New() ) + + if GameName then + self.GameName = GameName + else + error( "A game name must be given to register the scoring results" ) + end + + + _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self ) + _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self ) + _EVENTDISPATCHER:OnHit( self._EventOnHit, self ) + + self.SchedulerId = routines.scheduleFunction( SCORING._FollowPlayersScheduled, { self }, 0, 5 ) + + self:ScoreMenu() + + return self + +end + +--- Creates a score radio menu. Can be accessed using Radio -> F10. +-- @param #SCORING self +-- @return #SCORING self +function SCORING:ScoreMenu() + self.Menu = SUBMENU:New( 'Scoring' ) + self.AllScoresMenu = COMMANDMENU:New( 'Score All Active Players', self.Menu, SCORING.ReportScoreAll, self ) + --- = COMMANDMENU:New('Your Current Score', ReportScore, SCORING.ReportScorePlayer, self ) + return self +end + +--- Follows new players entering Clients within the DCSRTE. +-- TODO: Need to see if i can catch this also with an event. It will eliminate the schedule ... +function SCORING:_FollowPlayersScheduled() + self:F3( "_FollowPlayersScheduled" ) + + local ClientUnit = 0 + local CoalitionsData = { AlivePlayersRed = coalition.getPlayers(coalition.side.RED), AlivePlayersBlue = coalition.getPlayers(coalition.side.BLUE) } + local unitId + local unitData + local AlivePlayerUnits = {} + + for CoalitionId, CoalitionData in pairs( CoalitionsData ) do + self:T3( { "_FollowPlayersScheduled", CoalitionData } ) + for UnitId, UnitData in pairs( CoalitionData ) do + self:_AddPlayerFromUnit( UnitData ) + end + end +end + + +--- Track DEAD or CRASH events for the scoring. +-- @param #SCORING self +-- @param Event#EVENTDATA Event +function SCORING:_EventOnDeadOrCrash( Event ) + self:F( { Event } ) + + local TargetUnit = nil + local TargetGroup = nil + local TargetUnitName = "" + local TargetGroupName = "" + local TargetPlayerName = "" + local TargetCoalition = nil + local TargetCategory = nil + local TargetType = nil + local TargetUnitCoalition = nil + local TargetUnitCategory = nil + local TargetUnitType = nil + + if Event.IniDCSUnit then + + TargetUnit = Event.IniDCSUnit + TargetUnitName = Event.IniDCSUnitName + TargetGroup = Event.IniDCSGroup + TargetGroupName = Event.IniDCSGroupName + TargetPlayerName = TargetUnit:getPlayerName() + + TargetCoalition = TargetUnit:getCoalition() + --TargetCategory = TargetUnit:getCategory() + TargetCategory = TargetUnit:getDesc().category -- Workaround + TargetType = TargetUnit:getTypeName() + + TargetUnitCoalition = _SCORINGCoalition[TargetCoalition] + TargetUnitCategory = _SCORINGCategory[TargetCategory] + TargetUnitType = TargetType + + self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } ) + end + + for PlayerName, PlayerData in pairs( self.Players ) do + if PlayerData then -- This should normally not happen, but i'll test it anyway. + self:T( "Something got killed" ) + + -- Some variables + local InitUnitName = PlayerData.UnitName + local InitUnitType = PlayerData.UnitType + local InitCoalition = PlayerData.UnitCoalition + local InitCategory = PlayerData.UnitCategory + local InitUnitCoalition = _SCORINGCoalition[InitCoalition] + local InitUnitCategory = _SCORINGCategory[InitCategory] + + self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } ) + + -- What is he hitting? + if TargetCategory then + if PlayerData and PlayerData.Hit and PlayerData.Hit[TargetCategory] and PlayerData.Hit[TargetCategory][TargetUnitName] then -- Was there a hit for this unit for this player before registered??? + if not PlayerData.Kill[TargetCategory] then + PlayerData.Kill[TargetCategory] = {} + end + if not PlayerData.Kill[TargetCategory][TargetType] then + PlayerData.Kill[TargetCategory][TargetType] = {} + PlayerData.Kill[TargetCategory][TargetType].Score = 0 + PlayerData.Kill[TargetCategory][TargetType].ScoreKill = 0 + PlayerData.Kill[TargetCategory][TargetType].Penalty = 0 + PlayerData.Kill[TargetCategory][TargetType].PenaltyKill = 0 + end + + if InitCoalition == TargetCoalition then + PlayerData.Penalty = PlayerData.Penalty + 25 + PlayerData.Kill[TargetCategory][TargetType].Penalty = PlayerData.Kill[TargetCategory][TargetType].Penalty + 25 + PlayerData.Kill[TargetCategory][TargetType].PenaltyKill = PlayerData.Kill[TargetCategory][TargetType].PenaltyKill + 1 + MESSAGE:New( "Player '" .. PlayerName .. "' killed a friendly " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. + PlayerData.Kill[TargetCategory][TargetType].PenaltyKill .. " times. Penalty: -" .. PlayerData.Kill[TargetCategory][TargetType].Penalty .. + ". Score Total:" .. PlayerData.Score - PlayerData.Penalty, + "", 5, "/PENALTY" .. PlayerName .. "/" .. InitUnitName ):ToAll() + self:ScoreCSV( PlayerName, "KILL_PENALTY", 1, -125, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + else + PlayerData.Score = PlayerData.Score + 10 + PlayerData.Kill[TargetCategory][TargetType].Score = PlayerData.Kill[TargetCategory][TargetType].Score + 10 + PlayerData.Kill[TargetCategory][TargetType].ScoreKill = PlayerData.Kill[TargetCategory][TargetType].ScoreKill + 1 + MESSAGE:New( "Player '" .. PlayerName .. "' killed an enemy " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. + PlayerData.Kill[TargetCategory][TargetType].ScoreKill .. " times. Score: " .. PlayerData.Kill[TargetCategory][TargetType].Score .. + ". Score Total:" .. PlayerData.Score - PlayerData.Penalty, + "", 5, "/SCORE" .. PlayerName .. "/" .. InitUnitName ):ToAll() + self:ScoreCSV( PlayerName, "KILL_SCORE", 1, 10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + end + end + end + end + end +end + + + +--- Add a new player entering a Unit. +function SCORING:_AddPlayerFromUnit( UnitData ) + self:F( UnitData ) + + if UnitData:isExist() then + local UnitName = UnitData:getName() + local PlayerName = UnitData:getPlayerName() + local UnitDesc = UnitData:getDesc() + local UnitCategory = UnitDesc.category + local UnitCoalition = UnitData:getCoalition() + local UnitTypeName = UnitData:getTypeName() + + self:T( { PlayerName, UnitName, UnitCategory, UnitCoalition, UnitTypeName } ) + + if self.Players[PlayerName] == nil then -- I believe this is the place where a Player gets a life in a mission when he enters a unit ... + self.Players[PlayerName] = {} + self.Players[PlayerName].Hit = {} + self.Players[PlayerName].Kill = {} + self.Players[PlayerName].Mission = {} + + -- for CategoryID, CategoryName in pairs( SCORINGCategory ) do + -- self.Players[PlayerName].Hit[CategoryID] = {} + -- self.Players[PlayerName].Kill[CategoryID] = {} + -- end + self.Players[PlayerName].HitPlayers = {} + self.Players[PlayerName].HitUnits = {} + self.Players[PlayerName].Score = 0 + self.Players[PlayerName].Penalty = 0 + self.Players[PlayerName].PenaltyCoalition = 0 + self.Players[PlayerName].PenaltyWarning = 0 + end + + if not self.Players[PlayerName].UnitCoalition then + self.Players[PlayerName].UnitCoalition = UnitCoalition + else + if self.Players[PlayerName].UnitCoalition ~= UnitCoalition then + self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + 50 + self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1 + MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. _SCORINGCoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. _SCORINGCoalition[UnitCoalition] .. + "(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.", + "", + 2, + "/PENALTYCOALITION" .. PlayerName + ):ToAll() + self:ScoreCSV( PlayerName, "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, _SCORINGCoalition[self.Players[PlayerName].UnitCoalition], _SCORINGCategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType, + UnitName, _SCORINGCoalition[UnitCoalition], _SCORINGCategory[UnitCategory], UnitData:getTypeName() ) + end + end + self.Players[PlayerName].UnitName = UnitName + self.Players[PlayerName].UnitCoalition = UnitCoalition + self.Players[PlayerName].UnitCategory = UnitCategory + self.Players[PlayerName].UnitType = UnitTypeName + + if self.Players[PlayerName].Penalty > 100 then + if self.Players[PlayerName].PenaltyWarning < 1 then + MESSAGE:New( "Player '" .. PlayerName .. "': WARNING! If you continue to commit FRATRICIDE and have a PENALTY score higher than 150, you will be COURT MARTIALED and DISMISSED from this mission! \nYour total penalty is: " .. self.Players[PlayerName].Penalty, + "", + 30, + "/PENALTYCOALITION" .. PlayerName + ):ToAll() + self.Players[PlayerName].PenaltyWarning = self.Players[PlayerName].PenaltyWarning + 1 + end + end + + if self.Players[PlayerName].Penalty > 150 then + ClientGroup = GROUP:NewFromDCSUnit( UnitData ) + ClientGroup:Destroy() + MESSAGE:New( "Player '" .. PlayerName .. "' committed FRATRICIDE, he will be COURT MARTIALED and is DISMISSED from this mission!", + "", + 10, + "/PENALTYCOALITION" .. PlayerName + ):ToAll() + end + + end +end + + +--- Registers Scores the players completing a Mission Task. +function SCORING:_AddMissionTaskScore( PlayerUnit, MissionName, Score ) + self:F( { PlayerUnit, MissionName, Score } ) + + local PlayerName = PlayerUnit:getPlayerName() + + if not self.Players[PlayerName].Mission[MissionName] then + self.Players[PlayerName].Mission[MissionName] = {} + self.Players[PlayerName].Mission[MissionName].ScoreTask = 0 + self.Players[PlayerName].Mission[MissionName].ScoreMission = 0 + end + + self:T( PlayerName ) + self:T( self.Players[PlayerName].Mission[MissionName] ) + + self.Players[PlayerName].Score = self.Players[PlayerName].Score + Score + self.Players[PlayerName].Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score + + MESSAGE:New( "Player '" .. PlayerName .. "' has finished another Task in Mission '" .. MissionName .. "'. " .. + Score .. " Score points added.", + "", 20, "/SCORETASK" .. PlayerName ):ToAll() + + self:ScoreCSV( PlayerName, "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score, PlayerUnit:getName() ) +end + + +--- Registers Mission Scores for possible multiple players that contributed in the Mission. +function SCORING:_AddMissionScore( MissionName, Score ) + self:F( { MissionName, Score } ) + + for PlayerName, PlayerData in pairs( self.Players ) do + + if PlayerData.Mission[MissionName] then + PlayerData.Score = PlayerData.Score + Score + PlayerData.Mission[MissionName].ScoreMission = PlayerData.Mission[MissionName].ScoreMission + Score + MESSAGE:New( "Player '" .. PlayerName .. "' has finished Mission '" .. MissionName .. "'. " .. + Score .. " Score points added.", + "", 20, "/SCOREMISSION" .. PlayerName ):ToAll() + self:ScoreCSV( PlayerName, "MISSION_" .. MissionName:gsub( ' ', '_' ), 1, Score ) + end + end +end + +--- Handles the OnHit event for the scoring. +-- @param #SCORING self +-- @param Event#EVENTDATA Event +function SCORING:_EventOnHit( Event ) + self:F( { Event } ) + + local InitUnit = nil + local InitUnitName = "" + local InitGroup = nil + local InitGroupName = "" + local InitPlayerName = "dummy" + + local InitCoalition = nil + local InitCategory = nil + local InitType = nil + local InitUnitCoalition = nil + local InitUnitCategory = nil + local InitUnitType = nil + + local TargetUnit = nil + local TargetUnitName = "" + local TargetGroup = nil + local TargetGroupName = "" + local TargetPlayerName = "" + + local TargetCoalition = nil + local TargetCategory = nil + local TargetType = nil + local TargetUnitCoalition = nil + local TargetUnitCategory = nil + local TargetUnitType = nil + + if Event.IniDCSUnit then + + InitUnit = Event.IniDCSUnit + InitUnitName = Event.IniDCSUnitName + InitGroup = Event.IniDCSGroup + InitGroupName = Event.IniDCSGroupName + InitPlayerName = InitUnit:getPlayerName() + + InitCoalition = InitUnit:getCoalition() + --TODO: Workaround Client DCS Bug + --InitCategory = InitUnit:getCategory() + InitCategory = InitUnit:getDesc().category + InitType = InitUnit:getTypeName() + + InitUnitCoalition = _SCORINGCoalition[InitCoalition] + InitUnitCategory = _SCORINGCategory[InitCategory] + InitUnitType = InitType + + self:T( { InitUnitName, InitGroupName, InitPlayerName, InitCoalition, InitCategory, InitType , InitUnitCoalition, InitUnitCategory, InitUnitType } ) + end + + + if Event.TgtDCSUnit then + + TargetUnit = Event.TgtDCSUnit + TargetUnitName = Event.TgtDCSUnitName + TargetGroup = Event.TgtDCSGroup + TargetGroupName = Event.TgtDCSGroupName + TargetPlayerName = TargetUnit:getPlayerName() + + TargetCoalition = TargetUnit:getCoalition() + --TODO: Workaround Client DCS Bug + --TargetCategory = TargetUnit:getCategory() + TargetCategory = TargetUnit:getDesc().category + TargetType = TargetUnit:getTypeName() + + TargetUnitCoalition = _SCORINGCoalition[TargetCoalition] + TargetUnitCategory = _SCORINGCategory[TargetCategory] + TargetUnitType = TargetType + + self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType, TargetUnitCoalition, TargetUnitCategory, TargetUnitType } ) + end + + if InitPlayerName ~= nil then -- It is a player that is hitting something + self:_AddPlayerFromUnit( InitUnit ) + if self.Players[InitPlayerName] then -- This should normally not happen, but i'll test it anyway. + if TargetPlayerName ~= nil then -- It is a player hitting another player ... + self:_AddPlayerFromUnit( TargetUnit ) + self.Players[InitPlayerName].HitPlayers = self.Players[InitPlayerName].HitPlayers + 1 + end + + self:T( "Hitting Something" ) + -- What is he hitting? + if TargetCategory then + if not self.Players[InitPlayerName].Hit[TargetCategory] then + self.Players[InitPlayerName].Hit[TargetCategory] = {} + end + if not self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName] then + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName] = {} + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Score = 0 + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Penalty = 0 + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].ScoreHit = 0 + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].PenaltyHit = 0 + end + local Score = 0 + if InitCoalition == TargetCoalition then + self.Players[InitPlayerName].Penalty = self.Players[InitPlayerName].Penalty + 10 + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Penalty = self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Penalty + 10 + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].PenaltyHit = self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].PenaltyHit + 1 + MESSAGE:New( "Player '" .. InitPlayerName .. "' hit a friendly " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].PenaltyHit .. " times. Penalty: -" .. self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Penalty .. + ". Score Total:" .. self.Players[InitPlayerName].Score - self.Players[InitPlayerName].Penalty, + "", + 2, + "/PENALTY" .. InitPlayerName .. "/" .. InitUnitName + ):ToAll() + self:ScoreCSV( InitPlayerName, "HIT_PENALTY", 1, -25, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + else + self.Players[InitPlayerName].Score = self.Players[InitPlayerName].Score + 10 + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Score = self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Score + 1 + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].ScoreHit = self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].ScoreHit + 1 + MESSAGE:New( "Player '" .. InitPlayerName .. "' hit a target " .. TargetUnitCategory .. " ( " .. TargetType .. " ) " .. + self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].ScoreHit .. " times. Score: " .. self.Players[InitPlayerName].Hit[TargetCategory][TargetUnitName].Score .. + ". Score Total:" .. self.Players[InitPlayerName].Score - self.Players[InitPlayerName].Penalty, + "", + 2, + "/SCORE" .. InitPlayerName .. "/" .. InitUnitName + ):ToAll() + self:ScoreCSV( InitPlayerName, "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + end + end + end + elseif InitPlayerName == nil then -- It is an AI hitting a player??? + + end +end + + +function SCORING:ReportScoreAll() + + env.info( "Hello World " ) + + local ScoreMessage = "" + local PlayerMessage = "" + + self:T( "Score Report" ) + + for PlayerName, PlayerData in pairs( self.Players ) do + if PlayerData then -- This should normally not happen, but i'll test it anyway. + self:T( "Score Player: " .. PlayerName ) + + -- Some variables + local InitUnitCoalition = _SCORINGCoalition[PlayerData.UnitCoalition] + local InitUnitCategory = _SCORINGCategory[PlayerData.UnitCategory] + local InitUnitType = PlayerData.UnitType + local InitUnitName = PlayerData.UnitName + + local PlayerScore = 0 + local PlayerPenalty = 0 + + ScoreMessage = ":\n" + + local ScoreMessageHits = "" + + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do + self:T( CategoryName ) + if PlayerData.Hit[CategoryID] then + local Score = 0 + local ScoreHit = 0 + local Penalty = 0 + local PenaltyHit = 0 + self:T( "Hit scores exist for player " .. PlayerName ) + for UnitName, UnitData in pairs( PlayerData.Hit[CategoryID] ) do + Score = Score + UnitData.Score + ScoreHit = ScoreHit + UnitData.ScoreHit + Penalty = Penalty + UnitData.Penalty + PenaltyHit = UnitData.PenaltyHit + end + local ScoreMessageHit = string.format( "%s:%d ", CategoryName, Score - Penalty ) + self:T( ScoreMessageHit ) + ScoreMessageHits = ScoreMessageHits .. ScoreMessageHit + PlayerScore = PlayerScore + Score + PlayerPenalty = PlayerPenalty + Penalty + else + --ScoreMessageHits = ScoreMessageHits .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 ) + end + end + if ScoreMessageHits ~= "" then + ScoreMessage = ScoreMessage .. " Hits: " .. ScoreMessageHits .. "\n" + end + + local ScoreMessageKills = "" + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do + self:T( "Kill scores exist for player " .. PlayerName ) + if PlayerData.Kill[CategoryID] then + local Score = 0 + local ScoreKill = 0 + local Penalty = 0 + local PenaltyKill = 0 + + for UnitName, UnitData in pairs( PlayerData.Kill[CategoryID] ) do + Score = Score + UnitData.Score + ScoreKill = ScoreKill + UnitData.ScoreKill + Penalty = Penalty + UnitData.Penalty + PenaltyKill = PenaltyKill + UnitData.PenaltyKill + end + + local ScoreMessageKill = string.format( " %s:%d ", CategoryName, Score - Penalty ) + self:T( ScoreMessageKill ) + ScoreMessageKills = ScoreMessageKills .. ScoreMessageKill + + PlayerScore = PlayerScore + Score + PlayerPenalty = PlayerPenalty + Penalty + else + --ScoreMessageKills = ScoreMessageKills .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 ) + end + end + if ScoreMessageKills ~= "" then + ScoreMessage = ScoreMessage .. " Kills: " .. ScoreMessageKills .. "\n" + end + + local ScoreMessageCoalitionChangePenalties = "" + if PlayerData.PenaltyCoalition ~= 0 then + ScoreMessageCoalitionChangePenalties = ScoreMessageCoalitionChangePenalties .. string.format( " -%d (%d changed)", PlayerData.Penalty, PlayerData.PenaltyCoalition ) + PlayerPenalty = PlayerPenalty + PlayerData.Penalty + end + if ScoreMessageCoalitionChangePenalties ~= "" then + ScoreMessage = ScoreMessage .. " Coalition Penalties: " .. ScoreMessageCoalitionChangePenalties .. "\n" + end + + local ScoreMessageMission = "" + local ScoreMission = 0 + local ScoreTask = 0 + for MissionName, MissionData in pairs( PlayerData.Mission ) do + ScoreMission = ScoreMission + MissionData.ScoreMission + ScoreTask = ScoreTask + MissionData.ScoreTask + ScoreMessageMission = ScoreMessageMission .. "'" .. MissionName .. "'; " + end + PlayerScore = PlayerScore + ScoreMission + ScoreTask + + if ScoreMessageMission ~= "" then + ScoreMessage = ScoreMessage .. " Tasks: " .. ScoreTask .. " Mission: " .. ScoreMission .. " ( " .. ScoreMessageMission .. ")\n" + end + + PlayerMessage = PlayerMessage .. string.format( "Player '%s' Score:%d (%d Score -%d Penalties)%s", PlayerName, PlayerScore - PlayerPenalty, PlayerScore, PlayerPenalty, ScoreMessage ) + end + end + MESSAGE:New( PlayerMessage, "Player Scores", 30, "AllPlayerScores"):ToAll() +end + + +function SCORING:ReportScorePlayer() + + env.info( "Hello World " ) + + local ScoreMessage = "" + local PlayerMessage = "" + + self:T( "Score Report" ) + + for PlayerName, PlayerData in pairs( self.Players ) do + if PlayerData then -- This should normally not happen, but i'll test it anyway. + self:T( "Score Player: " .. PlayerName ) + + -- Some variables + local InitUnitCoalition = _SCORINGCoalition[PlayerData.UnitCoalition] + local InitUnitCategory = _SCORINGCategory[PlayerData.UnitCategory] + local InitUnitType = PlayerData.UnitType + local InitUnitName = PlayerData.UnitName + + local PlayerScore = 0 + local PlayerPenalty = 0 + + ScoreMessage = "" + + local ScoreMessageHits = "" + + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do + self:T( CategoryName ) + if PlayerData.Hit[CategoryID] then + local Score = 0 + local ScoreHit = 0 + local Penalty = 0 + local PenaltyHit = 0 + self:T( "Hit scores exist for player " .. PlayerName ) + for UnitName, UnitData in pairs( PlayerData.Hit[CategoryID] ) do + Score = Score + UnitData.Score + ScoreHit = ScoreHit + UnitData.ScoreHit + Penalty = Penalty + UnitData.Penalty + PenaltyHit = UnitData.PenaltyHit + end + local ScoreMessageHit = string.format( "\n %s = %d score(%d;-%d) hits(#%d;#-%d)", CategoryName, Score - Penalty, Score, Penalty, ScoreHit, PenaltyHit ) + self:T( ScoreMessageHit ) + ScoreMessageHits = ScoreMessageHits .. ScoreMessageHit + PlayerScore = PlayerScore + Score + PlayerPenalty = PlayerPenalty + Penalty + else + --ScoreMessageHits = ScoreMessageHits .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 ) + end + end + if ScoreMessageHits ~= "" then + ScoreMessage = ScoreMessage .. "\n Hits: " .. ScoreMessageHits .. " " + end + + local ScoreMessageKills = "" + for CategoryID, CategoryName in pairs( _SCORINGCategory ) do + self:T( "Kill scores exist for player " .. PlayerName ) + if PlayerData.Kill[CategoryID] then + local Score = 0 + local ScoreKill = 0 + local Penalty = 0 + local PenaltyKill = 0 + + for UnitName, UnitData in pairs( PlayerData.Kill[CategoryID] ) do + Score = Score + UnitData.Score + ScoreKill = ScoreKill + UnitData.ScoreKill + Penalty = Penalty + UnitData.Penalty + PenaltyKill = PenaltyKill + UnitData.PenaltyKill + end + + local ScoreMessageKill = string.format( "\n %s = %d score(%d;-%d) hits(#%d;#-%d)", CategoryName, Score - Penalty, Score, Penalty, ScoreKill, PenaltyKill ) + self:T( ScoreMessageKill ) + ScoreMessageKills = ScoreMessageKills .. ScoreMessageKill + + PlayerScore = PlayerScore + Score + PlayerPenalty = PlayerPenalty + Penalty + else + --ScoreMessageKills = ScoreMessageKills .. string.format( "%s:%d ", string.format(CategoryName, 1, 1), 0 ) + end + end + if ScoreMessageKills ~= "" then + ScoreMessage = ScoreMessage .. "\n Kills: " .. ScoreMessageKills .. " " + end + + local ScoreMessageCoalitionChangePenalties = "" + if PlayerData.PenaltyCoalition ~= 0 then + ScoreMessageCoalitionChangePenalties = ScoreMessageCoalitionChangePenalties .. string.format( " -%d (%d changed)", PlayerData.Penalty, PlayerData.PenaltyCoalition ) + PlayerPenalty = PlayerPenalty + PlayerData.Penalty + end + if ScoreMessageCoalitionChangePenalties ~= "" then + ScoreMessage = ScoreMessage .. "\n Coalition: " .. ScoreMessageCoalitionChangePenalties .. " " + end + + local ScoreMessageMission = "" + local ScoreMission = 0 + local ScoreTask = 0 + for MissionName, MissionData in pairs( PlayerData.Mission ) do + ScoreMission = ScoreMission + MissionData.ScoreMission + ScoreTask = ScoreTask + MissionData.ScoreTask + ScoreMessageMission = ScoreMessageMission .. "'" .. MissionName .. "'; " + end + PlayerScore = PlayerScore + ScoreMission + ScoreTask + + if ScoreMessageMission ~= "" then + ScoreMessage = ScoreMessage .. "\n Tasks: " .. ScoreTask .. " Mission: " .. ScoreMission .. " ( " .. ScoreMessageMission .. ") " + end + + PlayerMessage = PlayerMessage .. string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties ):%s", PlayerName, PlayerScore - PlayerPenalty, PlayerScore, PlayerPenalty, ScoreMessage ) + end + end + MESSAGE:New( PlayerMessage, "Player Scores", 30, "AllPlayerScores"):ToAll() + +end + + +function SCORING:SecondsToClock(sSeconds) + local nSeconds = sSeconds + if nSeconds == 0 then + --return nil; + return "00:00:00"; + else + nHours = string.format("%02.f", math.floor(nSeconds/3600)); + nMins = string.format("%02.f", math.floor(nSeconds/60 - (nHours*60))); + nSecs = string.format("%02.f", math.floor(nSeconds - nHours*3600 - nMins *60)); + return nHours..":"..nMins..":"..nSecs + end +end + +--- Opens a score CSV file to log the scores. +-- @param #SCORING self +-- @param #string ScoringCSV +-- @return #SCORING self +-- @usage +-- -- Open a new CSV file to log the scores of the game Gori Valley. Let the name of the CSV file begin with "Player Scores". +-- ScoringObject = SCORING:New( "Gori Valley" ) +-- ScoringObject:OpenCSV( "Player Scores" ) +function SCORING:OpenCSV( ScoringCSV ) + self:F( ScoringCSV ) + + if lfs and io and os then + if ScoringCSV then + self.ScoringCSV = ScoringCSV + local fdir = lfs.writedir() .. [[Logs\]] .. self.ScoringCSV .. " " .. os.date( "%Y-%m-%d %H-%M-%S" ) .. ".csv" + + self.CSVFile, self.err = io.open( fdir, "w+" ) + if not self.CSVFile then + error( "Error: Cannot open CSV file in " .. lfs.writedir() ) + end + + self.CSVFile:write( '"GameName","RunTime","Time","PlayerName","ScoreType","PlayerUnitCoaltion","PlayerUnitCategory","PlayerUnitType","PlayerUnitName","TargetUnitCoalition","TargetUnitCategory","TargetUnitType","TargetUnitName","Times","Score"\n' ) + + self.RunTime = os.date("%y-%m-%d_%H-%M-%S") + else + error( "A string containing the CSV file name must be given." ) + end + else + self:E( "The MissionScripting.lua file has not been changed to allow lfs, io and os modules to be used..." ) + end + return self +end + + +--- Registers a score for a player. +-- @param #SCORING self +-- @param #string PlayerName The name of the player. +-- @param #string ScoreType The type of the score. +-- @param #string ScoreTimes The amount of scores achieved. +-- @param #string ScoreAmount The score given. +-- @param #string PlayerUnitName The unit name of the player. +-- @param #string PlayerUnitCoalition The coalition of the player unit. +-- @param #string PlayerUnitCategory The category of the player unit. +-- @param #string PlayerUnitType The type of the player unit. +-- @param #string TargetUnitName The name of the target unit. +-- @param #string TargetUnitCoalition The coalition of the target unit. +-- @param #string TargetUnitCategory The category of the target unit. +-- @param #string TargetUnitType The type of the target unit. +-- @return #SCORING self +function SCORING:ScoreCSV( PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + --write statistic information to file + local ScoreTime = self:SecondsToClock( timer.getTime() ) + PlayerName = PlayerName:gsub( '"', '_' ) + + if PlayerUnitName and PlayerUnitName ~= '' then + local PlayerUnit = Unit.getByName( PlayerUnitName ) + + if PlayerUnit then + if not PlayerUnitCategory then + --PlayerUnitCategory = SCORINGCategory[PlayerUnit:getCategory()] + PlayerUnitCategory = _SCORINGCategory[PlayerUnit:getDesc().category] + end + + if not PlayerUnitCoalition then + PlayerUnitCoalition = _SCORINGCoalition[PlayerUnit:getCoalition()] + end + + if not PlayerUnitType then + PlayerUnitType = PlayerUnit:getTypeName() + end + else + PlayerUnitName = '' + PlayerUnitCategory = '' + PlayerUnitCoalition = '' + PlayerUnitType = '' + end + else + PlayerUnitName = '' + PlayerUnitCategory = '' + PlayerUnitCoalition = '' + PlayerUnitType = '' + end + + if not TargetUnitCoalition then + TargetUnitCoalition = '' + end + + if not TargetUnitCategory then + TargetUnitCategory = '' + end + + if not TargetUnitType then + TargetUnitType = '' + end + + if not TargetUnitName then + TargetUnitName = '' + end + + if lfs and io and os then + self.CSVFile:write( + '"' .. self.GameName .. '"' .. ',' .. + '"' .. self.RunTime .. '"' .. ',' .. + '' .. ScoreTime .. '' .. ',' .. + '"' .. PlayerName .. '"' .. ',' .. + '"' .. ScoreType .. '"' .. ',' .. + '"' .. PlayerUnitCoalition .. '"' .. ',' .. + '"' .. PlayerUnitCategory .. '"' .. ',' .. + '"' .. PlayerUnitType .. '"' .. ',' .. + '"' .. PlayerUnitName .. '"' .. ',' .. + '"' .. TargetUnitCoalition .. '"' .. ',' .. + '"' .. TargetUnitCategory .. '"' .. ',' .. + '"' .. TargetUnitType .. '"' .. ',' .. + '"' .. TargetUnitName .. '"' .. ',' .. + '' .. ScoreTimes .. '' .. ',' .. + '' .. ScoreAmount + ) + + self.CSVFile:write( "\n" ) + end +end + + +function SCORING:CloseCSV() + if lfs and io and os then + self.CSVFile:close() + end +end + diff --git a/Moose/Spawn.lua b/Moose/Spawn.lua index 645b69693..6049f554b 100644 --- a/Moose/Spawn.lua +++ b/Moose/Spawn.lua @@ -638,14 +638,17 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex ) return nil end ---- Will spawn a Group within a given @{ZONE}. +--- Will spawn a Group within a given @{Zone#ZONE}. +-- Once the group is spawned within the zone, it will continue on its route. +-- The first waypoint (where the group is spawned) is replaced with the zone coordinates. -- @param #SPAWN self --- @param #ZONE Zone The zone where the group is to be spawned. +-- @param Zone#ZONE Zone The zone where the group is to be spawned. +-- @param #number ZoneRandomize (Optional) Set to true if you want to randomize the starting point in the zone. -- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone. -- @return Group#GROUP that was spawned. -- @return #nil when nothing was spawned. -function SPAWN:SpawnInZone( Zone, SpawnIndex ) - self:F( { self.SpawnTemplatePrefix, Zone, SpawnIndex } ) +function SPAWN:SpawnInZone( Zone, ZoneRandomize, SpawnIndex ) + self:F( { self.SpawnTemplatePrefix, Zone, ZoneRandomize, SpawnIndex } ) if Zone then @@ -660,11 +663,14 @@ function SPAWN:SpawnInZone( Zone, SpawnIndex ) if SpawnTemplate then - local ZonePoint = Zone:GetPointVec2() + local ZonePoint + + if ZoneRandomize == true then + ZonePoint = Zone:GetRandomPointVec2() + else + ZonePoint = Zone:GetPointVec2() + end - SpawnTemplate.route.points = nil - SpawnTemplate.route.points = {} - SpawnTemplate.route.points[1] = {} SpawnTemplate.route.points[1].x = ZonePoint.x SpawnTemplate.route.points[1].y = ZonePoint.y @@ -674,17 +680,7 @@ function SPAWN:SpawnInZone( Zone, SpawnIndex ) SpawnTemplate.units[UnitID].y = ZonePoint.y self:T( 'SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y ) end - - local SpawnPos = Zone:GetRandomPointVec2() - local Point = {} - Point.type = "Turning Point" - Point.x = SpawnPos.x - Point.y = SpawnPos.y - Point.action = "Cone" - Point.speed = 5 - - table.insert( SpawnTemplate.route.points, 2, Point ) - + return self:SpawnWithIndex( self.SpawnIndex ) end end @@ -695,6 +691,7 @@ end + --- Will spawn a plane group in uncontrolled mode... -- This will be similar to the uncontrolled flag setting in the ME. -- @return #SPAWN self diff --git a/Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz b/Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz index 56f294d0a..ea146f2c5 100644 Binary files a/Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz and b/Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz differ