Merge pull request #3 from dutchie032/develop

Develop
This commit is contained in:
2024-11-06 14:32:56 +01:00
committed by GitHub
9 changed files with 88 additions and 41 deletions
+11 -2
View File
@@ -1,10 +1,11 @@
#start
name: update newsletters
name: Release
on:
push:
branches:
- main
- develop
jobs:
buildandpush:
@@ -61,8 +62,16 @@ jobs:
- 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/$sourcefileB.md --output ./$repo/Spearhead/$sourcefileB.html
- 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/
- name: ls
run: ls
+2
View File
@@ -14,6 +14,8 @@ In the example we'll show how you can create a simple island hopping mission
Firstly include the script.
<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/>
Please do exactly as it's done below. <br/>
+1 -1
View File
@@ -25,7 +25,7 @@ function StageConfig:new()
local maxMissionsPerStage = SpearheadConfig.StageConfig.maxMissionStage
o.getMaxMissionsPerStage = function(self) return maxMissionsPerStage end
o.logLevel = Spearhead.LoggerTemplate.LogLevelOptions.DEBUG
o.logLevel = Spearhead.LoggerTemplate.LogLevelOptions.INFO
o.toString = function()
return Spearhead.Util.toString({
+1 -1
View File
@@ -6,7 +6,7 @@ local fleetGroups = {}
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()
for _, groupName in pairs(all_groups) do
+7 -26
View File
@@ -445,7 +445,11 @@ do -- INIT DCS_UTIL
---checks if the groupname is a static group
---@param groupName any
function DCS_UTIL.IsGroupStatic(groupName)
return DCS_UTIL.__miz_groups[groupName].category == 5;
if DCS_UTIL.__miz_groups[groupName] then
return DCS_UTIL.__miz_groups[groupName].category == 5;
end
return StaticObject.getByName(groupName) ~= nil
end
---comment
@@ -739,8 +743,8 @@ do -- INIT DCS_UTIL
---@return table units
function DCS_UTIL.getAllPlayerUnits()
local units = {}
for key, value in pairs({ 1, 2, 3 }) do
local players = coalition.getPlayers(value)
for i = 0,2 do
local players = coalition.getPlayers(i)
for key, unit in pairs(players) do
units[#units + 1] = unit
end
@@ -782,29 +786,6 @@ do -- INIT DCS_UTIL
return result
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
--- location and route can be nil and will then use default route
---@param groupName string
+1
View File
@@ -323,6 +323,7 @@ do -- DB
functionString = functionString .. "{0,1,0,1}, {0,1,0,1}, 1)"
env.info(functionString)
---@diagnostic disable-next-line: deprecated
local f, err = loadstring(functionString)
if f then
f()
+41 -6
View File
@@ -234,7 +234,7 @@ do
do -- PLAYER ENTER UNIT
local playerEnterUnitListeners = {}
---comment
---@param listener table object with OnPlayerEnterUnit(self, unit)
---@param listener table object with OnPlayerEntersUnit(self, unit)
SpearheadEvents.AddOnPlayerEnterUnitListener = function(listener)
if type(listener) ~= "table" then
warn("Unit lost Event listener not of type table/object")
@@ -249,7 +249,7 @@ do
if playerEnterUnitListeners then
for _, callable in pairs(playerEnterUnitListeners) do
local succ, err = pcall(function()
callable:OnPlayerEnterUnit(unit)
callable:OnPlayerEntersUnit(unit)
end)
if err then
error(err)
@@ -298,10 +298,45 @@ do
end
end
if event.id == world.event.S_EVENT_PLAYER_ENTER_UNIT then
env.info("blaat player entering unit")
local groupId = event.initiator:getGroup():getID()
SpearheadEvents.AddCommandsToGroup(groupId)
local AI_GROUPS = {}
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.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
+23 -5
View File
@@ -183,17 +183,35 @@ do -- INIT Mission Class
timer.scheduleFunction(CheckAndUpdate, self, timer.getTime() + 300)
end
local CleanupDelayedAsync = function (self, time)
self:Cleanup()
return nil
end
---comment
---@param self table
---@param checkUnitHealth boolean?
o.CheckAndUpdateSelf = function(self, checkUnitHealth)
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
return
end
+1
View File
@@ -473,6 +473,7 @@ do --init STAGE DIRECTOR
mission:AddMissionCompleteListener(o)
end
Spearhead.Events.AddOnPlayerEnterUnitListener(o)
Spearhead.Events.AddOnStatusRequestReceivedListener(o)
Spearhead.Events.AddStageNumberChangedListener(o)
return o