Fixed MP issue and added a beta version for develop branch
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -298,10 +298,36 @@ 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 = {}
|
||||
|
||||
if event.id == world.event.S_EVENT_BIRTH then
|
||||
|
||||
local function isPlayer(unit)
|
||||
if Spearhead.DcsUtil.IsGroupStatic(unit:getName()) == true then
|
||||
return false
|
||||
end
|
||||
|
||||
if AI_GROUPS[unit:getGroup():getName()] == true then
|
||||
return false
|
||||
end
|
||||
|
||||
local players = Spearhead.DcsUtil.getAllPlayerUnits()
|
||||
local unitName = unit:getName()
|
||||
for i, unit in (players) do
|
||||
if unit:getName() == unitName then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
AI_GROUPS[unit:getGroup():getName()] = true
|
||||
return false
|
||||
end
|
||||
|
||||
if isPlayer(event.initiator) == true then
|
||||
local groupId = event.initiator:getGroup():getID()
|
||||
SpearheadEvents.AddCommandsToGroup(groupId)
|
||||
SpearheadEvents.TriggerPlayerEntersUnit(event.initiator)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user