Replace Spawn/Sleep in attach

This commit is contained in:
PabstMirror 2015-01-13 03:06:24 -06:00
parent 252b9f6790
commit 073805148b
3 changed files with 30 additions and 12 deletions

View File

@ -4,4 +4,5 @@ PREP(attach);
PREP(canAttach); PREP(canAttach);
PREP(canDetach); PREP(canDetach);
PREP(detach); PREP(detach);
PREP(detachDelayFix);
PREP(openAttachUI); PREP(openAttachUI);

View File

@ -16,6 +16,7 @@ private ["_unit", "_itemName", "_count", "_attachedItem"];
_unit = _this select 0; _unit = _this select 0;
_itemName = _unit getVariable [QGVAR(ItemName), ""]; _itemName = _unit getVariable [QGVAR(ItemName), ""];
_attachedItem = _unit getVariable [QGVAR(Item), objNull];
// Check if unit has an attached item // Check if unit has an attached item
if (_itemName == "") exitWith {}; if (_itemName == "") exitWith {};
@ -29,19 +30,13 @@ if ((count items _unit) + (count magazines _unit) <= _count) exitWith {
if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") then { if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") then {
// Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle // Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle
[_unit getVariable QGVAR(Item), _unit] spawn { detach _attachedItem;
_attachedItem = _this select 0; _attachedItem setPos [getPos _unit select 0, getPos _unit select 1, ((getPos _unit select 2) - 1000)];
_unit = _this select 1; // Delete attached item after 0.5 seconds
detach _attachedItem; [FUNC(detachFix), 0.5, [_attachedItem, (time + 0.5)]] call CBA_fnc_addPerFrameHandler;
_attachedItem setPos [getPos _unit select 0, getPos _unit select 1, (getPos _unit select 2) -1000]; } else {
sleep 0.5;
deleteVehicle _attachedItem;
};
}
else
{
// Delete attached item // Delete attached item
deleteVehicle (_unit getVariable QGVAR(Item)); deleteVehicle _attachedItem;
}; };
// Reset unit variables // Reset unit variables

View File

@ -0,0 +1,22 @@
/*
Name: ACE_attach_fnc_detachFix
Author: Pabst Mirror
Description:
Waits then deletes the object. Fixes IR_Grenade's effect not disapearing.
Parameters:
0: ARRAY - [OBJECT - item, NUMBER - time to wait until]
1: NUMBER - CBA's PerFrameHandler ID
*/
_attachedItem = (_this select 0) select 0;
_waitUntilTime = (_this select 0) select 1;
if (time < _waitUntilTime) exitWith {};
deleteVehicle _attachedItem;
//Remove the frame handler
[(_this select 1)] call cba_fnc_removePerFrameHandler;