mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Common - Add ace_common_fnc_addExplosionEventHandler
This commit is contained in:
parent
f564016b4b
commit
ea175b1dc4
@ -269,6 +269,7 @@ PREP(_handleRequestAllSyncedEvents);
|
|||||||
// other eventhandlers
|
// other eventhandlers
|
||||||
PREP(addActionEventHandler);
|
PREP(addActionEventHandler);
|
||||||
PREP(addActionMenuEventHandler);
|
PREP(addActionMenuEventHandler);
|
||||||
|
PREP(addExplosionEventHandler);
|
||||||
PREP(addMapMarkerCreatedEventHandler);
|
PREP(addMapMarkerCreatedEventHandler);
|
||||||
PREP(addPlayerEH);
|
PREP(addPlayerEH);
|
||||||
|
|
||||||
|
36
addons/common/functions/fnc_addExplosionEventHandler.sqf
Normal file
36
addons/common/functions/fnc_addExplosionEventHandler.sqf
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include "..\script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: johnb432, PabstMirror
|
||||||
|
* Adds event hander for explosions (for local projectiles)
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Code to execute <CODE>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* The CBA Event Handler Index <NUMBER>
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [{systemChat "boom"}] call ace_common_fnc_addExplosionEventHandler
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
|
|
||||||
|
params [["_code", {}, [{}]]];
|
||||||
|
|
||||||
|
if !(missionNamespace getVariable [QGVAR(addExplosionEventHandlerActive), false]) then {
|
||||||
|
GVAR(addExplosionEventHandlerActive) = true;
|
||||||
|
|
||||||
|
addMissionEventHandler ["ProjectileCreated", {
|
||||||
|
params ["_projectile"];
|
||||||
|
TRACE_2("pc",typeOf _projectile,local _projectile);
|
||||||
|
|
||||||
|
if (!local _projectile) exitWith {}; // Rockets only explode on local clients
|
||||||
|
|
||||||
|
_projectile addEventHandler ["Explode", {
|
||||||
|
TRACE_1("exp",_this);
|
||||||
|
[QGVAR(explosion), _this] call CBA_fnc_localEvent;
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
[QGVAR(explosion), _code] call CBA_fnc_addEventHandler
|
@ -16,16 +16,10 @@ if (isServer) then {
|
|||||||
// Only install event handler if combat deafness is enabled
|
// Only install event handler if combat deafness is enabled
|
||||||
if (!GVAR(enableCombatDeafness)) exitWith {};
|
if (!GVAR(enableCombatDeafness)) exitWith {};
|
||||||
|
|
||||||
addMissionEventHandler ["ProjectileCreated", {
|
[{ // Convert ace_common's local explosion to a hearing global explosion event
|
||||||
params ["_projectile"];
|
TRACE_1("Explode",_this);
|
||||||
|
[QGVAR(explosion), _this select [0,2]] call CBA_fnc_globalEvent; // trim unused 3rd arg for network savings
|
||||||
if (!local _projectile) exitWith {};
|
}] call EFUNC(common,addExplosionEventHandler);
|
||||||
|
|
||||||
// Rockets only explode on local clients
|
|
||||||
_projectile addEventHandler ["Explode", {
|
|
||||||
[QGVAR(explosion), _this] call CBA_fnc_globalEvent;
|
|
||||||
}];
|
|
||||||
}];
|
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
if (!hasInterface) exitWith {};
|
if (!hasInterface) exitWith {};
|
||||||
|
@ -6,13 +6,12 @@
|
|||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Projectile <OBJECT>
|
* 0: Projectile <OBJECT>
|
||||||
* 1: Explosion position ASL <ARRAY>
|
* 1: Explosion position ASL <ARRAY>
|
||||||
* 2: Velocity <ARRAY> (unused)
|
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [_projectile, [0, 0, 0], [0, 0, 0]] call ace_hearing_fnc_explosion
|
* [_projectile, [0, 0, 0]] call ace_hearing_fnc_explosion
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user