still testing
This commit is contained in:
@@ -1,39 +1,35 @@
|
||||
// this script is used in a trigger and run on all machines.
|
||||
// it is used to simulate the effects of an EMP bomb on all objects within a certain radius of the trigger
|
||||
|
||||
// safeguards have been put in place so that "Local Argument" commands are only processed on the machine that owns the object
|
||||
// this is important because the results of these commands are not reliable if the object is not local
|
||||
|
||||
// the playSound3D command has been modified to only play the sound on this local machine for every non-man object. This way, the many machines running this function are not propagating duplicate sound instances to each other all at once.
|
||||
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
// This function is used to deploy an EMP device and trigger the EMP effects on all machines
|
||||
// The EMP effect is triggered by the global event "QGVAR(event_empDeployed)"
|
||||
// This function should be called on the server
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
//get center and radius
|
||||
params [["_center",objNull],["_rad",200]];
|
||||
params [["_origin", objNull, [[], objNull]],["_rad",1500, [300]]];
|
||||
|
||||
private _objectsToAffect = [_center, _rad] call FUNC(getAffectedObjects);
|
||||
if (_origin isEqualType []) then {
|
||||
if (count _origin != 3) exitWith {
|
||||
["Invalid origin position provided (%1)", _origin] call BIS_fnc_error;
|
||||
};
|
||||
};
|
||||
|
||||
{
|
||||
// sleep to add aesthetic
|
||||
sleep GVAR(timeBetweenEntities);
|
||||
if (_origin isEqualType objNull) then {
|
||||
if (isNull _origin) exitWith {
|
||||
["No origin object or position provided (%1)", _origin] call BIS_fnc_error;
|
||||
};
|
||||
_origin = getPosASL _origin;
|
||||
};
|
||||
|
||||
[{
|
||||
params ["_obj"];
|
||||
private _objectsToAffect = [_origin, _rad] call FUNC(getObjectsToAffect);
|
||||
|
||||
// local flicker light effect
|
||||
[_obj] remoteExecCall [QFUNC(flickerLights), 0];
|
||||
// for groups, deduplicate and get AI groups only
|
||||
private _groupsToAffect = _objectsToAffect apply {group _x};
|
||||
_groupsToAffect = _groupsToAffect arrayIntersect _groupsToAffect;
|
||||
_groupsToAffect = _groupsToAffect select {!isPlayer (leader _x)};
|
||||
|
||||
// playSound3D from server (running this code) to all clients
|
||||
[_obj] call FUNC(playZapServer);
|
||||
|
||||
// process these if our machine owns the object, since many of the commands require local arguments
|
||||
// the results of these commands are not reliable if the object is not local
|
||||
[_obj] remoteExecCall [QFUNC(applyLocalUnitEffects), _obj];
|
||||
[QGVAR(event_empDeployed), [_origin, _objectsToAffect, _groupsToAffect]] call CBA_fnc_globalEvent;
|
||||
|
||||
// these are group-related commands that should be run where group is local
|
||||
[group _obj] remoteExecCall [QFUNC(applyLocalGroupEffects), group _obj];
|
||||
|
||||
}, [_x]] call CBA_fnc_directCall;
|
||||
} forEach _objectsToAffect;
|
||||
true;
|
||||
Reference in New Issue
Block a user