#Artillery with EHs
1 messages · Page 1 of 1 (latest)
_fireGroups is a local variable within the function, it only exists in the function, but not in the EH.
We can do the same as we did earlier: Use the unit's varspace to pass the variable from the function to the EH.
params ["_artillery", "_rounds"];
_artillery addEventHandler ["Fired", {
params ["_artillery"];
private _firedRounds = _artillery getVariable ["FEC_firedRounds", 0];
if (_firedRounds < (_artillery getVariable ["FEC_rounds", 0])) then {
_artillery doArtilleryFire [[[art_area], []] call BIS_fnc_randomPos, "32Rnd_155mm_Mo_shells", 1];
_artillery setVariable ["FEC_firedRounds", _firedRounds + 1];
} else {
_artillery removeEventHandler [_thisEvent, _thisEventHandler];
};
}];
_artillery setVariable ["FEC_rounds", _rounds];
_artillery setVariable ["FEC_firedRounds", 1];
_artillery doArtilleryFire [[[art_area], []] call BIS_fnc_randomPos, "32Rnd_155mm_Mo_shells", 1];
```This way you can indeed call the function like so: `[art_v, 3] call FEC_fnc_artilleryFire`
You can use the same approach to parameterize the target position in case you want the artillery to fire at more positions (and not just art_area).
ah, now i have permissions