2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-02-20 01:32:41 +00:00
|
|
|
* Author: bux, commy2
|
2016-02-06 20:07:05 +00:00
|
|
|
* Replace the disposable launcher with the used dummy. Called from the unified fired EH.
|
2015-02-20 01:32:41 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2016-02-06 19:39:08 +00:00
|
|
|
* None. Parameters inherited from EFUNC(common,firedEH)
|
2015-02-20 01:32:41 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-01-11 16:42:31 +00:00
|
|
|
* Nothing
|
2015-02-20 01:32:41 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [fromBisFiredEH] call ace_disposable_fnc_replaceATWeapon;
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-13 19:12:37 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2016-02-06 20:07:05 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
|
|
|
|
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
if (!local _unit || {_weapon != secondaryWeapon _unit}) exitWith {};
|
2015-02-20 01:32:41 +00:00
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube");
|
2015-03-20 01:24:14 +00:00
|
|
|
if (_replacementTube == "") exitWith {}; //If no replacement defined just exit
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-20 01:24:14 +00:00
|
|
|
//Save array of items attached to launcher
|
2016-01-06 21:42:02 +00:00
|
|
|
private _items = secondaryWeaponItems _unit;
|
2015-03-20 01:24:14 +00:00
|
|
|
//Replace the orginal weapon with the 'usedTube' weapon
|
|
|
|
_unit addWeapon _replacementTube;
|
|
|
|
//Makes sure the used tube is still equiped
|
|
|
|
_unit selectWeapon _replacementTube;
|
|
|
|
//Re-add all attachments to the used tube
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
2015-02-20 01:32:41 +00:00
|
|
|
if (_x != "") then {_unit addSecondaryWeaponItem _x};
|
2015-08-09 03:25:19 +00:00
|
|
|
} count _items;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-20 01:24:14 +00:00
|
|
|
|
|
|
|
// AI - Remove the ai's missle launcher tube after the missle has exploded
|
2015-01-13 19:12:37 +00:00
|
|
|
if !([_unit] call EFUNC(common,isPlayer)) then {
|
2015-03-20 01:24:14 +00:00
|
|
|
[{
|
2015-08-10 07:51:14 +00:00
|
|
|
params ["_args","_idPFH"];
|
2015-08-09 03:25:19 +00:00
|
|
|
_args params ["_unit", "_tube", "_projectile"];
|
2015-03-20 01:24:14 +00:00
|
|
|
|
|
|
|
//don't do anything until projectile is null (exploded/max range)
|
|
|
|
if (isNull _projectile) then {
|
|
|
|
//Remove PFEH:
|
2015-11-30 15:45:20 +00:00
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-03-20 01:24:14 +00:00
|
|
|
|
|
|
|
//If (tube is dropped) OR (is dead) OR (is player) just exit
|
2016-01-06 21:42:02 +00:00
|
|
|
if (secondaryWeapon _unit != _tube || {!alive _unit} || {[_unit] call EFUNC(common,isPlayer)}) exitWith {};
|
2015-03-20 01:37:36 +00:00
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
//private _items = secondaryWeaponItems _unit;
|
|
|
|
private _container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
|
2015-03-20 01:24:14 +00:00
|
|
|
_container setPosAsl (getPosAsl _unit);
|
|
|
|
_container addWeaponCargoGlobal [_tube, 1];
|
2015-08-09 03:25:19 +00:00
|
|
|
|
2015-03-21 15:35:21 +00:00
|
|
|
//This will duplicate attachements, because we will be adding a weapon that may already have attachments on it
|
|
|
|
//We either need a way to add a clean weapon, or a way to add a fully configured weapon to a container:
|
|
|
|
// {
|
|
|
|
// if (_x != "") then {_container addItemCargoGlobal [_x, 1];};
|
|
|
|
// } forEach _items;
|
2015-08-09 03:25:19 +00:00
|
|
|
|
2015-03-20 01:24:14 +00:00
|
|
|
_unit removeWeaponGlobal _tube;
|
|
|
|
};
|
|
|
|
}, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|