Tested and Cleaned up code

This commit is contained in:
bob7hebuilder 2015-09-01 14:38:16 +10:00
parent 1911e6e524
commit 1a57f9db7f

156
CTLD.lua
View File

@ -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")