You can do that in this way:
First create a trigger as large as the area affected by radiological hazard (you can choose any of the two available shapes, I would go for the circle shape and not the rectangular one since it's more realistic, usually radiation level decreases with the distance from the center of the radiation source):
Set the trigger parameters like this:
ACTIVATED BY: Anyone, Repeatedly
TYPE: None
CONDITION: this
ON ACTIVATION: call{[thisList, 0.01, []] execVM "radiationSource.sqf"}
then use the following script (call it radiationSource.sqf or change the name in the trigger field if you use another name)
/* SYNTAX: [unitArray, radiationLevel, shieldedVehicleArray] execVM "radiationSource.sqf"
VARIABLES: unitArray: Array - Array of units affected by the radiation source
radiationLevel: Number - damage each units will suffer while staying nearby the radiation source
(damage is added every second, so 0.1 means the unit will lose 0.1 of health each second, 1 means
instant death)
shieldedVehicleParam: Matrix - Matrix containing a couple of values [className, damageScale] which
represents the damage reduction in percentage for the units inside the given vehicle
(for example modern tanks are shielded against radiation sources, so you can use this to reduce
the damage for units inside a vehicle).
If you are not interested in vehicle damage reduction just pass the script an empty array [].
NOTES: You should call this script from a trigger with a certain area, so you can pass the thisList array to the
script. For example a call could be
call{[thisList, 0.1, []] execVM "radiationSource.sqf"}
*/
//local function used to check how many units are alive in an array
_areAlive =
{
_count = 0;
{
if (alive _x) then {_count = _count + 1};
}
forEach _this;
_count
};
//initializing local variables
_unitArray = _this select 0;
_damage = _this select 1;
_vArray = _this select 2;
//number of units who activated the trigger
_currentAliveUnits = _unitArray call _areAlive;
while {_currentAliveUnits > 0} do
{
//compute and apply the damage factor for each unit in unitArray
{
_damageRed = 0;
//triggering unit is in a vehicle
if (count crew vehicle _x > 0) then
{
_v = vehicle _x;
//check if the vehicle in which the unit is mounted is radiation shielded
{
if ((_x select 0) == (typeOf _v)) then {_damageRed = _x select 1};
}
forEach _vArray;
};
_totalDamage = _damage - (_damage / 100 * _damageRed);
if (_totalDamage <= 0.001 and _x == player) then {hint "Warning - Low radiation source detected"}
else
{
if (_totalDamage <= 0.01 and _x == player) then {hint "Warning - Medium radiation source detected"}
else
{
if (_x == player) then {hint "Warning - Strong radiation source detected"};
};
};
//set the current damage for the unit
if (count crew _x > 0) then
{
{_x setDamage ((damage _x) + _totalDamage)} forEach crew _x;
}
else {_x setDamage ((damage _x) + _totalDamage)};
//DEBUG
player sidechat format["%1 health is %2", player, 1 - (damage player)];
}
forEach _unitArray;
sleep(1);
_currentAliveUnits = _unitArray call _areAlive;
};
The script works like this: the first parameter is a unit array containing the units affected by the radiation source. In this case you pass the
thisList variables since the radiation source is an area represented by the trigger area. The third parameter is a matrix, that is an array of arrays. Each element contains a couple made of a vehicle classname and a percentage of damage reduction. I made this because certain tanks and armored vehicles are partially shielded against radiations. If you're not interested in damage reduction you can pass the script an empty array.
EXAMPLE: You want to create a radiation source which damage the health of the units by 10% each second and no vehicle is shielded against it. You create a trigger just as I told you before then in the activation field write
call{[thisList, 0.1, []] execVM "radiationSource.sqf"}
EXAMPLE: You want to create a radiation source which damage the health of the units by 10% each second and you want that both T72 and M1A1 are shielded and reduce the radiation level by 75%, then you write
call{[thisList, 0.1, [["M1Abrams", 75], ["T72", 75]]] execVM "radiationSource.sqf"} (watch the square brackets since you have a lot of arrays!)
You can find all the vehicle classnames here:
http://www.ofpec.com/COMREF/index.php?action=read&id=73You can also add multilevel radiation source, that is a different scale of damage based on the distance from the center of the source. You just have to place concentric triggers whose area becomes as larger as they are farther from the radiation source. In each trigger put a different value for the radiation damage when you call the script. Remember that the damage is summed among all the trigger that are currently active
EXAMPLE: You want to make a 3-level radiation source, that damages the player by 10% of his health when he's 50m close to it, by 1% when he's between 50m and 100 m and by 0.1% when he's from 100 to 200m close to it.
Create three triggers:
TRIGGER 1:
SIZE: a = 50, b = 50, circle
ACTIVATION: Anyone - Repeatedly
CONDITION: this
ON ACTIVATION: call{[thisList, 0.089, []] execVM "radiationSource.sqf"}
Note that the damage is 0.089 and not 0.1 because when you're inside this trigger you're both inside TRIGGER2 and TRIGGER 3 (see below) and the damage of all the 3 triggers is summed since 3 instances of the script are running at the same time (every second it adds 0.089 + 0.01 + 0.001 damage to the player).
TRIGGER 2:
SIZE: a = 100, b = 100, circle
ACTIVATION: Anyone - Repeatedly
CONDITION: this
ON ACTIVATION: call{[thisList, 0.009, []] execVM "radiationSource.sqf"}
This time we use 0.009 because both TRIGGER2 and TRIGGER3 are active when a unit is inside it so 0.009 + 0.001 = 0.01 damage is added every second.
TRIGGER 3:
SIZE: a = 200, b = 200, circle
ACTIVATION: Anyone - Repeatedly
CONDITION: this
ON ACTIVATION: call{[thisList, 0.001, []] execVM "radiationSource.sqf"}
The last trigger has the normal damage value since it's the only active when the unit is far from the radiation source more than 100m.
Finally you can add some effects to signal that a unit has entered a hazardous location, for example you can add a Geiger counter sound which is played as long as the unit is inside the area (but you have to modify the script and define the class for the sound in the mission description.ext file), or you can add a HUD image displaying the radiation hazard symbol using dialogs but you have to ask Mandobole for a better explanation since I'm not very good at scritping this kind of stuff. In my script I simply put a hint message which changes depending on the level of radiation (Strong, medium and low).