diff --git a/Buta-018-EagleHunt.miz b/Buta-018-EagleHunt.miz index 0361afe..e798960 100644 Binary files a/Buta-018-EagleHunt.miz and b/Buta-018-EagleHunt.miz differ diff --git a/Doc/Brief.ppt b/Doc/Brief.ppt new file mode 100644 index 0000000..73283ff Binary files /dev/null and b/Doc/Brief.ppt differ diff --git a/Doc/新建 文本文档.txt b/Doc/新建 文本文档.txt new file mode 100644 index 0000000..67b31ff --- /dev/null +++ b/Doc/新建 文本文档.txt @@ -0,0 +1,5 @@ +AH64: MGRS GRID: 37 S DU 27680 19875 + +Cargo: +N34°36'33" +E38°14'34" \ No newline at end of file diff --git a/Scripts/PatrolUnit.lua b/Scripts/PatrolUnit.lua index 14e370c..3fd7ef1 100644 --- a/Scripts/PatrolUnit.lua +++ b/Scripts/PatrolUnit.lua @@ -29,6 +29,18 @@ PatrolUnit.Database = { fireRange = 2500, eyeHight = 3, }, + ['HL_KORD'] = { + fireRange = 1200, + eyeHight = 3, + }, + ['tt_DSHK'] = { + fireRange = 1200, + eyeHight = 3, + }, + ['tt_KORD'] = { + fireRange = 1200, + eyeHight = 3, + }, } PatrolUnit.AllGroups = {} do @@ -50,6 +62,18 @@ do return end + if PatrolUnit.DebugMod then + local unitType = unit:getTypeName() + + if unitType then + Utils.Debug('UnitType: '..unitType) + end + + if not unitType then + Utils.Debug('UnitType: nil') + end + end + fireRange = fireRange or PatrolUnit.Database[unit:getTypeName()].fireRange or PatrolUnit.DefaultFireRange eyeHight = eyeHight or PatrolUnit.Database[unit:getTypeName()].eyeHight or PatrolUnit.DefaultEyeHight @@ -190,21 +214,21 @@ do [1] = { x = roadPoint_start.x, y = roadPoint_start.y, - speed = 1000, + speed = math.random(40,60)/3.6, type = AI.Task.WaypointType.TURNING_POINT, action = AI.Task.VehicleFormation.ON_ROAD, }, [2] = { x = roadPoint_end.x, y = roadPoint_end.y, - speed = 1000, + speed = math.random(40,60)/3.6, type = AI.Task.WaypointType.TURNING_POINT, action = AI.Task.VehicleFormation.ON_ROAD, }, [3] = { x = endPoint_vec3.x, y = endPoint_vec3.z, - speed = 1000, + speed = math.random(40,60)/3.6, type = AI.Task.WaypointType.TURNING_POINT, action = AI.Task.VehicleFormation.OFF_ROAD, }, @@ -228,6 +252,11 @@ do local self = vars.context local repeatTime = vars.repeatTime + if not self.group:isExist() then + self:Remove() + return + end + local myUnit = self.group:getUnit(1) if not myUnit then self:remove() return end if not myUnit:isActive() then return time + repeatTime end @@ -350,7 +379,7 @@ do local patrolGroupName = 'Red-Patrol-AAA-' - for i=1,20,1 do + for i=1,30,1 do if not Group.getByName(patrolGroupName..i) then return end PatrolUnit:New(patrolGroupName..i) end diff --git a/Scripts/misc.lua b/Scripts/misc.lua index 420ceac..931138b 100644 --- a/Scripts/misc.lua +++ b/Scripts/misc.lua @@ -1,18 +1,23 @@ -- hanle miscellaneous mission events --Red alarm when under attack +local redAlarmEvent = { + DebugMode = false, + redAlarm = false, + ignoreList = { + ['Red-RescueInf-1'] = true, + ['Red-Scud'] = true, + }, + alarmOffGroups = { + ['Red-PowerStation-1'] = true, + }, +} do - local redAlarmEvent = { - redAlarm = false, - ignoreList = { - ['Red-RescueInf-1'] = true, - ['Red-Scud'] = true, - } - } function redAlarmEvent:redAlarm_On() - Utils.Debug('==================\n\n敌人因为受到攻击, 拉响了警报!\n\n==================') + if self.redAlarm then return end + Utils.Debug('==================\n\n敌人因为受到攻击, 拉响了警报!\n\n==================') self.redAlarm = true local redGrounds = coalition.getGroups(1,Group.Category.GROUND) @@ -26,6 +31,9 @@ do if not groupIsActivate and not redAlarmEvent.ignoreList[group:getName()] then + if redAlarmEvent.DebugMode then + Utils.Debug('Activate Group: '..group:getName()) + end timer.scheduleFunction(function (group) group:activate() end,group,timer.getTime()+math.random(120,600)) @@ -37,12 +45,27 @@ do function redAlarmEvent:onEvent(event) if not self.redAlarm then - if event.id == world.event.S_EVENT_HIT or event.id == world.event.S_EVENT_KILL or event.id == world.event.S_EVENT_DEAD then - local object = event.initiator - if not object:getCoalition() == 1 then return end - if object:getName() == 'Red-PowerStation-1' then return end + if event.id == world.event.S_EVENT_HIT then + local object = event.target + if not object then return end + if not object:isExist() then return end - local objectCategory, unitCategory = Unit.getCategory(object) + if not object.getCoalition then return end + if object:getCoalition() == 2 then return end + + for groupName, value in pairs(redAlarmEvent.alarmOffGroups) do + + if redAlarmEvent.DebugMode then + Utils.Debug('redAlarmEvent - Trigger Group: '..object:getName()) + Utils.Debug('redAlarmEvent - groupName: '..groupName) + end + + if object:getName() == groupName then + return + end + end + + local objectCategory, unitCategory = Object.getCategory(object) if objectCategory == Object.Category.UNIT then if unitCategory == Unit.Category.GROUND_UNIT or unitCategory == Unit.Category.STRUCTURE then self:redAlarm_On() @@ -145,8 +168,10 @@ do newStaticObjs = {}, } function PowerStationEvent:onEvent(event) - if event.id == world.event.S_EVENT_KILL or event.id == world.event.S_EVENT_DEAD then + if event.id == world.event.S_EVENT_DEAD then local object = event.initiator + if not object.getName then return end + if object:getName() == 'Red-PowerStation-1' then -- 关闭防空 for i, groupName in ipairs(PowerStationEvent.connectedGroupList) do @@ -239,17 +264,313 @@ do world.addEventHandler(PowerStationEvent) end ---Debug -local PowerStation = StaticObject.getByName('Red-PowerStation-1') -if not PowerStation then return end +-- Mines +do + Mines = {} -timer.scheduleFunction(function (PowerStation) - Utils.Debug('触发电厂被炸event') + Mines.DebugMod = false + Mines.DetectionRange = 1500 + Mines.FireRange = 300 - event = { - id = world.event.S_EVENT_DEAD, - initiator = PowerStation, - } + Mines.TriggerExplode = 0.5 --kg + Mines.Warhead_AH = 3 --kg - world.onEvent(event) -end,PowerStation,timer.getTime()+10) \ No newline at end of file + Mines.Warhead_AG = 6 --kg + + Mines.MonitorStartDelay = 1 + Mines.MonitorRepeatTime = 30 + Mines.ActivatedMonitorRepeatTime = 2 + + Mines.MineFieldZonePolygon = Utils.getWayPoints('mineZoneGroup-1') + + if Utils.getTableSize(Mines.MineFieldZonePolygon) < 3 then + if Mines.DebugMod then + Utils.Debug('Misc.lua - Mines: MineFieldZonePolygon has not enough waypoints.') + end + return + end + -- DrawMineZone + Utils.drawPolygon(-1,Utils.getMarkID(),Mines.MineFieldZonePolygon,{0,0,0,0.1},{0,0,0,0.1},2) + + + Mines.AllMines = {} + + function Mines:New(staticObject) + if not staticObject then return end + + local obj = {} + obj.staticObject = staticObject + obj.staticObjectName = staticObject:getName() + obj.point = staticObject:getPoint() + + if Mines.DebugMod then + trigger.action.circleToAll(-1,Utils.getMarkID(),obj.point,Mines.DetectionRange,{1,0,0,1},{1,0,0,0.3},2) + trigger.action.circleToAll(-1,Utils.getMarkID(),obj.point,Mines.FireRange,{1,0,0,1},{1,0,0,0.5},1) + end + + setmetatable(obj, self) + self.__index = self + + Mines.AllMines[obj.staticObjectName] = obj + obj:Start() + + return obj + end + + function Mines:Remove(removeStatic) + if not Mines.AllMines[self.staticObjectName] then return end + self:ActivatedMonitorStop() + self:Stop() + + if removeStatic then + if self.staticObject then + if self.staticObject:isExist() then + self.staticObject:destroy() + end + end + end + + Mines.AllMines[self.staticObjectName] = nil + end + + function Mines:TriggerActive(targetPoint,targetSpeed,targetHeading) + if not targetPoint then return end + if type(targetPoint) ~= 'table' then return end + + if not self.staticObject:isExist() then + self:Remove() + return + end + + if self.staticObject:getLife() < 1 then + self:Remove() + return + end + + -- trigger explode + trigger.action.explosion(self.point,Mines.TriggerExplode) + self:Remove(true) + + -- Warhead_AH explode + local shellTravelTime = math.random(3,5)*0.1 + local predictedExplodePoint = Utils.vecTranslate(targetPoint,targetHeading,(targetSpeed*shellTravelTime)) + predictedExplodePoint.z = predictedExplodePoint.y + predictedExplodePoint.y = targetPoint.y + + timer.scheduleFunction(function (predictedExplodePoint) + + local explodePoint = Utils.deepCopy(predictedExplodePoint) + + -- x + if math.random(1,10) >= 5 then + explodePoint.x = explodePoint.x + math.random(25,80)*0.1 + else + explodePoint.x = explodePoint.x - math.random(25,80)*0.1 + end + + -- z + if math.random(1,10) >= 5 then + explodePoint.z = explodePoint.z + math.random(25,80)*0.1 + else + explodePoint.z = explodePoint.z - math.random(25,80)*0.1 + end + + -- y + if math.random(1,10) >= 5 then + explodePoint.y = explodePoint.y + math.random(0,50)*0.1 + else + explodePoint.y = explodePoint.y - math.random(0,50)*0.1 + end + + trigger.action.explosion(explodePoint,Mines.Warhead_AH) + end,predictedExplodePoint,timer.getTime()+shellTravelTime) + end + + function Mines._ActivatedMonitorFunction(vars,time) + local self = vars.context + local repeatTime = vars.repeatTime + + if Mines.DebugMod then + Utils.Debug('_ActivatedMonitorFunction.') + end + + local target = vars.target + if not target then return end + if not target:isExist() then return end + if target:getLife() < 1 then return end + + local targetPoint = target:getPoint() + local Distance = Utils.get3DDist(targetPoint,self.point) + + if Mines.DebugMod then + Utils.Debug('Distance: '..Distance) + end + + if Distance > Mines.DetectionRange then + if Mines.DebugMod then + Utils.Debug('Enemy unit out mine DetectionRange.') + end + + self:ActivatedMonitorStop() + self:Start(1) + return + end + + if Distance <= Mines.FireRange then + local chance = math.random(1,10) + if chance >= 5 then + + local targetSpeed = Utils.mag(target:getVelocity()) + local targetHeading = math.deg(Utils.getObjHeading(target)) + + trigger.action.outText(target:getName()..'触发了防空地雷!',10) + self:TriggerActive(targetPoint,targetSpeed,targetHeading) + + return + end + end + + return time + repeatTime + end + + function Mines:ActivatedMonitorStart(target,Delay,RepeatScanSeconds) + if not target then return end + + Mines.MonitorStartDelay = Delay or Mines.MonitorStartDelay + + local tDelay = Delay or Mines.MonitorStartDelay + + local RepeatScanInterval = RepeatScanSeconds or Mines.ActivatedMonitorRepeatTime + + if self.ActivatedMonitorID then + self:ActivatedMonitorStop() + end + + self.ActivatedMonitorID = timer.scheduleFunction(self._ActivatedMonitorFunction,{target = target,context = self,repeatTime = RepeatScanInterval},timer.getTime() + tDelay) + end + + function Mines:ActivatedMonitorStop() + if not self.ActivatedMonitorID then return end + + timer.removeFunction(self.ActivatedMonitorID) + self.ActivatedMonitorID = nil + end + + function Mines:CheckEnemyInDetectionRange(enemyGroup) + if enemyGroup:isExist() then + for j,unit in ipairs(enemyGroup:getUnits()) do + if unit:getLife() > 1 then + local enemyPoint = unit:getPoint() + local Distance = Utils.get3DDist(enemyPoint,self.point) + + if Mines.DebugMod then + -- Utils.Debug('Distance: '..Distance) + end + + if Distance <= self.DetectionRange then + if math.random(1,10) < 7 then + if Mines.DebugMod then + Utils.Debug('Helo unit in mine DetectionRange.') + end + + self:ActivatedMonitorStart(unit,1) + return true + end + end + end + end + end + + return false + end + + function Mines._MonitorFunction(vars,time) + local self = vars.context + local repeatTime = vars.repeatTime + + if Mines.DebugMod then + -- Utils.Debug('_MonitorFunction') + end + + --AG + local enemyGroundGroups = coalition.getGroups(coalition.side.BLUE,Group.Category.GROUND) + for i,group in ipairs(enemyGroundGroups) do + for j,unit in ipairs(group:getUnits()) do + local enemyPoint = unit:getPoint() + if Utils.pointInPolygon(enemyPoint, Mines.MineFieldZonePolygon) then + if Mines.DebugMod then + Utils.Debug('Ground unit in mine polygon.') + end + + local chance = math.random(1,100) + if chance > 70 then + trigger.action.explosion(enemyPoint,Mines.Warhead_AG) + end + end + end + end + + --AH + local enemyHeloGroups = coalition.getGroups(coalition.side.BLUE,Group.Category.HELICOPTER) + for i,group in ipairs(enemyHeloGroups) do + if self:CheckEnemyInDetectionRange(group) then + self:Stop() + break + end + end + + local enemyPlaneGroups = coalition.getGroups(coalition.side.BLUE,Group.Category.AIRPLANE) + for i,group in ipairs(enemyPlaneGroups) do + if self:CheckEnemyInDetectionRange(group) then + self:Stop() + break + end + end + + return time + repeatTime + end + + function Mines:Start(Delay,RepeatScanSeconds) + Mines.MonitorStartDelay = Delay or Mines.MonitorStartDelay + + local tDelay = Delay or Mines.MonitorStartDelay + Mines.MonitorStartDelay = Mines.MonitorStartDelay + 1 + + local RepeatScanInterval = RepeatScanSeconds or Mines.MonitorRepeatTime + + if self.MonitorID then + self:Stop() + end + + self.MonitorID = timer.scheduleFunction(self._MonitorFunction,{context = self,repeatTime = RepeatScanInterval},timer.getTime() + tDelay) + end + + function Mines:Stop() + if not self.MonitorID then return end + + timer.removeFunction(self.MonitorID) + self.MonitorID = nil + end + + --- Init + for i=1,200,1 do + local myMinesStaticObjName = 'Static Barrel-'..i..'-1' + local myMineStaticObj = StaticObject.getByName(myMinesStaticObjName) + if myMineStaticObj then + local myMine = Mines:New(myMineStaticObj) + end + + -- Add mines to alarm ignore + redAlarmEvent.alarmOffGroups[myMinesStaticObjName] = true + end + + -- Add Patrol to alarm ignore + if PatrolUnit then + if PatrolUnit.AllGroups then + for groupName, value in ipairs(PatrolUnit.AllGroups) do + redAlarmEvent.alarmOffGroups[groupName] = true + end + end + end + +end \ No newline at end of file diff --git a/ideas.md b/ideas.md index cef4aa8..91c0711 100644 --- a/ideas.md +++ b/ideas.md @@ -2,6 +2,7 @@ - 激光干扰车 - 检查站馕言文配音 - 接近结束前, 红方会用火箭弹轰炸前线直升机起降点 +- 反直升机地雷 # 蓝方 ## Eagle diff --git a/imgs/Brief/Biref.psd b/imgs/Brief/Biref.psd new file mode 100644 index 0000000..7a535d6 Binary files /dev/null and b/imgs/Brief/Biref.psd differ diff --git a/imgs/Brief/DCS 2025-04-03 20-45-13.png b/imgs/Brief/DCS 2025-04-03 20-45-13.png new file mode 100644 index 0000000..32d410b Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-45-13.png differ diff --git a/imgs/Brief/DCS 2025-04-03 20-45-40.png b/imgs/Brief/DCS 2025-04-03 20-45-40.png new file mode 100644 index 0000000..57e5ae0 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-45-40.png differ diff --git a/imgs/Brief/DCS 2025-04-03 20-45-54.png b/imgs/Brief/DCS 2025-04-03 20-45-54.png new file mode 100644 index 0000000..254f719 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-45-54.png differ diff --git a/imgs/Brief/DCS 2025-04-03 20-46-20.png b/imgs/Brief/DCS 2025-04-03 20-46-20.png new file mode 100644 index 0000000..c2fbc4a Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-46-20.png differ diff --git a/imgs/Brief/DCS 2025-04-03 20-46-43.png b/imgs/Brief/DCS 2025-04-03 20-46-43.png new file mode 100644 index 0000000..013afd1 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-46-43.png differ diff --git a/imgs/Brief/DCS 2025-04-03 20-47-33.png b/imgs/Brief/DCS 2025-04-03 20-47-33.png new file mode 100644 index 0000000..9829e95 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-47-33.png differ diff --git a/imgs/Brief/DCS 2025-04-03 20-48-02.png b/imgs/Brief/DCS 2025-04-03 20-48-02.png new file mode 100644 index 0000000..88be1b8 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-48-02.png differ diff --git a/imgs/Brief/DCS 2025-04-03 20-48-35.png b/imgs/Brief/DCS 2025-04-03 20-48-35.png new file mode 100644 index 0000000..8226b60 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-03 20-48-35.png differ diff --git a/imgs/Brief/DCS 2025-04-04 11-39-42.png b/imgs/Brief/DCS 2025-04-04 11-39-42.png new file mode 100644 index 0000000..5dc0ce2 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-04 11-39-42.png differ diff --git a/imgs/Brief/DCS 2025-04-04 11-39-46.png b/imgs/Brief/DCS 2025-04-04 11-39-46.png new file mode 100644 index 0000000..3bf0100 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-04 11-39-46.png differ diff --git a/imgs/Brief/DCS 2025-04-04 11-39-55.png b/imgs/Brief/DCS 2025-04-04 11-39-55.png new file mode 100644 index 0000000..a35b8e5 Binary files /dev/null and b/imgs/Brief/DCS 2025-04-04 11-39-55.png differ diff --git a/imgs/Brief/DCS 2025-04-04 14-43-20.png b/imgs/Brief/DCS 2025-04-04 14-43-20.png new file mode 100644 index 0000000..dd697ed Binary files /dev/null and b/imgs/Brief/DCS 2025-04-04 14-43-20.png differ diff --git a/imgs/Brief/SCUD.png b/imgs/Brief/SCUD.png new file mode 100644 index 0000000..e16c8d0 Binary files /dev/null and b/imgs/Brief/SCUD.png differ diff --git a/imgs/Brief/map all plane.png b/imgs/Brief/map all plane.png new file mode 100644 index 0000000..8cfd431 Binary files /dev/null and b/imgs/Brief/map all plane.png differ diff --git a/imgs/Brief/map detail.png b/imgs/Brief/map detail.png new file mode 100644 index 0000000..1382f41 Binary files /dev/null and b/imgs/Brief/map detail.png differ diff --git a/imgs/Brief/map heli all.png b/imgs/Brief/map heli all.png new file mode 100644 index 0000000..3251071 Binary files /dev/null and b/imgs/Brief/map heli all.png differ