Version 0.995

Watchflags
This commit is contained in:
Christian Franz 2022-03-24 17:42:24 +01:00
parent 95e809b85c
commit 6d1e992037
22 changed files with 474 additions and 73 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
rndFlags = {}
rndFlags.version = "1.1.0"
rndFlags.version = "1.2.0"
rndFlags.verbose = false
rndFlags.requiredLibs = {
"dcsCommon", -- always
@ -22,6 +22,7 @@ rndFlags.requiredLibs = {
getFlagValue in update
some code clean-up
rndMethod synonym
1.2.0 - Watchflag integration
--]]
rndFlags.rndGen = {}
@ -104,6 +105,14 @@ function rndFlags.createRNDWithZone(theZone)
theZone.remove = cfxZones.getBoolFromZoneProperty(theZone, "remove", false)
-- watchflag:
-- triggerMethod
theZone.rndTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "rndTriggerMethod") then
theZone.rndTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "rndTriggerMethod", "change")
end
-- trigger flag
if cfxZones.hasProperty(theZone, "f?") then
theZone.triggerFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none")
@ -117,6 +126,7 @@ function rndFlags.createRNDWithZone(theZone)
theZone.triggerFlag = cfxZones.getStringFromZoneProperty(theZone, "rndPoll?", "none")
end
if theZone.triggerFlag then
theZone.lastTriggerValue = cfxZones.getFlagValue(theZone.triggerFlag, theZone) --trigger.misc.getUserFlag(theZone.triggerFlag) -- save last value
end
@ -223,6 +233,13 @@ function rndFlags.update()
timer.scheduleFunction(rndFlags.update, {}, timer.getTime() + 1)
for idx, aZone in pairs(rndFlags.rndGen) do
if cfxZones.testZoneFlag(aZone, aZone.triggerFlag, aZone.rndTriggerMethod, "lastTriggerValue") then
if rndFlags.verbose then
trigger.action.outText("+++RND: triggering " .. aZone.name, 30)
end
rndFlags.fire(aZone)
end
--[[-- old code pre watchflag
if aZone.triggerFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerFlag)
if currTriggerVal ~= aZone.lastTriggerValue
@ -235,6 +252,7 @@ function rndFlags.update()
end
end
--]]--
end
end

View File

@ -1,7 +1,12 @@
cfxArtilleryDemon = {}
cfxArtilleryDemon.version = "1.0.2"
cfxArtilleryDemon.version = "1.0.3"
-- based on cfx stage demon v 1.0.2
--[[--
Version History
1.0.2 - taken from stageDemon
1.0.3 - corrected 'messageOut' bug
--]]--
cfxArtilleryDemon.messageToAll = true -- set to false if messages should be sent only to the group that set the mark
cfxArtilleryDemon.messageTime = 30 -- how long a message stays on the sceeen
@ -181,7 +186,7 @@ function cfxArtilleryDemon:onEvent(theEvent)
local theGroup = cfxArtilleryDemon.retrieveGroupFromEvent(theEvent)
if not theGroup then
args.toAll = true
trigger.action.messageOut("*** WARNING: cfxArtilleryDemon can't find group for command", 30)
trigger.action.outText("*** WARNING: cfxArtilleryDemon can't find group for command", 30)
else
args.group = theGroup
end

View File

@ -1,5 +1,5 @@
cfxArtilleryZones = {}
cfxArtilleryZones.version = "2.0.2"
cfxArtilleryZones.version = "2.2.0"
cfxArtilleryZones.requiredLibs = {
"dcsCommon", -- always
"cfxZones", -- Zones, of course
@ -28,6 +28,7 @@ cfxArtilleryZones.verbose = false
2.0.2 - boom?, arty? synonyms
2.1.0 - DML Flag Support
- code cleanup
2.2.0 - DML Watchflag integration
Artillery Target Zones *** EXTENDS ZONES ***
Target Zones for artillery. Can determine which zones are in range and visible and then handle artillery barrage to this zone
@ -123,6 +124,15 @@ function cfxArtilleryZones.processArtilleryZone(aZone)
aZone.transitionTime = cfxZones.getNumberFromZoneProperty(aZone, "transitionTime", 20) -- average time of travel for projectiles
aZone.addMark = cfxZones.getBoolFromZoneProperty(aZone, "addMark", true) -- note: defaults to true
aZone.shellVariance = cfxZones.getNumberFromZoneProperty(aZone, "shellVariance", 0.2) -- strength of explosion can vary by +/- this amount
-- watchflag:
-- triggerMethod
aZone.artyTriggerMethod = cfxZones.getStringFromZoneProperty(aZone, "artyTriggerMethod", "change")
if cfxZones.hasProperty(aZone, "triggerMethod") then
aZone.artyTriggerMethod = cfxZones.getStringFromZoneProperty(aZone, "triggerMethod", "change")
end
if cfxZones.hasProperty(aZone, "f?") then
aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "f?", "none")
end
@ -134,6 +144,10 @@ function cfxArtilleryZones.processArtilleryZone(aZone)
if cfxZones.hasProperty(aZone, "artillery?") then
aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "artillery?", "none")
end
if cfxZones.hasProperty(aZone, "in?") then
aZone.artyTriggerFlag = cfxZones.getStringFromZoneProperty(aZone, "in?", "none")
end
if aZone.artyTriggerFlag then
aZone.lastTriggerValue = trigger.misc.getUserFlag(aZone.artyTriggerFlag) -- save last value
end
@ -357,6 +371,17 @@ function cfxArtilleryZones.update()
-- iterate all zones to see if a trigger has changed
for idx, aZone in pairs(cfxArtilleryZones.artilleryZones) do
if cfxZones.testZoneFlag(aZone, aZone.artyTriggerFlag, aZone.artyTriggerMethod, "lastTriggerValue") then
-- a triggered release!
cfxArtilleryZones.doFireAt(aZone) -- all from zone vars!
if cfxArtilleryZones.verbose then
local addInfo = " with var = " .. aZone.baseAccuracy .. " pB=" .. aZone.shellStrength
trigger.action.outText("Artillery T-Firing on ".. aZone.name .. addInfo, 30)
end
end
-- old code
if aZone.artyTriggerFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.artyTriggerFlag, aZone) -- trigger.misc.getUserFlag(aZone.artyTriggerFlag)
if currTriggerVal ~= aZone.lastTriggerValue

View File

@ -1,5 +1,5 @@
cfxCargoReceiver = {}
cfxCargoReceiver.version = "1.2.0"
cfxCargoReceiver.version = "1.2.1"
cfxCargoReceiver.ups = 1 -- once a second
cfxCargoReceiver.maxDirectionRange = 500 -- in m. distance when cargo manager starts talking to pilots who are carrying that cargo
cfxCargoReceiver.requiredLibs = {
@ -16,6 +16,7 @@ cfxCargoReceiver.requiredLibs = {
silent attribute
- 1.2.0 method
f!, cargoReceived!
- 1.2.1 cargoMethod
CargoReceiver is a zone enhancement you use to be automatically
@ -71,13 +72,17 @@ function cfxCargoReceiver.processReceiverZone(aZone) -- process attribute and ad
end
-- new method support
aZone.method = cfxZones.getStringFromZoneProperty(aZone, "method", "inc")
aZone.cargoMethod = cfxZones.getStringFromZoneProperty(aZone, "method", "inc")
if cfxZones.hasProperty(aZone, "cargoMethod") then
aZone.cargoMethod = cfxZones.getStringFromZoneProperty(aZone, "cargoMethod", "inc")
end
if cfxZones.hasProperty(aZone, "f!") then
aZone.outReceiveFlag = cfxZones.getNumberFromZoneProperty(aZone, "f!", -1)
aZone.outReceiveFlag = cfxZones.getStringFromZoneProperty(aZone, "f!", "*<none>")
end
if cfxZones.hasProperty(aZone, "cargoReceived!") then
aZone.outReceiveFlag = cfxZones.getNumberFromZoneProperty(aZone, "cargoReceived!", -1)
if cfxZones.hasProperty(aZone, "cargoReceived!") then
aZone.outReceiveFlag = cfxZones.getStringFromZoneProperty(aZone, "cargoReceived!", "*<none>")
end
end
@ -146,7 +151,7 @@ function cfxCargoReceiver.cargoEvent(event, object, name)
end
if aZone.outReceiveFlag then
cfxZones.pollFlag(aZone.outReceiveFlag, aZone.method)
cfxZones.pollFlag(aZone.outReceiveFlag, aZone.cargoMethod)
end
--trigger.action.outText("+++rcv: " .. name .. " delivered in zone " .. aZone.name, 30)

View File

@ -1,5 +1,5 @@
cfxObjectSpawnZones = {}
cfxObjectSpawnZones.version = "1.2.0"
cfxObjectSpawnZones.version = "1.2.1"
cfxObjectSpawnZones.requiredLibs = {
"dcsCommon", -- common is of course needed for everything
-- pretty stupid to check for this since we
@ -7,7 +7,7 @@ cfxObjectSpawnZones.requiredLibs = {
"cfxZones", -- Zones, of course. MUST HAVE RUN
}
cfxObjectSpawnZones.ups = 1
cfxObjectSpawnZones.verbose = false
--
-- Zones that conform with this requirements spawn toops automatically
-- *** DOES NOT EXTEND ZONES ***
@ -25,6 +25,8 @@ cfxObjectSpawnZones.ups = 1
-- 1.1.4 - activate?, pause? attributes
-- 1.1.5 - spawn?, spawnObjects? synonyms
-- 1.2.0 - DML flag upgrade
-- 1.2.1 - config zone
-- - autoLink bug (zone instead of spaneer accessed)
-- respawn currently happens after theSpawns is deleted and cooldown seconds have passed
cfxObjectSpawnZones.allSpawners = {}
@ -191,6 +193,20 @@ function cfxObjectSpawnZones.verifySpawnOwnership(spawner)
end
function cfxObjectSpawnZones.spawnObjectNTimes(aSpawner, theType, n, container)
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: enter spawnNT for " .. theType .. " with spawner " .. aSpawner.name .. " for zone " .. aSpawner.zone.name , 30)
if aSpawner.zone.linkedUnit then
trigger.action.outText("linked to unit " .. aSpawner.zone.linkedUnit:getName(), 30)
if aSpawner.autoLink then
trigger.action.outText("autolink", 30)
else
trigger.action.outText("UNAUTO", 30)
end
else
trigger.action.outText("Unlinked", 30)
end
end
if not aSpawner then return end
if not container then container = {} end
if not n then n = 1 end
@ -220,7 +236,11 @@ function cfxObjectSpawnZones.spawnObjectNTimes(aSpawner, theType, n, container)
-- if linked, relative-link instead to ship
-- NOTE: it is possible that we have to re-calc heading
-- if ship turns relative to original designation position.
if aZone.linkedUnit and aZone.autoLink then
if aZone.linkedUnit and aSpawner.autoLink then
-- remember there is identical code for when more than 1 item!!!!
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: linking <" .. aZone.name .. ">'s objects to unit " .. aZone.linkedUnit:getName(), 30)
end
dcsCommon.linkStaticDataToUnit(
theStaticData,
aZone.linkedUnit,
@ -269,7 +289,7 @@ function cfxObjectSpawnZones.spawnObjectNTimes(aSpawner, theType, n, container)
aSpawner.count = aSpawner.count + 1
dcsCommon.moveStaticDataTo(theStaticData, ox, oy)
if aZone.linkedUnit and aZone.autoLink then
if aZone.linkedUnit and aSpawner.autoLink then
dcsCommon.linkStaticDataToUnit(theStaticData, aZone.linkedUnit, aSpawner.dx + rx, aSpawner.dy + ry, aSpawner.origHeading)
end
@ -430,12 +450,33 @@ function cfxObjectSpawnZones.update()
end
end
function cfxObjectSpawnZones.readConfigZone()
local theZone = cfxZones.getZoneByName("objectSpawnZonesConfig")
if not theZone then
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: NO config zone!", 30)
end
return
end
cfxObjectSpawnZones.verbose = cfxZones.getBoolFromZoneProperty(theZone, "verbose", false)
cfxObjectSpawnZones.ups = cfxZones.getNumberFromZoneProperty(theZone, "ups", 1)
if cfxObjectSpawnZones.verbose then
trigger.action.outText("+++oSpwn: read config", 30)
end
end
function cfxObjectSpawnZones.start()
if not dcsCommon.libCheck("cfx Object Spawn Zones",
cfxObjectSpawnZones.requiredLibs) then
return false
end
-- read config
cfxObjectSpawnZones.readConfigZone()
-- collect all spawn zones
local attrZones = cfxZones.getZonesWithAttributeNamed("objectSpawner")

View File

@ -1,5 +1,5 @@
cfxPlayerScore = {}
cfxPlayerScore.version = "1.3.0"
cfxPlayerScore.version = "1.3.1"
cfxPlayerScore.badSound = "Death BRASS.wav"
cfxPlayerScore.scoreSound = "Quest Snare 3.wav"
cfxPlayerScore.announcer = true
@ -22,6 +22,7 @@ cfxPlayerScore.announcer = true
- scenery objects are now supported. use the
number that is given under OBJECT ID when
using assign as...
1.3.1 - isStaticObject() to better detect buildings after Match 22 patch
--]]--
@ -233,6 +234,13 @@ function cfxPlayerScore.postProcessor(theEvent)
-- don't do anything
end
function cfxPlayerScore.isStaticObject(theUnit)
if not theUnit.getGroup then return true end
local aGroup = theUnit:getGroup()
if aGroup then return false end
return true
end
function cfxPlayerScore.killDetected(theEvent)
-- we are only getting called when and if
-- a kill occured and killer was a player
@ -270,7 +278,9 @@ function cfxPlayerScore.killDetected(theEvent)
-- see what kind of unit (category) we killed
-- and look up base score
if not victim.getGroup then
local isStO = cfxPlayerScore.isStaticObject(victim)
--if not victim.getGroup then
if isStO then
-- static objects have no group
local staticName = victim:getName() -- on statics, this returns
@ -279,7 +289,7 @@ function cfxPlayerScore.killDetected(theEvent)
if staticScore > 0 then
-- this was a named static, return the score - unless our own
if fraternicide then
scoreMod = -2 * scoreMod
scoreMod = -1 * scoreMod -- blue on blue static kills award negative
trigger.action.outSoundForCoalition(killSide, cfxPlayerScore.badSound)
else
trigger.action.outSoundForCoalition(killSide, cfxPlayerScore.scoreSound)
@ -294,7 +304,15 @@ function cfxPlayerScore.killDetected(theEvent)
end
local vicGroup = victim:getGroup()
if not vicGroup then
trigger.action.outText("+++scr: strange stuff:group, outta here", 30)
return
end
local vicCat = vicGroup:getCategory()
if not vicCat then
trigger.action.outText("+++scr: strange stuff:cat, outta here", 30)
return
end
local unitScore = cfxPlayerScore.unit2score(victim)
-- see which weapon was used. gun kills score 2x
@ -308,9 +326,7 @@ function cfxPlayerScore.killDetected(theEvent)
else
local kWeapon = killWeap:getTypeName()
killMeth = " with " .. kWeapon
end
else
end
end
if pk then

View File

@ -6,7 +6,7 @@
--
cfxZones = {}
cfxZones.version = "2.5.8"
cfxZones.version = "2.6.1"
--[[-- VERSION HISTORY
- 2.2.4 - getCoalitionFromZoneProperty
- getStringFromZoneProperty
@ -57,6 +57,10 @@ cfxZones.version = "2.5.8"
- 2.5.7 - pollFlag supports dml flags
- 2.5.8 - flagArrayFromString
- getFlagNumber invokes tonumber() before returning result
- 2.5.9 - removed pass-back flag in getPoint()
- 2.6.0 - testZoneFlag() method based flag testing
- 2.6.1 - Watchflag parsing of zone condition for number-named flags
- case insensitive
--]]--
cfxZones.verbose = false
@ -884,6 +888,7 @@ end
-- from center to rim, with 100% being entirely in center, 0 = outside
-- the third value returned is the distance to center
function cfxZones.pointInZone(thePoint, theZone)
if not (theZone) then return false, 0, 0 end
local pflat = {x = thePoint.x, y = 0, z = thePoint.z}
@ -1177,6 +1182,146 @@ function cfxZones.isMEFlag(inFlag)
-- return dcsCommon.stringIsPositiveNumber(inFlag)
end
-- method-based flag testing
function cfxZones.testFlagByMethodForZone(currVal, lastVal, theMethod, theZone)
-- return true/false based on theMethod's contraints
-- simple constraints
-- ONLY RETURN TRUE IF CHANGE AND CONSTRAINT MET
local lMethod = string.lower(theMethod)
if lMethod == "#" or lMethod == "change" then
-- check if currVal different from lastVal
return currVal ~= lastVal
end
if lMethod == "0" or lMethod == "no" or lMethod == "false"
or lMethod == "off" then
-- WARNING: ONLY RETURNS TRUE IF FALSE AND lastval not zero!
return currVal == 0 and currVal ~= lastVal
end
if lMethod == "1" or lMethod == "yes" or lMethod == "true"
or lMethod == "on" then
-- WARNING: only returns true if lastval was false!!!!
return (currVal ~= 0 and lastVal == 0)
end
if lMethod == "inc" or lMethod == "+1" then
return currVal == lastVal+1
end
if lMethod == "dec" or lMethod == "-1" then
return currVal == lastVal-1
end
-- number constraints
-- or flag constraints
-- ONLY RETURN TRUE IF CHANGE AND CONSTRAINT MET
local op = string.sub(theMethod, 1, 1)
local remainder = string.sub(theMethod, 2)
remainder = dcsCommon.trim(remainder) -- remove all leading and trailing spaces
local rNum = tonumber(remainder)
if not rNum then
-- we use remainder as name for flag
-- PROCESS ESCAPE SEQUENCES
local esc = string.sub(remainder, 1, 1)
local last = string.sub(remainder, -1)
if esc == "@" then
remainder = string.sub(remainder, 2)
remainder = dcsCommon.trim(remainder)
end
if esc == "(" and last == ")" and string.len(remainder) > 2 then
-- note: iisues with startswith("(") ???
remainder = string.sub(remainder, 2, -2)
remainder = dcsCommon.trim(remainder)
end
if esc == "\"" and last == "\"" and string.len(remainder) > 2 then
remainder = string.sub(remainder, 2, -2)
remainder = dcsCommon.trim(remainder)
end
if cfxZones.verbose then
trigger.action.outText("+++zne: accessing flag <" .. remainder .. ">", 30)
end
rNum = cfxZones.getFlagValue(remainder, theZone)
end
if rNum then
-- we have a comparison = ">", "=", "<" followed by a number
-- THEY TRIGGER EACH TIME lastVal <> currVal AND condition IS MET
if op == "=" then
return currVal == rNum and lastVal ~= currVal
end
if op == "#" or op == "~" then
return currVal ~= rNum and lastVal ~= currVal
end
if op == "<" then
return currVal < rNum and lastVal ~= currVal
end
if op == ">" then
return currVal > rNum and lastVal ~= currVal
end
end
-- if we get here, we have an error
local zoneName = "<NIL>"
if theZone then zoneName = theZone.name end
trigger.action.outText("+++Zne: illegal method constraints |" .. theMethod .. "| for zone " .. zoneName, 30 )
return false
end
function cfxZones.testZoneFlag(theZone, theFlagName, theMethod, latchName)
-- returns true if method contraints are met for flag theFlagName
-- as defined by theMethod
if not theMethod then
theMethod = "change"
end
-- will read and update theZone[latchName] as appropriate
if not theZone then
trigger.action.outText("+++Zne: no zone for testZoneFlag", 30)
return
end
if not theFlagName then
-- this is common, no error, only on verbose
if cfxZones.verbose then
trigger.action.outText("+++Zne: no flagName for zone " .. theZone.name .. " for testZoneFlag", 30)
end
return
end
if not latchName then
trigger.action.outText("+++Zne: no latchName for zone " .. theZone.name .. " for testZoneFlag", 30)
return
end
-- get current value
local currVal = cfxZones.getFlagValue(theFlagName, theZone)
-- get last value from latch
local lastVal = theZone[latchName]
if not lastVal then
trigger.action.outText("+++Zne: latch <" .. latchName .. "> not valid for zone " .. theZone.name, 30)
return
end
-- now, test by method
-- we should only test if currVal <> lastVal
if currVal == lastVal then
return false
end
--trigger.action.outText("+++Zne: about to test: c = " .. currVal .. ", l = " .. lastVal, 30)
local testResult = cfxZones.testFlagByMethodForZone(currVal, lastVal, theMethod, theZone)
-- update latch by method
theZone[latchName] = currVal
-- return result
return testResult
end
function cfxZones.flagArrayFromString(inString)
-- original code from RND flag
if string.len(inString) < 1 then
@ -1500,8 +1645,13 @@ function cfxZones.getPoint(aZone) -- always works, even linked, point can be reu
thePos.x = aZone.point.x
thePos.y = 0 -- aZone.y
thePos.z = aZone.point.z
-- since we are at it, update the zone as well
aZone.point = thePos
-- update the zone as well -- that's stupid!
--[[-- aZone.point = thePos
local retPoint = {} -- create new copy to pass back
retPoint.x = thePos.x
retPoint.y = 0
retPoint.z = thePos.z
--]]--
return thePos
end

View File

@ -1,5 +1,5 @@
cloneZones = {}
cloneZones.version = "1.3.1"
cloneZones.version = "1.4.0"
cloneZones.verbose = false
cloneZones.requiredLibs = {
"dcsCommon", -- always
@ -36,6 +36,7 @@ cloneZones.uniqueCounter = 9200000 -- we start group numbering here
1.3.0 - DML flag upgrade
1.3.1 - groupTracker interface
- trackWith: attribute
1.4.0 - Watchflags
--]]--
@ -184,6 +185,14 @@ function cloneZones.createClonerWithZone(theZone) -- has "Cloner"
end
end
-- watchflag:
-- triggerMethod
theZone.cloneTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "cloneTriggerMethod") then
theZone.cloneTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "cloneTriggerMethod", "change")
end
-- f? and spawn? and other synonyms map to the same
if cfxZones.hasProperty(theZone, "f?") then
theZone.spawnFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none")
@ -870,6 +879,14 @@ function cloneZones.update()
end
-- see if we got spawn? command
if cfxZones.testZoneFlag(aZone, aZone.spawnFlag, aZone.cloneTriggerMethod, "lastSpawnValue") then
if cloneZones.verbose then
trigger.action.outText("+++clnZ: spawn triggered for <" .. aZone.name .. ">", 30)
end
cloneZones.spawnWithCloner(aZone)
end
-- old code
--[[--
if aZone.spawnFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.spawnFlag, aZone) -- trigger.misc.getUserFlag(aZone.spawnFlag)
if currTriggerVal ~= aZone.lastSpawnValue
@ -881,6 +898,7 @@ function cloneZones.update()
aZone.lastSpawnValue = currTriggerVal
end
end
--]]--
-- empty handling
local isEmpty = cloneZones.countLiveUnits(aZone) < 1 and aZone.hasClones

View File

@ -1,5 +1,5 @@
countDown = {}
countDown.version = "1.2.0"
countDown.version = "1.3.0"
countDown.verbose = true
countDown.ups = 1
countDown.requiredLibs = {
@ -21,6 +21,9 @@ countDown.requiredLibs = {
- counterOut!
- ups config
1.2.1 - disableCounter?
1.3.0 - DML & Watchflags upgrade
- method --> ctdwnMethod
--]]--
@ -85,8 +88,18 @@ function countDown.createCountDownWithZone(theZone)
-- extend after zero
theZone.belowZero = cfxZones.getBoolFromZoneProperty(theZone, "belowZero", false)
-- method
theZone.method = cfxZones.getStringFromZoneProperty(theZone, "method", "flip")
-- out method
theZone.ctdwnMethod = cfxZones.getStringFromZoneProperty(theZone, "method", "flip")
if cfxZones.hasProperty(theZone, "ctdwnMethod") then
theZone.ctdwnMethod = cfxZones.getStringFromZoneProperty(theZone, "ctdwnMethod", "flip")
end
-- triggerMethod
theZone.ctdwnTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "ctdwnTriggerMethod") then
theZone.ctdwnTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "ctdwnTriggerMethod", "change")
end
-- trigger flag "count" / "start?"
if cfxZones.hasProperty(theZone, "count?") then
@ -155,7 +168,7 @@ function countDown.isTriggered(theZone)
if countDown.verbose then
trigger.action.outText("+++cntD: TMINUTS", 30)
end
cfxZones.pollFlag(theZone.tMinusFlag, theZone.method, theZone)
cfxZones.pollFlag(theZone.tMinusFlag, theZone.ctdwnMethod, theZone)
end
elseif val == 0 then
@ -165,7 +178,7 @@ function countDown.isTriggered(theZone)
if countDown.verbose then
trigger.action.outText("+++cntD: ZERO", 30)
end
cfxZones.pollFlag(theZone.zeroFlag, theZone.method, theZone)
cfxZones.pollFlag(theZone.zeroFlag, theZone.ctdwnMethod, theZone)
end
if theZone.loop then
@ -184,7 +197,7 @@ function countDown.isTriggered(theZone)
if countDown.verbose then
trigger.action.outText("+++cntD: Below Zero", 30)
end
cfxZones.pollFlag(theZone.zeroFlag, theZone.method, theZone)
cfxZones.pollFlag(theZone.zeroFlag, theZone.ctdwnMethod, theZone)
end
end
@ -203,6 +216,16 @@ function countDown.update()
for idx, aZone in pairs(countDown.counters) do
-- make sure to re-start before reading time limit
if (not aZone.counterDisabled) and cfxZones.testZoneFlag(aZone, aZone.triggerCountFlag, aZone.ctdwnTriggerMethod, "lastCountTriggerValue")
then
if countDown.verbose then
trigger.action.outText("+++cntD: triggered on in?", 30)
end
countDown.isTriggered(aZone)
end
-- old colde
--[[--
if aZone.triggerCountFlag and not aZone.counterDisabled then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerCountFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerCountFlag)
if currTriggerVal ~= aZone.lastCountTriggerValue
@ -214,7 +237,16 @@ function countDown.update()
aZone.lastCountTriggerValue = cfxZones.getFlagValue(aZone.triggerCountFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerCountFlag) -- save last value
end
end
--]]--
if cfxZones.testZoneFlag(aZone, aZone.disableCounterFlag, aZone.ctdwnTriggerMethod, "disableCounterFlagVal") then
if countDown.verbose then
trigger.action.outText("+++cntD: disabling counter " .. aZone.name, 30)
end
aZone.counterDisabled = true
end
-- old code
--[[--
if aZone.disableCounterFlag then
local currVal = cfxZones.getFlagValue(aZone.disableCounterFlag, aZone)
if currVal ~= aZone.disableCounterFlagVal then
@ -224,6 +256,7 @@ function countDown.update()
aZone.counterDisabled = true
end
end
--]]--
end
end

View File

@ -1,5 +1,5 @@
dcsCommon = {}
dcsCommon.version = "2.5.6"
dcsCommon.version = "2.5.7"
--[[-- VERSION HISTORY
2.2.6 - compassPositionOfARelativeToB
- clockPositionOfARelativeToB
@ -66,6 +66,7 @@ dcsCommon.version = "2.5.6"
- stringStartsWithLetter()
- stringIsPositiveNumber()
2.5.6 - corrected stringEndsWith() bug with str
2.5.7 - point2text(p)
--]]--
@ -1772,6 +1773,15 @@ dcsCommon.version = "2.5.6"
return "no"
end
function dcsCommon.point2text(p)
if not p then return "<!NIL!>" end
local t = "[x="
if p.x then t = t .. p.x .. ", " else t = t .. "<nil>, " end
if p.y then t = t .. p.y .. ", " else t = t .. "<nil>, " end
if p.z then t = t .. p.z .. "]" else t = t .. "<nil>]" end
return t
end
-- recursively show the contents of a variable
function dcsCommon.dumpVar(key, value, prefix, inrecursion)
if not inrecursion then

View File

@ -1,5 +1,5 @@
delayFlag = {}
delayFlag.version = "1.1.0"
delayFlag.version = "1.2.0"
delayFlag.verbose = false
delayFlag.requiredLibs = {
"dcsCommon", -- always
@ -28,6 +28,7 @@ delayFlag.flags = {}
- delayDone! synonym
- pauseDelay?
- unpauseDelay?
1.2.0 - Watchflags
--]]--
@ -58,7 +59,14 @@ function delayFlag.createTimerWithZone(theZone)
if delayFlag.verbose then
trigger.action.outText("+++dlyF: time delay is <" .. theZone.delayMin .. ", " .. theZone.delayMax .. "> seconds", 30)
end
-- watchflags:
-- triggerMethod
theZone.delayTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "delayTriggerMethod") then
theZone.delayTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "delayTriggerMethod", "change")
end
-- trigger flag
if cfxZones.hasProperty(theZone, "f?") then
@ -142,6 +150,14 @@ function delayFlag.update()
for idx, aZone in pairs(delayFlag.flags) do
-- see if we need to stop
if cfxZones.testZoneFlag(aZone, aZone.triggerStopDelay, aZone.delayTriggerMethod, "lastTriggerStopValue") then
aZone.delayRunning = false -- simply stop.
if delayFlag.verbose then
trigger.action.outText("+++dlyF: stopped delay " .. aZone.name, 30)
end
end
-- old code
--[[--
if aZone.triggerStopDelay then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerStopDelay, aZone)
if currTriggerVal ~= lastTriggerStopValue then
@ -151,7 +167,20 @@ function delayFlag.update()
end
end
end
--]]--
if cfxZones.testZoneFlag(aZone, aZone.triggerDelayFlag, aZone.delayTriggerMethod, "lastDelayTriggerValue") then
if delayFlag.verbose then
if aZone.delayRunning then
trigger.action.outText("+++dlyF: re-starting timer " .. aZone.name, 30)
else
trigger.action.outText("+++dlyF: init timer for " .. aZone.name, 30)
end
end
delayFlag.startDelay(aZone) -- we restart even if running
end
-- old code
--[[--
-- make sure to re-start before reading time limit
if aZone.triggerDelayFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerDelayFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerDelayFlag)
@ -168,6 +197,7 @@ function delayFlag.update()
aZone.lastDelayTriggerValue = currTriggerVal
end
end
--]]--
if aZone.delayRunning then
-- check expiry

View File

@ -1,5 +1,5 @@
messenger = {}
messenger.version = "1.1.1"
messenger.version = "1.2.0"
messenger.verbose = false
messenger.requiredLibs = {
"dcsCommon", -- always
@ -18,6 +18,8 @@ messenger.messengers = {}
1.1.1 - firewalled coalition to msgCoalition
- messageOn?
- messageOff?
1.2.0 - triggerMethod (original Watchflag integration)
--]]--
function messenger.addMessenger(theZone)
@ -53,6 +55,9 @@ function messenger.createMessengerWithZone(theZone)
theZone.duration = cfxZones.getNumberFromZoneProperty(theZone, "duration", 30)
-- triggerMethod
theZone.triggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
-- trigger flag f? in? messageOut?
if cfxZones.hasProperty(theZone, "f?") then
theZone.triggerMessagerFlag = cfxZones.getStringFromZoneProperty(theZone, "f?", "none")
@ -157,37 +162,26 @@ function messenger.update()
for idx, aZone in pairs(messenger.messengers) do
-- make sure to re-start before reading time limit
if aZone.triggerMessagerFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerMessagerFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerMessagerFlag)
if currTriggerVal ~= aZone.lastMessageTriggerValue
then
if messenger.verbose then
-- new trigger code
if cfxZones.testZoneFlag(aZone, aZone.triggerMessagerFlag, aZone.triggerMethod, "lastMessageTriggerValue") then
if messenger.verbose then
trigger.action.outText("+++msgr: triggered on in? for <".. aZone.name ..">", 30)
end
messenger.isTriggered(aZone)
aZone.lastMessageTriggerValue = cfxZones.getFlagValue(aZone.triggerMessagerFlag, aZone) -- trigger.misc.getUserFlag(aZone.triggerMessagerFlag) -- save last value
end
messenger.isTriggered(aZone)
end
-- old trigger code
if cfxZones.testZoneFlag(aZone, aZone.messageOffFlag, "change", "lastMessageOff") then
aZone.messageOff = true
if messenger.verbose then
trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ***OFF***", 30)
end
end
if aZone.messageOffFlag then
local currVal = cfxZones.getFlagValue(aZone.messageOffFlag, aZone)
if currVal ~= aZone.lastMessageOff then
aZone.messageOff = true
aZone.lastMessageOff = currVal
if messenger.verbose then
trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ***OFF***", 30)
end
end
end
if aZone.messageOnFlag then
local currVal = cfxZones.getFlagValue(aZone.messageOnFlag, aZone)
if currVal ~= aZone.lastMessageOn then
aZone.messageOff = false
aZone.lastMessageOn = currVal
if messenger.verbose then
trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ON", 30)
end
if cfxZones.testZoneFlag(aZone, aZone.messageOnFlag, "change", "lastMessageOn") then
aZone.messageOff = false
if messenger.verbose then
trigger.action.outText("+++msg: messenger <" .. aZone.name .. "> turned ON", 30)
end
end
end

View File

@ -1,5 +1,5 @@
pulseFlags = {}
pulseFlags.version = "1.1.0"
pulseFlags.version = "1.2.0"
pulseFlags.verbose = false
pulseFlags.requiredLibs = {
"dcsCommon", -- always
@ -27,6 +27,8 @@ pulseFlags.requiredLibs = {
pulseMethod synonym
startPulse? synonym
pulseStopped synonym
- 1.2.0 DML Watchflag integration
corrected bug in loading last pulse value for paused
--]]--
@ -57,7 +59,15 @@ function pulseFlags.createPulseWithZone(theZone)
theZone.pulses = cfxZones.getNumberFromZoneProperty(theZone, "pulses", -1)
theZone.pulsesLeft = 0 -- will start new cycle
-- watchflag:
-- triggerMethod
theZone.pulseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "pulseTriggerMethod") then
theZone.pulseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "pulseTriggerMethod", "change")
end
-- trigger flags
if cfxZones.hasProperty(theZone, "activate?") then
theZone.activatePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "activate?", "none")
@ -71,12 +81,12 @@ function pulseFlags.createPulseWithZone(theZone)
if cfxZones.hasProperty(theZone, "pause?") then
theZone.pausePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "pause?", "*none")
theZone.lastPauseValue = cfxZones.getFlagValue(theZone.lastPauseValue, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value
theZone.lastPauseValue = cfxZones.getFlagValue(theZone.pausePulseFlag, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value
end
if cfxZones.hasProperty(theZone, "pausePulse?") then
theZone.pausePulseFlag = cfxZones.getStringFromZoneProperty(theZone, "pausePulse?", "*none")
theZone.lastPauseValue = cfxZones.getFlagValue(theZone.lastPauseValue, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value
theZone.lastPauseValue = cfxZones.getFlagValue(theZone.pausePulseFlag, theZone)-- trigger.misc.getUserFlag(theZone.pausePulseFlag) -- save last value
end
theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "paused", false)
@ -85,10 +95,10 @@ function pulseFlags.createPulseWithZone(theZone)
theZone.pulsePaused = cfxZones.getBoolFromZoneProperty(theZone, "pulseStopped", false)
end
theZone.method = cfxZones.getStringFromZoneProperty(theZone, "method", "flip")
theZone.pulseMethod = cfxZones.getStringFromZoneProperty(theZone, "method", "flip")
if cfxZones.hasProperty(theZone, "pulseMethod") then
theZone.method = cfxZones.getStringFromZoneProperty(theZone, "pulseMethod", "flip")
theZone.pulseMethod = cfxZones.getStringFromZoneProperty(theZone, "pulseMethod", "flip")
end
-- done flag
if cfxZones.hasProperty(theZone, "done+1") then
@ -127,7 +137,7 @@ function pulseFlags.doPulse(args)
trigger.action.outText("+++pulF: will bang " .. theZone.pulseFlag, 30);
end
cfxZones.pollFlag(theZone.pulseFlag, theZone.method, theZone)
cfxZones.pollFlag(theZone.pulseFlag, theZone.pulseMethod, theZone)
-- decrease count
if theZone.pulses > 0 then
@ -202,6 +212,15 @@ function pulseFlags.update()
end
-- see if we got a pause or activate command
-- activatePulseFlag
if cfxZones.testZoneFlag(aZone, aZone.activatePulseFlag, aZone.pulseTriggerMethod, "lastActivateValue") then
if pulseFlags.verbose then
trigger.action.outText("+++PulF: activating <" .. aZone.name .. ">", 30)
end
aZone.pulsePaused = false -- will start anew
end
--[[-- -- old code
if aZone.activatePulseFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.activatePulseFlag, aZone) -- trigger.misc.getUserFlag(aZone.activatePulseFlag)
if currTriggerVal ~= aZone.lastActivateValue
@ -214,7 +233,20 @@ function pulseFlags.update()
end
end
--]]--
-- pausePulseFlag
if cfxZones.testZoneFlag(aZone, aZone.pausePulseFlag, aZone.pulseTriggerMethod, "lastPauseValue") then
if pulseFlags.verbose then
trigger.action.outText("+++PulF: pausing <" .. aZone.name .. ">", 30)
end
aZone.pulsePaused = true -- prevents new start
if aZone.timerID then
timer.removeFunction(aZone.timerID)
aZone.timerID = nil
end
end
--[[--
-- old colde
if aZone.pausePulseFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.pausePulseFlag, aZone)-- trigger.misc.getUserFlag(aZone.pausePulseFlag)
if currTriggerVal ~= aZone.lastPauseValue
@ -230,6 +262,7 @@ function pulseFlags.update()
end
end
end
--]]--
end
end

View File

@ -1,5 +1,5 @@
raiseFlag = {}
raiseFlag.version = "1.0.1"
raiseFlag.version = "1.2.0"
raiseFlag.verbose = false
raiseFlag.requiredLibs = {
"dcsCommon", -- always
@ -12,6 +12,8 @@ raiseFlag.flags = {}
Version History
1.0.0 - initial release
1.0.1 - synonym "raiseFlag!"
1.1.0 - DML update
1.2.0 - Watchflag update
--]]--
function raiseFlag.addRaiseFlag(theZone)
@ -44,6 +46,14 @@ function raiseFlag.createRaiseFlagWithZone(theZone)
theZone.minAfterTime, theZone.maxAfterTime = cfxZones.getPositiveRangeFromZoneProperty(theZone, "afterTime", -1)
-- method for triggering
-- watchflag:
-- triggerMethod
theZone.raiseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "triggerMethod", "change")
if cfxZones.hasProperty(theZone, "raiseTriggerMethod") then
theZone.raiseTriggerMethod = cfxZones.getStringFromZoneProperty(theZone, "raiseTriggerMethod", "change")
end
if cfxZones.hasProperty(theZone, "stopFlag?") then
theZone.triggerStopFlag = cfxZones.getStringFromZoneProperty(theZone, "stopFlag?", "none")
theZone.lastTriggerStopValue = cfxZones.getFlagValue(theZone.triggerStopFlag, theZone) -- save last value
@ -79,6 +89,12 @@ function raiseFlag.update()
for idx, aZone in pairs(raiseFlag.flags) do
-- make sure to re-start before reading time limit
if cfxZones.testZoneFlag(aZone, aZone.triggerStopFlag, aZone.raiseTriggerMethod, "lastTriggerStopValue") then
theZone.raiseStopped = true -- we are done, no flag!
end
-- old code
--[[--
if aZone.triggerStopFlag then
local currTriggerVal = cfxZones.getFlagValue(aZone.triggerStopFlag, theZone)
if currTriggerVal ~= aZone.lastTriggerStopValue
@ -86,6 +102,7 @@ function raiseFlag.update()
theZone.raiseStopped = true -- we are done, no flag!
end
end
--]]--
end
end

View File

@ -1,5 +1,5 @@
xFlags = {}
xFlags.version = "1.0.0"
xFlags.version = "1.0.1"
xFlags.verbose = false
xFlags.ups = 1 -- overwritten in get config!
xFlags.requiredLibs = {
@ -11,6 +11,8 @@ xFlags.requiredLibs = {
Version History
1.0.0 - Initial version
1.0.1 - allow flags names for ops as well
modelled on cfxZones.testFlagByMethodForZone()
--]]--
xFlags.xFlagZones = {}
@ -99,7 +101,6 @@ function xFlags.evaluateFlags(theZone)
-- we must preserve the order of the array
local flagName = theZone.flagNames[i]
currVals[i] = cfxZones.getFlagValue(flagName, theZone)
end
-- now perform comparison flag by flag
@ -109,6 +110,11 @@ function xFlags.evaluateFlags(theZone)
local firstChar = string.sub(op, 1, 1)
local remainder = string.sub(op, 2)
local rNum = tonumber(remainder)
if not rNum then
-- interpret remainder as flag name
-- so we can say >*killMax
rNum = cfxZones.getFlagValue(remainder, theZone)
end
for i = 1, #theZone.flagNames do
local lastHits = hits

Binary file not shown.