I'm not sure if this is the sort of example for which you're seeking but...
In some missions I've made, I like to add IEDs via Jeevz' IED script. (Note that it's in SQS format!
) Anyhow, I didn't like having specific IED locations...I wanted them to be random so that players couldn't be sure whether or not it was safe to walk near that car...that garbage can...that pile of trash near the road. So I wrote a script to randomize the locations of the IEDs. To use it, you simply place a series of empty objects on the map, name them (i.e., "ied1", "ied2", "ied3", etc.) and then add the following line to the mission's INIT.SQF file...
[
[
[ied1, "Large", 15],
[ied2, "Huge", 30],
[ied3, "Large", 15]
]
] execVM "IED_Randomizer.sqf";
Essentially what this does is it identifies possible IED locations in the map (ied1 thru ied3) and specifies both the size of each IED (Small, Medium, Large, or Huge) and the distance at which it will be triggered. For example, if ied1 is made active, then it will be a Large IED triggered when someone comes within 15 meters of its location. Whether or not a particular location is made into an actual IED is based on the script equivalent of flipping a coin ("round(random 1)").
Well, I'm sure you get the idea so here's the randomization script itself (see below). Note that the input parameters are in nested array form and I can add more possible IED's simply by adding more entries to the parameter array.
Hope this helps,
-z
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
IED_Randomizer.sqf// ----------------------------------------------------
//
// IED_Randomizer.sqf by zonker3210
// created: 10-Jun-2009
//
// Intended for use with the IED.SQS script made
// by Jeevz. The IED.SQS script may be found here:
//
// http://www.armaholic.com/page.php?id=504
//
// The script below allows for somewhat random IEDs
// from a pool of potential IEDs. Should be
// referenced in your INIT.SQF file like so...
//
// [
// [
// [ied1, "Large", 15],
// [ied2, "Huge", 30],
// [ied3, "Large", 15],
// [ied4, "Small", 5],
// [ied5, "Medium", 15]
// ]
// ] execVM "IED_Randomizer.sqf";
//
// ----------------------------------------------------
if !(isServer) exitWith{};
private ["_trigger", "_activateIED", "_iedArray"];
_activateIED = 0;
_iedArray = _this select 0;
if (isNil "Ied_Setup_Completed") then
{
//loop thru each item in the array of potential IEDs...
{
// get a pseudo-random number; 0=false, 1=true
_activateIED = round(random 1);
if (_activateIED > 0) then
{
// ------- debugging statement -------
//hint format["%1 is active", _x];
// -----------------------------------
// Create a trigger at the location of the potential IED. When activated,
// the trigger will call the IED.SQS script using the specified IED object
// and blast size.
_trigger = createTrigger["EmptyDetector", (getPos (_x select 0))];
_trigger setTriggerArea[(_x select 2),(_x select 2),0,false];
_trigger setTriggerActivation["WEST","PRESENT",false];
_trigger setTriggerStatements["(thisList select 0) isKindOf 'Man'", format["[%1, ""%2""] exec ""ied.sqs""", (_x select 0), (_x select 1)], ""];
};
sleep .5;
} foreach _iedArray;
// set the nil variable with a default value for server and both JIP & 'join at mission start'
Ied_Setup_Completed = true;
publicVariable "Ied_Setup_Completed";
};
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */