Units not in a zone trigger

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
vettim89
Posts: 3723
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

Units not in a zone trigger

Post by vettim89 »

A scenario I am designing involves a hostage rescue. I am trying to figure out a code that will only allow an event if a particular zone is free of OPFOR units.

A SpecOps unit has infiltrated the area where the hostages were being held and neutralized the captors. However, there are other OPFOR units nearby that can interfere with the extraction. Follow on friendly forces are assigned to destroy all OPFOR units in the area before the extraction helo is sent in to pick up the hostages. Basically I want the event to only trigger if the LZ is clear of enemy units. How could I do this?

Second I want an event to end the scenario once the hostages and all friendly units have been exfiltrated, i.e no friendly units left in the AO. Is there a way to trigger this?

Thanks as always for the help
"We have met the enemy and they are ours" - Commodore O.H. Perry
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Units not in a zone trigger

Post by michaelm75au »

Basically for the first, it should be an event on a time or 'unit remains in area' trigger with a condition of no units in the area (there is an inArea() method for unit/contact), and probably should be inactive until some primary event happens as the SpecOps eliminating the captors.
Once I wake up, I'll add some code if no-one else beats me to it.[:D]
Michael
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Units not in a zone trigger

Post by michaelm75au »

Event condition to check if a area is free of units from a side.
--------------------------------
-- condition assumed to pass. look for cases where not true
local AOclear = true
-- AO area
local area = {'rp-6074','rp-6075','rp-6076','rp-6077'}
-- get units on a side
local side = VP_GetSide({side='china'})
-- side's unit list print(side.units)
-- process the list
for key,value in pairs(side.units)
do
-- get the unit details
local unit = ScenEdit_GetUnit({guid=value.guid})
-- check if unit in the area
if unit:inArea( area ) == true then
-- yes, then condition not true
AOclear = false ; print('AO not clear')
break
end
end
-- return the status
return AOclear
Michael
Post Reply

Return to “Lua Legion”