mirror of
https://github.com/spencershepard/RotorOps.git
synced 2025-11-10 15:45:30 +00:00
..
This commit is contained in:
parent
49c97bc197
commit
7dd12d09fc
164
RotaryOps.lua
164
RotaryOps.lua
@ -11,6 +11,10 @@ local function dispMsg(text)
|
||||
return text
|
||||
end
|
||||
|
||||
local function tableHasKey(table,key)
|
||||
return table[key] ~= nil
|
||||
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))
|
||||
@ -105,13 +109,13 @@ function RotaryOps.chargeEnemy(vars)
|
||||
end
|
||||
world.searchObjects(Object.Category.UNIT, volS, ifFound)
|
||||
mist.goRoute(grp, path)
|
||||
local id = timer.scheduleFunction(RotaryOps.chargeEnemy, vars, timer.getTime() + 60)
|
||||
local id = timer.scheduleFunction(RotaryOps.chargeEnemy, vars, timer.getTime() + math.random(50,70))
|
||||
|
||||
end
|
||||
|
||||
|
||||
function RotaryOps.patrolRadius(vars)
|
||||
--trigger.action.outText("patrol radius: "..mist.utils.tableShow(vars), 5)
|
||||
trigger.action.outText("patrol radius: "..mist.utils.tableShow(vars), 5)
|
||||
local grp = vars.grp
|
||||
local search_radius = vars.radius or 100
|
||||
local first_valid_unit
|
||||
@ -173,9 +177,163 @@ function RotaryOps.patrolRadius(vars)
|
||||
--trigger.action.outText("new waypoints created: "..(#path - 1), 5)
|
||||
mist.goRoute(grp, path)
|
||||
--local timing = mist.getPathLength(path) / 5
|
||||
local id = timer.scheduleFunction(RotaryOps.patrolRadius, vars, timer.getTime() + 60)
|
||||
local id = timer.scheduleFunction(RotaryOps.patrolRadius, vars, timer.getTime() + math.random(50,70))
|
||||
|
||||
end
|
||||
|
||||
|
||||
function RotaryOps.knowEnemy(vars)
|
||||
--trigger.action.outText("charge enemies: "..mist.utils.tableShow(vars), 5)
|
||||
local grp = vars.grp
|
||||
local search_radius = vars.radius or 5000
|
||||
----
|
||||
local first_valid_unit
|
||||
if grp:isExist() ~= true then return end
|
||||
for index, unit in pairs(grp:getUnits())
|
||||
do
|
||||
if unit:isExist() == true then
|
||||
first_valid_unit = unit
|
||||
break
|
||||
else --trigger.action.outText("a unit no longer exists", 15)
|
||||
end
|
||||
end
|
||||
----
|
||||
|
||||
if first_valid_unit == nil then return end
|
||||
local start_point = first_valid_unit:getPoint()
|
||||
if not vars.spawn_point then vars.spawn_point = start_point end
|
||||
|
||||
local enemy_coal
|
||||
if grp:getCoalition() == 1 then enemy_coal = 2 end
|
||||
if grp:getCoalition() == 2 then enemy_coal = 1 end
|
||||
|
||||
--local sphere = trigger.misc.getZone('town')
|
||||
local volS = {
|
||||
id = world.VolumeType.SPHERE,
|
||||
params = {
|
||||
point = grp:getUnit(1):getPoint(), --check if exists, maybe itterate through grp
|
||||
radius = search_radius
|
||||
}
|
||||
}
|
||||
local enemy_unit
|
||||
local path = {}
|
||||
local ifFound = function(foundItem, val)
|
||||
--trigger.action.outText("found item: "..foundItem:getTypeName(), 5)
|
||||
if foundItem:getCoalition() == enemy_coal then
|
||||
enemy_unit = foundItem
|
||||
trigger.action.outText("found enemy! "..foundItem:getTypeName(), 5)
|
||||
|
||||
path[1] = mist.ground.buildWP(start_point, '', 5)
|
||||
path[2] = mist.ground.buildWP(enemy_unit:getPoint(), '', 5)
|
||||
--path[3] = mist.ground.buildWP(vars.spawn_point, '', 5)
|
||||
grp:getUnit(1):getController():knowTarget(enemy_unit, true, true)
|
||||
|
||||
|
||||
else
|
||||
|
||||
--trigger.action.outText("object found is not enemy inf in "..search_radius, 5)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
--default path if no units found
|
||||
if false then
|
||||
trigger.action.outText("group going back to origin", 5)
|
||||
path[1] = mist.ground.buildWP(start_point, '', 5)
|
||||
path[2] = mist.ground.buildWP(vars.spawn_point, '', 5)
|
||||
|
||||
end
|
||||
world.searchObjects(Object.Category.UNIT, volS, ifFound)
|
||||
--mist.goRoute(grp, path)
|
||||
local id = timer.scheduleFunction(RotaryOps.knowEnemy, vars, timer.getTime() + 15)
|
||||
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------
|
||||
|
||||
|
||||
|
||||
RotaryOps.zones = {}
|
||||
RotaryOps.active_zone = 'ALPHA'
|
||||
|
||||
function RotaryOps.sortOutInfantry(mixed_units)
|
||||
local _infantry = {}
|
||||
local _not_infantry = {}
|
||||
for index, unit in pairs(mixed_units)
|
||||
do
|
||||
if unit:hasAttribute("Infantry") then
|
||||
_infantry[#_infantry + 1] = unit
|
||||
else _not_infantry[#_not_infantry + 1] = unit
|
||||
end
|
||||
end
|
||||
return {infantry = _infantry, not_infantry = _not_infantry}
|
||||
end
|
||||
|
||||
function RotaryOps.assessUnitsInZone(var)
|
||||
--consider adding other unit types
|
||||
local red_ground_units = mist.getUnitsInZones(mist.makeUnitTable({'[red][vehicle]'}), {RotaryOps.active_zone}) --consider adding other unit types
|
||||
local red_infantry = RotaryOps.sortOutInfantry(red_ground_units).infantry
|
||||
local red_vehicles = RotaryOps.sortOutInfantry(red_ground_units).not_infantry
|
||||
local blue_ground_units = mist.getUnitsInZones(mist.makeUnitTable({'[blue][vehicle]'}), {RotaryOps.active_zone}) --consider adding other unit types
|
||||
local blue_infantry = RotaryOps.sortOutInfantry(blue_ground_units).infantry
|
||||
local blue_vehicles = RotaryOps.sortOutInfantry(blue_ground_units).not_infantry
|
||||
|
||||
trigger.action.outText("["..RotaryOps.active_zone .. "] RED: " ..#red_infantry.. " infantry, " .. #red_vehicles .. " vehicles. BLUE: "..#blue_infantry.. " infantry, " .. #blue_vehicles.." vehicles.", 5, true)
|
||||
local id = timer.scheduleFunction(RotaryOps.assessUnitsInZone, 1, timer.getTime() + 5)
|
||||
end
|
||||
local id = timer.scheduleFunction(RotaryOps.assessUnitsInZone, 1, timer.getTime() + 5)
|
||||
|
||||
|
||||
function RotaryOps.drawZones(zones) --should be drawZones and itterate through all zones, getting the active zone, and incrementing id
|
||||
local previous_point
|
||||
for index, zone in pairs(zones)
|
||||
do
|
||||
local point = trigger.misc.getZone(zone.outter_zone_name).point
|
||||
local radius = trigger.misc.getZone(zone.outter_zone_name).radius
|
||||
local coalition = -1
|
||||
local id = index --this must be UNIQUE!
|
||||
local color = {1, 1, 1, 0.5}
|
||||
local fill_color = {1, 1, 1, 0.1}
|
||||
local text_fill_color = {0, 0, 0, 0}
|
||||
local line_type = 5 --1 Solid 2 Dashed 3 Dotted 4 Dot Dash 5 Long Dash 6 Two Dash
|
||||
local font_size = 20
|
||||
local read_only = false
|
||||
local text = zone.outter_zone_name
|
||||
if zone.outter_zone_name == RotaryOps.active_zone then
|
||||
color = {1, 1, 1, 0.5}
|
||||
fill_color = {1, 0, 1, 0.1}
|
||||
end
|
||||
if previous_point ~= nill then
|
||||
trigger.action.lineToAll(coalition, id + 200, point, previous_point, color, line_type)
|
||||
end
|
||||
previous_point = point
|
||||
trigger.action.outText("drawing map circle", 5)
|
||||
trigger.action.circleToAll(coalition, id, point, radius, color, fill_color, line_type)
|
||||
trigger.action.textToAll(coalition, id + 100, point, color, text_fill_color, font_size, read_only, text)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function RotaryOps.addZone(_outter_zone_name, _vars, group_id) --todo: implement zone group ids
|
||||
group_id = group_id or 1
|
||||
table.insert(RotaryOps.zones, {outter_zone_name = _outter_zone_name, vars = _vars})
|
||||
RotaryOps.drawZones(RotaryOps.zones)
|
||||
ctld.dropOffZones[#ctld.dropOffZones + 1] = { _outter_zone_name, "green", 0 }
|
||||
--trigger.action.outText("zones: ".. mist.utils.tableShow(RotaryOps.zones), 5)
|
||||
end
|
||||
|
||||
--[[
|
||||
vars = {
|
||||
inner_zone = '',
|
||||
infantry_spawn = 10,
|
||||
infantry_respawn = 50,
|
||||
infantry_spawn_zone = ''
|
||||
defender_coal = 'red'
|
||||
}
|
||||
]]
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
assert(loadfile("C:\\Users\\spenc\\OneDrive\\Documents\\Eclipe_LDT\\dcs splash damage\\src\\mist.lua"))()
|
||||
--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\\mist_4_4_90.lua"))()
|
||||
--assert(loadfile("C:\\Users\\spenc\\OneDrive\\Documents\\Eclipe_LDT\\Rotary Ops\\src\\RotaryOps.lua"))()
|
||||
assert(loadfile("C:\\Users\\spenc\\OneDrive\\Documents\\Eclipe_LDT\\Rotary Ops\\src\\CTLD.lua"))()
|
||||
assert(loadfile("C:\\Users\\spenc\\OneDrive\\Documents\\Eclipe_LDT\\Rotary Ops\\src\\RotaryOps.lua"))()
|
||||
--assert(require("RotaryOps"))
|
||||
7347
mist_4_4_90.lua
Normal file
7347
mist_4_4_90.lua
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user