Hi, yes it can be done both ways. But depending on the condition you want them to explode, you might find your self doing something different than what I have done. Which is to detect if a group or unit has entered a zone and destroy either the group or unit in that zone. You can run and test both .miz files provided below and see how each one works differently.
Mission Editor Trigger:
explode_trigger.miz
This example will destroy an ENTIRE group if:
1) ALL OF GROUP IN ZONE
or
2) PART OF GROUP IN ZONE
becomes true.
This will also only happen ONCE because of the ONCE Type TRIGGER.
Scripted Trigger:
explode_script.miz
To be noted: This script requires MIST
The code below will destroy a SINGLE unit from the group if it is within the zone. However the downside to this is that it needs to be continuously updated to detect if any unit from the group is within the zone. It will run until it finds that the entire group no longer exists and then it will stop.
function explode_group()
local groupName = "Hog 1"
local zone = trigger.misc.getZone("Explode Zone")
if Group.getByName(groupName) then
local units = Group.getByName(groupName):getUnits()
for k,v in pairs(units) do
local unit = v
local unit_name = unit:getName()
local unit_pos = unit:getPosition().p
if mist.utils.get2DDist(unit_pos, zone.point) < zone.radius then
trigger.action.outText("Destroying "..unit_name.." In Zone!", 5)
unit:destroy()
trigger.action.explosion(unit_pos, 500)
else
trigger.action.outText(unit_name.." Not In Zone!", 5)
end
end
timer.scheduleFunction(explode_group, nil, timer.getTime() + 6)
else
trigger.action.outText("cannot find group named: "..groupName, 5)
end
end
explode_group()
The mission editor trigger should be fairly straight forward to accomplish based on your needs. If you have any questions on how the scripting one works, feel free to ask.
Enjoy