@@ -1,10 +1,11 @@
|
|||||||
#start
|
#start
|
||||||
|
|
||||||
name: update newsletters
|
name: Release
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- develop
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
buildandpush:
|
buildandpush:
|
||||||
@@ -61,8 +62,16 @@ jobs:
|
|||||||
- run: npm i markdown-to-html-cli -g
|
- run: npm i markdown-to-html-cli -g
|
||||||
- run: markdown-to-html --title 'Spearhead' --dark-mode auto --keywords "dcs,spearhead,tdcs,mission,campaign,tactical dcs,tactical" --no-dark-mode --markdown-style-theme dark --source ./spearhead/_docs/$sourcefileA.md --output ./$repo/Spearhead/$sourcefileA.html
|
- run: markdown-to-html --title 'Spearhead' --dark-mode auto --keywords "dcs,spearhead,tdcs,mission,campaign,tactical dcs,tactical" --no-dark-mode --markdown-style-theme dark --source ./spearhead/_docs/$sourcefileA.md --output ./$repo/Spearhead/$sourcefileA.html
|
||||||
- run: markdown-to-html --title 'Spearhead' --dark-mode auto --keywords "dcs,spearhead,tdcs,mission,campaign,tactical dcs,tactical" --no-dark-mode --markdown-style-theme dark --source ./spearhead/_docs/$sourcefileB.md --output ./$repo/Spearhead/$sourcefileB.html
|
- run: markdown-to-html --title 'Spearhead' --dark-mode auto --keywords "dcs,spearhead,tdcs,mission,campaign,tactical dcs,tactical" --no-dark-mode --markdown-style-theme dark --source ./spearhead/_docs/$sourcefileB.md --output ./$repo/Spearhead/$sourcefileB.html
|
||||||
|
|
||||||
- run: python3 ./spearhead/SpearheadCompile.py "./spearhead" "./$repo/Spearhead/spearhead.lua"
|
- run: python3 ./spearhead/SpearheadCompile.py "./spearhead" "./$repo/Spearhead/spearhead.lua"
|
||||||
- run: cp "./spearhead/config.lua" "./$repo/Spearhead/spearheadConfig.lua"
|
if: github.ref == 'refs/heads/master'
|
||||||
|
|
||||||
|
- run: mkdir -p ./$repo/Spearhead/beta
|
||||||
|
if: github.ref == 'refs/heads/develop'
|
||||||
|
|
||||||
|
- run: python3 ./spearhead/SpearheadCompile.py "./spearhead" "./$repo/Spearhead/beta/spearhead.lua"
|
||||||
|
if: github.ref == 'refs/heads/develop'
|
||||||
|
|
||||||
- run: cp -a ./spearhead/_docs/img/. ./$repo/Spearhead/img/
|
- run: cp -a ./spearhead/_docs/img/. ./$repo/Spearhead/img/
|
||||||
- name: ls
|
- name: ls
|
||||||
run: ls
|
run: ls
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ In the example we'll show how you can create a simple island hopping mission
|
|||||||
|
|
||||||
Firstly include the script.
|
Firstly include the script.
|
||||||
<a download="spearhead.lua" href="./spearhead.lua" target="_blank" rel="noopener noreferrer">Download Script</a>
|
<a download="spearhead.lua" href="./spearhead.lua" target="_blank" rel="noopener noreferrer">Download Script</a>
|
||||||
|
<br/>Or if you want to use the latest beta version:
|
||||||
|
<a download="spearhead.lua" href="./beta/spearhead.lua" target="_blank" rel="noopener noreferrer">Download Beta Script</a>
|
||||||
|
|
||||||
Then run the script in the mission. <br/>
|
Then run the script in the mission. <br/>
|
||||||
Please do exactly as it's done below. <br/>
|
Please do exactly as it's done below. <br/>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ function StageConfig:new()
|
|||||||
local maxMissionsPerStage = SpearheadConfig.StageConfig.maxMissionStage
|
local maxMissionsPerStage = SpearheadConfig.StageConfig.maxMissionStage
|
||||||
o.getMaxMissionsPerStage = function(self) return maxMissionsPerStage end
|
o.getMaxMissionsPerStage = function(self) return maxMissionsPerStage end
|
||||||
|
|
||||||
o.logLevel = Spearhead.LoggerTemplate.LogLevelOptions.DEBUG
|
o.logLevel = Spearhead.LoggerTemplate.LogLevelOptions.INFO
|
||||||
|
|
||||||
o.toString = function()
|
o.toString = function()
|
||||||
return Spearhead.Util.toString({
|
return Spearhead.Util.toString({
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ local fleetGroups = {}
|
|||||||
|
|
||||||
GlobalFleetManager.start = function(database)
|
GlobalFleetManager.start = function(database)
|
||||||
|
|
||||||
local logger = Spearhead.LoggerTemplate:new("CARRIERFLEET", Spearhead.LoggerTemplate.LogLevelOptions.DEBUG)
|
local logger = Spearhead.LoggerTemplate:new("CARRIERFLEET", Spearhead.LoggerTemplate.LogLevelOptions.INFO)
|
||||||
|
|
||||||
local all_groups = Spearhead.DcsUtil.getAllGroupNames()
|
local all_groups = Spearhead.DcsUtil.getAllGroupNames()
|
||||||
for _, groupName in pairs(all_groups) do
|
for _, groupName in pairs(all_groups) do
|
||||||
|
|||||||
@@ -445,9 +445,13 @@ do -- INIT DCS_UTIL
|
|||||||
---checks if the groupname is a static group
|
---checks if the groupname is a static group
|
||||||
---@param groupName any
|
---@param groupName any
|
||||||
function DCS_UTIL.IsGroupStatic(groupName)
|
function DCS_UTIL.IsGroupStatic(groupName)
|
||||||
|
if DCS_UTIL.__miz_groups[groupName] then
|
||||||
return DCS_UTIL.__miz_groups[groupName].category == 5;
|
return DCS_UTIL.__miz_groups[groupName].category == 5;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return StaticObject.getByName(groupName) ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@param groupName string destroy the given group
|
---@param groupName string destroy the given group
|
||||||
function DCS_UTIL.DestroyGroup(groupName)
|
function DCS_UTIL.DestroyGroup(groupName)
|
||||||
@@ -739,8 +743,8 @@ do -- INIT DCS_UTIL
|
|||||||
---@return table units
|
---@return table units
|
||||||
function DCS_UTIL.getAllPlayerUnits()
|
function DCS_UTIL.getAllPlayerUnits()
|
||||||
local units = {}
|
local units = {}
|
||||||
for key, value in pairs({ 1, 2, 3 }) do
|
for i = 0,2 do
|
||||||
local players = coalition.getPlayers(value)
|
local players = coalition.getPlayers(i)
|
||||||
for key, unit in pairs(players) do
|
for key, unit in pairs(players) do
|
||||||
units[#units + 1] = unit
|
units[#units + 1] = unit
|
||||||
end
|
end
|
||||||
@@ -782,29 +786,6 @@ do -- INIT DCS_UTIL
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
---Gets all groups that have players
|
|
||||||
---@return table groups
|
|
||||||
function DCS_UTIL.getAllPlayerGroups()
|
|
||||||
local groupNames = {}
|
|
||||||
local result = {}
|
|
||||||
for key, value in pairs({ 1, 2, 3 }) do
|
|
||||||
local players = coalition.getPlayers(value)
|
|
||||||
for key, unit in pairs(players) do
|
|
||||||
local group = unit:getGroup()
|
|
||||||
if group ~= nil then
|
|
||||||
local name = group:getName()
|
|
||||||
if name ~= nil then
|
|
||||||
if groupNames[name] ~= nil then
|
|
||||||
groupNames[name] = 1
|
|
||||||
table.insert(result, group)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
--- spawns the units as specified in the mission file itself
|
--- spawns the units as specified in the mission file itself
|
||||||
--- location and route can be nil and will then use default route
|
--- location and route can be nil and will then use default route
|
||||||
---@param groupName string
|
---@param groupName string
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ do -- DB
|
|||||||
functionString = functionString .. "{0,1,0,1}, {0,1,0,1}, 1)"
|
functionString = functionString .. "{0,1,0,1}, {0,1,0,1}, 1)"
|
||||||
|
|
||||||
env.info(functionString)
|
env.info(functionString)
|
||||||
|
---@diagnostic disable-next-line: deprecated
|
||||||
local f, err = loadstring(functionString)
|
local f, err = loadstring(functionString)
|
||||||
if f then
|
if f then
|
||||||
f()
|
f()
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ do
|
|||||||
do -- PLAYER ENTER UNIT
|
do -- PLAYER ENTER UNIT
|
||||||
local playerEnterUnitListeners = {}
|
local playerEnterUnitListeners = {}
|
||||||
---comment
|
---comment
|
||||||
---@param listener table object with OnPlayerEnterUnit(self, unit)
|
---@param listener table object with OnPlayerEntersUnit(self, unit)
|
||||||
SpearheadEvents.AddOnPlayerEnterUnitListener = function(listener)
|
SpearheadEvents.AddOnPlayerEnterUnitListener = function(listener)
|
||||||
if type(listener) ~= "table" then
|
if type(listener) ~= "table" then
|
||||||
warn("Unit lost Event listener not of type table/object")
|
warn("Unit lost Event listener not of type table/object")
|
||||||
@@ -249,7 +249,7 @@ do
|
|||||||
if playerEnterUnitListeners then
|
if playerEnterUnitListeners then
|
||||||
for _, callable in pairs(playerEnterUnitListeners) do
|
for _, callable in pairs(playerEnterUnitListeners) do
|
||||||
local succ, err = pcall(function()
|
local succ, err = pcall(function()
|
||||||
callable:OnPlayerEnterUnit(unit)
|
callable:OnPlayerEntersUnit(unit)
|
||||||
end)
|
end)
|
||||||
if err then
|
if err then
|
||||||
error(err)
|
error(err)
|
||||||
@@ -298,10 +298,45 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.id == world.event.S_EVENT_PLAYER_ENTER_UNIT then
|
local AI_GROUPS = {}
|
||||||
env.info("blaat player entering unit")
|
|
||||||
local groupId = event.initiator:getGroup():getID()
|
local function CheckAndTriggerSpawnAsync(unit, time)
|
||||||
|
local function isPlayer(unit)
|
||||||
|
if unit == nil then return false, "unit is nil" end
|
||||||
|
if unit:isExist() ~= true then return false, "unit does not exist" end
|
||||||
|
local group = unit:getGroup()
|
||||||
|
if group ~= nil then
|
||||||
|
if Spearhead.DcsUtil.IsGroupStatic(group:getName()) == true then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if AI_GROUPS[group:getName()] == true then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local players = Spearhead.DcsUtil.getAllPlayerUnits()
|
||||||
|
local unitName = unit:getName()
|
||||||
|
for i, unit in pairs(players) do
|
||||||
|
if unit:getName() == unitName then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
AI_GROUPS[group:getName()] = true
|
||||||
|
end
|
||||||
|
return false, "unit is nil or does not exist"
|
||||||
|
end
|
||||||
|
|
||||||
|
if isPlayer(unit) == true then
|
||||||
|
local groupId = unit:getGroup():getID()
|
||||||
SpearheadEvents.AddCommandsToGroup(groupId)
|
SpearheadEvents.AddCommandsToGroup(groupId)
|
||||||
|
SpearheadEvents.TriggerPlayerEntersUnit(unit)
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if event.id == world.event.S_EVENT_BIRTH then
|
||||||
|
timer.scheduleFunction(CheckAndTriggerSpawnAsync, event.initiator, timer.getTime() + 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -183,17 +183,35 @@ do -- INIT Mission Class
|
|||||||
timer.scheduleFunction(CheckAndUpdate, self, timer.getTime() + 300)
|
timer.scheduleFunction(CheckAndUpdate, self, timer.getTime() + 300)
|
||||||
end
|
end
|
||||||
|
|
||||||
local CleanupDelayedAsync = function (self, time)
|
|
||||||
self:Cleanup()
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@param self table
|
---@param self table
|
||||||
---@param checkUnitHealth boolean?
|
---@param checkUnitHealth boolean?
|
||||||
o.CheckAndUpdateSelf = function(self, checkUnitHealth)
|
o.CheckAndUpdateSelf = function(self, checkUnitHealth)
|
||||||
if not checkUnitHealth then checkUnitHealth = false end
|
if not checkUnitHealth then checkUnitHealth = false end
|
||||||
|
|
||||||
|
if checkUnitHealth == true then
|
||||||
|
local function unitAliveState(unitName)
|
||||||
|
local unit = Unit.getByName(unitName)
|
||||||
|
return unit ~= nil and unit:isExist() == true and unit:getLife() > 0.1
|
||||||
|
end
|
||||||
|
|
||||||
|
for groupName, unitNameDict in pairs(self.groupUnitAliveDict) do
|
||||||
|
for unitName, isAlive in pairs(unitNameDict) do
|
||||||
|
if isAlive == true then
|
||||||
|
self.groupUnitAliveDict[groupName][unitName] = unitAliveState(unitName)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for groupName, unitNameDict in pairs(self.targetAliveStates) do
|
||||||
|
for unitName, isAlive in pairs(unitNameDict) do
|
||||||
|
if isAlive == true then
|
||||||
|
self.targetAliveStates[groupName][unitName] = unitAliveState(unitName)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if self.missionState == Mission.MissionState.COMPLETED then
|
if self.missionState == Mission.MissionState.COMPLETED then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ do --init STAGE DIRECTOR
|
|||||||
mission:AddMissionCompleteListener(o)
|
mission:AddMissionCompleteListener(o)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Spearhead.Events.AddOnPlayerEnterUnitListener(o)
|
||||||
Spearhead.Events.AddOnStatusRequestReceivedListener(o)
|
Spearhead.Events.AddOnStatusRequestReceivedListener(o)
|
||||||
Spearhead.Events.AddStageNumberChangedListener(o)
|
Spearhead.Events.AddStageNumberChangedListener(o)
|
||||||
return o
|
return o
|
||||||
|
|||||||
Reference in New Issue
Block a user