From 06f38347bc659e83de24a964e1f16f33a0e6ccaa Mon Sep 17 00:00:00 2001 From: bob7hebuilder Date: Mon, 31 Aug 2015 13:10:37 +1000 Subject: [PATCH 1/3] Pickup Zones Modified Added option to activate / deactivate zone during mission Added coalition to zones so the other team can't pick up from your zone. UNTESTED - Written while at work --- CTLD.lua | 141 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 111 insertions(+), 30 deletions(-) diff --git a/CTLD.lua b/CTLD.lua index 3e634ca..0a73cb3 100644 --- a/CTLD.lua +++ b/CTLD.lua @@ -21,6 +21,10 @@ - Report status via F10 Radio - Report status every 5 minutes or when targets first appear - Report vague status like 5 armoured vehicles, soldiers and support trucks ?? + + Steggles TODO: + - Test logic on smoke refresh + - Test logic on inPickupZone coalition and active check ]] @@ -103,18 +107,18 @@ ctld.JTAC_lock = "all" -- "vehicle" OR "troop" OR "all" forces JTAC to only lock -- You can add number as a third option to limit the number of soldier or vehicle groups that can be loaded from a zone. -- Dropping back a group at a limited zone will add one more to the limit - +--pickupZones = { "name", "smoke", "limit (-1 unlimited)", "active (yes/no), "side (1/2)"} ctld.pickupZones = { - { "pickzone1", "blue" }, - { "pickzone2", "blue" }, - { "pickzone3", "none" }, - { "pickzone4", "none" }, - { "pickzone5", "none" }, - { "pickzone6", "none" }, - { "pickzone7", "none" }, - { "pickzone8", "none" }, - { "pickzone9", "none", 5 }, -- limits pickup zone 9 to 5 groups of soldiers or vehicles - { "pickzone10", "none", 10 }, -- limits pickup zone 10 to 10 groups of soldiers or vehicles + { "pickzone1", "blue", -1, "yes", 1 }, --unlimited pickups, active on mission start, red side only + { "pickzone2", "blue", -1, "yes", 2 }, --unlimited pickups, active on mission start, blue side only + { "pickzone3", "none", -1, "no", 1 }, --unlimited pickups, not active on mission start, red side only + { "pickzone4", "none", -1, "yes", 1 }, + { "pickzone5", "none", -1, "yes", 1 }, + { "pickzone6", "none", -1, "yes", 1 }, + { "pickzone7", "none", -1, "yes", 1 }, + { "pickzone8", "none", -1, "yes", 1 }, + { "pickzone9", "none", 5, "yes", 1 }, -- limits pickup zone 9 to 5 groups of soldiers or vehicles, only red can pick up + { "pickzone10", "none", 10, "yes", 2 }, -- limits pickup zone 10 to 10 groups of soldiers or vehicles, only blue can pick up } ctld.dropOffZones = { @@ -3074,7 +3078,10 @@ function ctld.inPickupZone(_heli) local _dist = ctld.getDistance(_heliPoint, _triggerZone.point) if _dist <= _triggerZone.radius then - return {inZone = true,limit = _zoneDetails[3],index=_i} + local _heliCoalition = _heli:getCoalition() + if _zoneDetails[4] == 1 and _zoneDetails[5] == _heliCoalition then + return {inZone = true,limit = _zoneDetails[3],index=_i} + end end end end @@ -3180,7 +3187,7 @@ function ctld.refreshSmoke() local _triggerZone = trigger.misc.getZone(_zoneDetails[1]) - if _triggerZone ~= nil and _zoneDetails[2] >= 0 then + if _triggerZone ~= nil and _zoneDetails[2] >= 0 and _zoneDetails[4] == 1 then -- Trigger smoke markers @@ -4261,6 +4268,74 @@ function ctld.getPositionString(_unit) end +------------------------Steggles Functions----------------------- +function ctld.activatePickupZone(_zoneName) + local _triggerZone = trigger.misc.getZone(_zoneName) -- trigger to use as reference position + + if _triggerZone == nil then + trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zoneName, 10) + return + end + + for _, _zoneDetails in pairs(ctld.pickupZones) do + + if _triggerZone = trigger.misc.getZone(_zoneDetails[1]) then + + --smoke could get messy if designer keeps calling this on an active zone, check its not active first + if _zoneDetails[4] == 1 then + trigger.action.outText("CTLD.lua ERROR: Pickup Zone already active: " .. _zoneName, 10) + return + end + + _zoneDetails[4] = 1 --activate zone + + if ctld.disableAllSmoke == true then --smoke disabled + return + end + + if _zoneDetails[2] >= 0 then + + -- Trigger smoke marker + -- This will cause an overlapping smoke marker on next refreshsmoke call + -- but will only happen once + local _pos2 = { x = _triggerZone.point.x, y = _triggerZone.point.z } + local _alt = land.getHeight(_pos2) + local _pos3 = { x = _pos2.x, y = _alt, z = _pos2.y } + + trigger.action.smoke(_pos3, _zoneDetails[2]) + end + + end + + end +end + +function ctld.deactivatePickupZone(_zoneName) + + local _triggerZone = trigger.misc.getZone(_zoneName) -- trigger to use as reference position + + if _triggerZone == nil then + trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zoneName, 10) + return + end + + for _, _zoneDetails in pairs(ctld.pickupZones) do + + if _triggerZone = trigger.misc.getZone(_zoneDetails[1]) then + + if _zoneDetails[4] == 0 then --this really needed?? + trigger.action.outText("CTLD.lua ERROR: Pickup Zone already deactiveated: " .. _zoneName, 10) + return + end + + _zoneDetails[4] = 0 --deactivate zone + + end + + end +end + + -- ***************** SETUP SCRIPT **************** assert(mist ~= nil, "\n\n** HEY MISSION-DESIGNER! **\n\nMiST has not been loaded!\n\nMake sure MiST 3.6 or higher is running\n*before* running this script!\n") @@ -4345,27 +4420,33 @@ for _, _zone in pairs(ctld.pickupZones) do local _zoneName = _zone[1] local _zoneColor = _zone[2] - - if _zoneColor == "green" then - _zone[2] = trigger.smokeColor.Green - elseif _zoneColor == "red" then - _zone[2] = trigger.smokeColor.Red - elseif _zoneColor == "white" then - _zone[2] = trigger.smokeColor.White - elseif _zoneColor == "orange" then - _zone[2] = trigger.smokeColor.Orange - elseif _zoneColor == "blue" then - _zone[2] = trigger.smokeColor.Blue - else - _zone[2] = -1 -- no smoke colour - end + local _zoneActive = _zone[4] + + if _zoneColor == "green" then + _zone[2] = trigger.smokeColor.Green + elseif _zoneColor == "red" then + _zone[2] = trigger.smokeColor.Red + elseif _zoneColor == "white" then + _zone[2] = trigger.smokeColor.White + elseif _zoneColor == "orange" then + _zone[2] = trigger.smokeColor.Orange + elseif _zoneColor == "blue" then + _zone[2] = trigger.smokeColor.Blue + else + _zone[2] = -1 -- no smoke colour + end -- add in counter for troops or units - if _zone[3] == nil then + if _zone[3] == -1 then _zone[3] = 10000; end - - + + -- change active to 1 / 0 + if _zoneActive == "yes" then + _zone[4] = 1 + else + _zone[4] = 0 + end end From 1911e6e524633b255ab16f51e6937decbe7412c1 Mon Sep 17 00:00:00 2001 From: bob7hebuilder Date: Mon, 31 Aug 2015 20:56:07 +1000 Subject: [PATCH 2/3] Fixed logic in activate / deactivate pickup zone Changed logic in activate / deactivate pickup zone functions to something that **should** work, unlike before. STILL UNTESTED --- CTLD.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CTLD.lua b/CTLD.lua index 0a73cb3..73c94ed 100644 --- a/CTLD.lua +++ b/CTLD.lua @@ -4279,7 +4279,7 @@ function ctld.activatePickupZone(_zoneName) for _, _zoneDetails in pairs(ctld.pickupZones) do - if _triggerZone = trigger.misc.getZone(_zoneDetails[1]) then + if _zoneName == _zoneDetails[1] then --smoke could get messy if designer keeps calling this on an active zone, check its not active first if _zoneDetails[4] == 1 then @@ -4321,7 +4321,7 @@ function ctld.deactivatePickupZone(_zoneName) for _, _zoneDetails in pairs(ctld.pickupZones) do - if _triggerZone = trigger.misc.getZone(_zoneDetails[1]) then + if _zoneName == _zoneDetails[1] then if _zoneDetails[4] == 0 then --this really needed?? trigger.action.outText("CTLD.lua ERROR: Pickup Zone already deactiveated: " .. _zoneName, 10) From 1a57f9db7fe2cd3b0bd406394f588433b2230026 Mon Sep 17 00:00:00 2001 From: bob7hebuilder Date: Tue, 1 Sep 2015 14:38:16 +1000 Subject: [PATCH 3/3] Tested and Cleaned up code --- CTLD.lua | 156 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 82 insertions(+), 74 deletions(-) diff --git a/CTLD.lua b/CTLD.lua index 73c94ed..7a50efb 100644 --- a/CTLD.lua +++ b/CTLD.lua @@ -22,9 +22,6 @@ - Report status every 5 minutes or when targets first appear - Report vague status like 5 armoured vehicles, soldiers and support trucks ?? - Steggles TODO: - - Test logic on smoke refresh - - Test logic on inPickupZone coalition and active check ]] @@ -107,16 +104,16 @@ ctld.JTAC_lock = "all" -- "vehicle" OR "troop" OR "all" forces JTAC to only lock -- You can add number as a third option to limit the number of soldier or vehicle groups that can be loaded from a zone. -- Dropping back a group at a limited zone will add one more to the limit ---pickupZones = { "name", "smoke", "limit (-1 unlimited)", "active (yes/no), "side (1/2)"} +--pickupZones = { "name", "smoke color", "limit (-1 unlimited)", "active (yes/no)", "side (1 = red / 2 = blue)"} ctld.pickupZones = { - { "pickzone1", "blue", -1, "yes", 1 }, --unlimited pickups, active on mission start, red side only + { "pickzone1", "red", -1, "yes", 1 }, --unlimited pickups, active on mission start, red side only { "pickzone2", "blue", -1, "yes", 2 }, --unlimited pickups, active on mission start, blue side only { "pickzone3", "none", -1, "no", 1 }, --unlimited pickups, not active on mission start, red side only { "pickzone4", "none", -1, "yes", 1 }, { "pickzone5", "none", -1, "yes", 1 }, { "pickzone6", "none", -1, "yes", 1 }, { "pickzone7", "none", -1, "yes", 1 }, - { "pickzone8", "none", -1, "yes", 1 }, + { "pickzone7", "none", -1, "yes", 2 }, -- Listing pickzone7 a second time with other team makes it available to both sides. { "pickzone9", "none", 5, "yes", 1 }, -- limits pickup zone 9 to 5 groups of soldiers or vehicles, only red can pick up { "pickzone10", "none", 10, "yes", 2 }, -- limits pickup zone 10 to 10 groups of soldiers or vehicles, only blue can pick up } @@ -518,6 +515,85 @@ function ctld.createRadioBeaconAtZone(_zone, _coalition, _batteryLife, _name) end end + +------------------------Steggles Functions----------------------- +-- Activates a pickup zone +-- Activates a pickup zone when called from a trigger +-- EG: ctld.activatePickupZone("pickzone3") +-- This is enable pickzone3 to be used as a pickup zone for the team set +function ctld.activatePickupZone(_zoneName) + local _triggerZone = trigger.misc.getZone(_zoneName) -- trigger to use as reference position + + if _triggerZone == nil then + trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zoneName, 10) + return + end + + for _, _zoneDetails in pairs(ctld.pickupZones) do + + if _zoneName == _zoneDetails[1] then + + --smoke could get messy if designer keeps calling this on an active zone, check its not active first + if _zoneDetails[4] == 1 then + trigger.action.outText("CTLD.lua ERROR: Pickup Zone already active: " .. _zoneName, 10) + return + end + + _zoneDetails[4] = 1 --activate zone + + if ctld.disableAllSmoke == true then --smoke disabled + return + end + + if _zoneDetails[2] >= 0 then + + -- Trigger smoke marker + -- This will cause an overlapping smoke marker on next refreshsmoke call + -- but will only happen once + local _pos2 = { x = _triggerZone.point.x, y = _triggerZone.point.z } + local _alt = land.getHeight(_pos2) + local _pos3 = { x = _pos2.x, y = _alt, z = _pos2.y } + + trigger.action.smoke(_pos3, _zoneDetails[2]) + end + + end + + end +end + + +-- Deactivates a pickup zone +-- Deactivates a pickup zone when called from a trigger +-- EG: ctld.deactivatePickupZone("pickzone3") +-- This is disables pickzone3 and can no longer be used to as a pickup zone +-- These functions can be called by triggers, like if a set of buildings is used, you can trigger the zone to be 'not operational' +-- once they are destroyed +function ctld.deactivatePickupZone(_zoneName) + + local _triggerZone = trigger.misc.getZone(_zoneName) -- trigger to use as reference position + + if _triggerZone == nil then + trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zoneName, 10) + return + end + + for _, _zoneDetails in pairs(ctld.pickupZones) do + + if _zoneName == _zoneDetails[1] then + + if _zoneDetails[4] == 0 then --this really needed?? + trigger.action.outText("CTLD.lua ERROR: Pickup Zone already deactiveated: " .. _zoneName, 10) + return + end + + _zoneDetails[4] = 0 --deactivate zone + + end + + end +end + -- *************************************************************** -- **************** BE CAREFUL BELOW HERE ************************ -- *************************************************************** @@ -4268,74 +4344,6 @@ function ctld.getPositionString(_unit) end -------------------------Steggles Functions----------------------- -function ctld.activatePickupZone(_zoneName) - local _triggerZone = trigger.misc.getZone(_zoneName) -- trigger to use as reference position - - if _triggerZone == nil then - trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zoneName, 10) - return - end - - for _, _zoneDetails in pairs(ctld.pickupZones) do - - if _zoneName == _zoneDetails[1] then - - --smoke could get messy if designer keeps calling this on an active zone, check its not active first - if _zoneDetails[4] == 1 then - trigger.action.outText("CTLD.lua ERROR: Pickup Zone already active: " .. _zoneName, 10) - return - end - - _zoneDetails[4] = 1 --activate zone - - if ctld.disableAllSmoke == true then --smoke disabled - return - end - - if _zoneDetails[2] >= 0 then - - -- Trigger smoke marker - -- This will cause an overlapping smoke marker on next refreshsmoke call - -- but will only happen once - local _pos2 = { x = _triggerZone.point.x, y = _triggerZone.point.z } - local _alt = land.getHeight(_pos2) - local _pos3 = { x = _pos2.x, y = _alt, z = _pos2.y } - - trigger.action.smoke(_pos3, _zoneDetails[2]) - end - - end - - end -end - -function ctld.deactivatePickupZone(_zoneName) - - local _triggerZone = trigger.misc.getZone(_zoneName) -- trigger to use as reference position - - if _triggerZone == nil then - trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zoneName, 10) - return - end - - for _, _zoneDetails in pairs(ctld.pickupZones) do - - if _zoneName == _zoneDetails[1] then - - if _zoneDetails[4] == 0 then --this really needed?? - trigger.action.outText("CTLD.lua ERROR: Pickup Zone already deactiveated: " .. _zoneName, 10) - return - end - - _zoneDetails[4] = 0 --deactivate zone - - end - - end -end - - -- ***************** SETUP SCRIPT **************** assert(mist ~= nil, "\n\n** HEY MISSION-DESIGNER! **\n\nMiST has not been loaded!\n\nMake sure MiST 3.6 or higher is running\n*before* running this script!\n")