**TODO:**

- finish Range:activeTartgets()
    - add function Range:addTargetPreset(group/groupName,targetType)
    - add function Range:RemoveTargetPreset(group/groupName,targetType)
This commit is contained in:
2024-12-31 17:14:55 +08:00
parent 586f142e78
commit 9163433bc8
2 changed files with 78 additions and 7 deletions
+4
View File
@@ -41,6 +41,8 @@ Localizations = {
--AutoRespawn
['Auto Respawn Targets: On'] = 'Auto Respawn Targets: On',
['Auto Respawn Targets: Off'] = 'Auto Respawn Targets: Off',
--Message
['There is no range section of %s left.'] = 'There is no range section of %s left.',
},
--中文
@@ -83,6 +85,8 @@ Localizations = {
--AutoRespawn
['Auto Respawn Targets: On'] = '目标自动重生: 开',
['Auto Respawn Targets: Off'] = '目标自动重生: 关',
--Message
['There is no range section of %s left.'] = '没有 %s 类型靶场空闲了.',
}
}
+74 -7
View File
@@ -1,3 +1,12 @@
--[[
24.13.31.1714
TODO:
- finish Range:activeTartgets()
- add function Range:addTargetPreset(group/groupName,targetType)
- add function Range:RemoveTargetPreset(group/groupName,targetType)
]]
Range = {
MonitorRepeatTime = 5, --Seconds
MonitorID = nil,
@@ -27,6 +36,8 @@ Range = {
-- TELE = 'Tele',
},
targetPresets = {},
sections = {},
playerList = {},
@@ -201,8 +212,7 @@ do
local FightBackSwitchName = Localizations:translate(string.format('Targets open fire: %s',switch),'cn')
missionCommands.addCommandForGroup(groupID,FightBackSwitchName,SettingsMenu,function (vars)
local self = vars.context
self.playerList[playerName].isTargerRedAlert = not self.playerList[playerName].isTargerRedAlert
self:createMenu(playerGroup)
self:setTargetFightBack(playerGroup)
end,{context = self})
switch = 'Off'
@@ -213,8 +223,7 @@ do
local AutoRespawnSwitchName = Localizations:translate(string.format('Auto Respawn Targets: %s',switch),'cn')
missionCommands.addCommandForGroup(groupID,AutoRespawnSwitchName,SettingsMenu,function (vars)
local self = vars.context
self.playerList[playerName].autoRespawn = not self.playerList[playerName].autoRespawn
self:createMenu(playerGroup)
self:setTargetAutoRespawn(playerGroup)
end,{context = self})
end
@@ -237,6 +246,7 @@ do
autoRespawn = false,
isTargerRedAlert = false,
activeTarget = nil,
targetData = {},
menu = nil,
}
self:createMenu(playerGroup)
@@ -253,13 +263,46 @@ do
self.playerList[PlayerName] = nil
end
function Range:activeTartgets(section,targetType,AAType,Move)
function Range:activeTartgets(sectionType,targetType,AAType,Move)
if not sectionType then return end
if not targetType then return end
AAType = AAType or 'none'
Move = Move or false
--Debug
local isMove = 'Stationary'
if Move then
isMove = 'Moving'
end
Utils.Debug('section:'..section..' targetType: '..' AAType: '..AAType..' Move: '..isMove)
Utils.Debug('section:'..sectionType..' targetType: '..' AAType: '..AAType..' Move: '..isMove)
--Get sectionZone
local sectionZone = nil
for i=1,#self.sections[sectionType],1 do
local zoneNum = math.random(1,#self.sections[sectionType])
if not self.sections[sectionType][zoneNum].active then
sectionZone = self.sections[sectionType][zoneNum]
self.sections[sectionType][zoneNum].active = true
end
end
if not sectionZone then
for i=1,#self.sections[sectionType],1 do
if not self.sections[sectionType][i].active then
sectionZone = self.sections[sectionType][i]
self.sections[sectionType][i].active = true
end
end
end
if not sectionZone then
trigger.action.outTextForGroup(string.format(Localizations:translate('There is no range section of %s left.','cn'),Localizations:translate(sectionType,'cn')))
return
end
--Get target types
end
function Range:deactivateTargets(PlayerName)
@@ -277,8 +320,32 @@ do
if not playerUnit then return end
if not playerUnit:isActive() then return end
local playerName = playerUnit:getPlayerName()
if not playerName then return end
self.playerList[playerName].isTargerRedAlert = not self.playerList[playerName].isTargerRedAlert
if self.playerList[playerName].activeTarget then
local Controller = self.playerList[playerName].activeTarget:getController()
if Controller then
Controller:setOption(AI.Option.Ground.id.ROE,AI.Option.Ground.val.ROE.WEAPON_HOLD)
Controller:setOption(AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.GREEN)
end
end
self:createMenu(playerGroup)
end
function Range:setTargetAutoRespawn(playerGroup)
if not playerGroup then return end
local playerUnit = playerGroup:getUnit(1)
if not playerUnit then return end
if not playerUnit:isActive() then return end
local playerName = playerUnit:getPlayerName()
if not playerName then return end
self.playerList[playerName].autoRespawn = not self.playerList[playerName].autoRespawn
self:createMenu(playerGroup)
end