OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Gnat on 20 Aug 2008, 12:29:58
-
Searched but not found something that matches.
Looking for a simple mission trigger where X% or >X buildings within a radius of a gamelogic or within the Trigger zone are destroyed.
I don't want to have to record the object ID for every object or building and script test every one, I just want to know the zone is very much been bombed back to the stone age!
The count including objects and vehicles etc is of no concern.
Thx :D
-
Hmmmm, maybe check how many building models have been replaced by the Ruins class equivalent?
Just thinking aloud.
Planck
-
Well, triggers only pick up vehicles, but you can still use a trigger for this. Name a trigger, "devastation". To check if there are greater than 5 ruined buildings within 200m of the trigger:
(count nearestObjects [getPos devastation, ["Ruins"], 200]) > 5
Note that this will include any ruins that are already placed at the start of the mission, for example those in Corazol.
If you want lower cpu load (e.g. if you need to check a lot of buildings or a very large area), you could add KILLED handlers to all the buildings in a given area with each handler adding 1 to a count of destroyed buildings and if the count is too large at that point, it could run a handler function:
// [getPos devastationLogic, 1000, 5, { player sideChat "Devastation!" }] execVM "devastation.sqf";
_centre = _this select 0;
_radius = _this select 1;
ruinsMax = _this select 2; // Buildings destroyed for handler to fire.
ruinsHandler = _this select 3; // Function to call when too many ruins.
_buildings = nearestObjects [_centre, ["House", "FuelStation", "Church"], _radius];
ruinsCount = 0;
{
_x addEventHandler ["KILLED", {
ruinsCount = ruinsCount + 1;
if (ruinsCount == ruinsMax) then
{
call ruinsHandler;
};
}];
} forEach _buildings;
EDIT: Probably best to add handler to just ["House", "FuelStation", "Church"] rather than to all ["Strategic"].
-
Darn that was quick Spooner!
It worked perfectly ..... legend! :good: