/* * Author: esteldunedain * Unfied handling of weapon fire * * Argument: * 0: unit - Object the event handler is assigned to * 1: weapon - Fired weapon * 2: muzzle - Muzzle that was used * 3: mode - Current mode of the fired weapon * 4: ammo - Ammo used * 5: magazine - magazine name which was used * 6: projectile - Object of the projectile that was shot * * Return value: * None * * Public: No */ #include "script_component.hpp" BEGIN_COUNTER(firedEH); params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"]; TRACE_7("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile); if (_unit isKindOf "CAManBase") then { // The unit it on foot if (_unit == ACE_player) then { ["firedPlayer", _this] call FUNC(localEvent); } else { if ([_unit] call EFUNC(common,isPlayer)) then { ["firedPlayerNonLocal", _this] call FUNC(localEvent); } else { ["firedNonPlayer", _this] call FUNC(localEvent); }; }; } else { // The unit is a vehicle private _vehicle = _unit; // Get the gunner and turret path. // Code based on FUNC(getGunner), extracted for efficency. private _gunner = objNull; private _turret = []; { if (_weapon in (_unit weaponsTurret _x)) exitWith { _gunner = _unit turretUnit _x; _turret = _x; }; false } count allTurrets [_unit, true]; // Ensure that at least the pilot is returned if there is no gunner if (isManualFire _unit && {isNull _gunner}) then { _gunner = effectiveCommander _unit; }; if (_gunner == ACE_player) then { ["firedPlayerVehicle", _this] call FUNC(localEvent); } else { if ([_gunner] call EFUNC(common,isPlayer)) then { ["firedPlayerVehicleNonLocal", _this] call FUNC(localEvent); } else { ["firedNonPlayerVehicle", _this] call FUNC(localEvent); }; }; }; END_COUNTER(firedEH);