From 88d4557c12ee0e4d4e0c5d10eecd742b962c0f15 Mon Sep 17 00:00:00 2001 From: spencer-ki <56365667+spencer-ki@users.noreply.github.com> Date: Sat, 25 Dec 2021 09:02:12 -0800 Subject: [PATCH] Initial commit --- .gitattributes | 2 ++ RotaryOps.lua | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ ScriptLoader.lua | 3 ++ 3 files changed, 88 insertions(+) create mode 100644 .gitattributes create mode 100644 RotaryOps.lua create mode 100644 ScriptLoader.lua diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/RotaryOps.lua b/RotaryOps.lua new file mode 100644 index 0000000..c83ed5b --- /dev/null +++ b/RotaryOps.lua @@ -0,0 +1,83 @@ +RotaryOps = {} + +trigger.action.outText("ROTARY OPS STARTED", 5) + +local function tableHasKey(table,key) + return table[key] ~= nil +end + +local function dispMsg(text) + trigger.action.outText(text, 5) + return text +end + +local function getObjectVolume(obj) + local length = (obj:getDesc().box.max.x + math.abs(obj:getDesc().box.min.x)) + local height = (obj:getDesc().box.max.y + math.abs(obj:getDesc().box.min.y)) + local depth = (obj:getDesc().box.max.z + math.abs(obj:getDesc().box.min.z)) + return length * height * depth +end + +function RotaryOps.spawn(grp) + local vars = {} + vars.gpName = 'RED_Infantry' + vars.action = 'clone' + vars.point = grp:getUnit(1):getPoint() + vars.radius = 5 + vars.disperse = 'disp' + vars.maxDisp = 5 + local new_grp_table = mist.teleportToPoint(vars) + + if new_grp_table then + local new_grp = Group.getByName(new_grp_table.name) + trigger.action.outText("new group: "..mist.utils.tableShow(new_grp_table), 5) + if 1 then + trigger.action.outText("new group: "..mist.utils.tableShow(new_grp_table), 5) + local id = timer.scheduleFunction(RotaryOps.seekCover, new_grp, timer.getTime() + 1) + end + else trigger.action.outText("failed to spawn? ", 5) + end +end + +function RotaryOps.seekCover(grp) + trigger.action.outText("seek cover: "..mist.utils.tableShow(grp), 5) + local object_vol_thresh = 0 + local foundUnits = {} + --local sphere = trigger.misc.getZone('town') + local volS = { + id = world.VolumeType.SPHERE, + params = { + point = grp:getUnit(1):getPoint(), + radius = 400 + } + } + + local ifFound = function(foundItem, val) + trigger.action.outText("found item: "..foundItem:getTypeName(), 5) + if foundItem:hasAttribute("Infantry") ~= true then --disregard infantry...we only want objects that might provide cover + if getObjectVolume(foundItem) > object_vol_thresh then + foundUnits[#foundUnits + 1] = foundItem + --trigger.action.outText("valid cover item: "..foundItem:getTypeName(), 5) + end + else trigger.action.outText("object not the right type", 5) + end + return true + end + + --world.searchObjects(Object.Category.UNIT, volS, ifFound) + --world.searchObjects(Object.Category.STATIC, volS, ifFound) + world.searchObjects(Object.Category.SCENERY, volS, ifFound) + --world.searchObjects(Object.Category.BASE, volS, ifFound) + local path = {} + path[1] = mist.ground.buildWP(grp:getUnit(1):getPoint(), '', 5) + for i = 1, #foundUnits , 1 + do + local rand_index = math.random(1,#foundUnits) + path[i + 1] = mist.ground.buildWP(foundUnits[rand_index]:getPoint(), '', 5) + trigger.action.outText("waypoint to: "..foundUnits[i]:getTypeName(), 5) + end + mist.goRoute(grp, path) + +end + + diff --git a/ScriptLoader.lua b/ScriptLoader.lua new file mode 100644 index 0000000..c952523 --- /dev/null +++ b/ScriptLoader.lua @@ -0,0 +1,3 @@ +assert(loadfile("C:\\Users\\spenc\\OneDrive\\Documents\\Eclipe_LDT\\dcs splash damage\\src\\mist.lua"))() +assert(loadfile("C:\\Users\\spenc\\OneDrive\\Documents\\Eclipe_LDT\\Rotary Ops\\src\\RotaryOps.lua"))() +--assert(require("RotaryOps")) \ No newline at end of file