mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Cargo - paradrop fixes (#8203)
* Small fixes in ace_cargo
Makes paradropItem and unloadItem invoke event "ace_cargoUnloaded" with parameters _itemObject, _vehicle and "paradrop" or "unload" respectivelty.
paradropItem invoked said event but if item was classname it would send classname to event which is not particularly useful.
* Update XEH_postInit.sqf
Moved event invocation to unloadItem, this provides ability to always pass object to eventhandlers.
* code refactor
refactored according to https://github.com/acemod/ACE3/pull/8203#discussion_r610394484
* Update fnc_paradropItem.sqf
apply new fix
* Revert "Update fnc_paradropItem.sqf"
This reverts commit 3db5cc1910
.
* Update fnc_paradropItem.sqf
fixed hint that was broken by previous fixes
* style check
Co-authored-by: commy2 <commy-2@gmx.de>
* style check
Co-authored-by: commy2 <commy-2@gmx.de>
* naming convention
replaced object references called _item with _object.
* Update fnc_paradropItem.sqf
Co-authored-by: commy2 <commy-2@gmx.de>
This commit is contained in:
parent
c425b35c5f
commit
4726108c8e
@ -37,10 +37,6 @@
|
|||||||
|
|
||||||
[[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured);
|
[[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured);
|
||||||
|
|
||||||
if (_unloaded) then {
|
|
||||||
// Invoke listenable event
|
|
||||||
["ace_cargoUnloaded", [_item, _vehicle]] call CBA_fnc_globalEvent;
|
|
||||||
};
|
|
||||||
|
|
||||||
// TOOO maybe drag/carry the unloaded item?
|
// TOOO maybe drag/carry the unloaded item?
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
@ -38,68 +38,67 @@ TRACE_1("",_distBehind);
|
|||||||
private _posBehindVehicleAGL = _vehicle modelToWorld [0, _distBehind, -2];
|
private _posBehindVehicleAGL = _vehicle modelToWorld [0, _distBehind, -2];
|
||||||
|
|
||||||
|
|
||||||
private _itemObject = if (_item isEqualType objNull) then {
|
private _object = _item;
|
||||||
detach _item;
|
if (_item isEqualType objNull) then {
|
||||||
|
detach _object;
|
||||||
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
|
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
|
||||||
// do both on server to ensure they are executed in the correct order
|
// do both on server to ensure they are executed in the correct order
|
||||||
[QGVAR(serverUnload), [_item, _posBehindVehicleAGL]] call CBA_fnc_serverEvent;
|
[QGVAR(serverUnload), [_object, _posBehindVehicleAGL]] call CBA_fnc_serverEvent;
|
||||||
_item
|
|
||||||
} else {
|
} else {
|
||||||
private _newItem = createVehicle [_item, _posBehindVehicleAGL, [], 0, "NONE"];
|
_object = createVehicle [_item, _posBehindVehicleAGL, [], 0, "NONE"];
|
||||||
_newItem setPosASL (AGLtoASL _posBehindVehicleAGL);
|
_object setPosASL (AGLtoASL _posBehindVehicleAGL);
|
||||||
_newItem
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_itemObject setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vectorDir _vehicle)) vectorMultiply -5));
|
_object setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vectorDir _vehicle)) vectorMultiply -5));
|
||||||
|
|
||||||
// open parachute and ir light effect
|
// open parachute and ir light effect
|
||||||
[{
|
[{
|
||||||
params ["_item"];
|
params ["_object"];
|
||||||
|
|
||||||
if (isNull _item || {getPos _item select 2 < 1}) exitWith {};
|
if (isNull _object || {getPos _object select 2 < 1}) exitWith {};
|
||||||
|
|
||||||
private _parachute = createVehicle ["B_Parachute_02_F", [0,0,0], [], 0, "CAN_COLLIDE"];
|
private _parachute = createVehicle ["B_Parachute_02_F", [0,0,0], [], 0, "CAN_COLLIDE"];
|
||||||
|
|
||||||
// cannot use setPos on parachutes without them closing down
|
// cannot use setPos on parachutes without them closing down
|
||||||
_parachute attachTo [_item, [0,0,0]];
|
_parachute attachTo [_object, [0,0,0]];
|
||||||
detach _parachute;
|
detach _parachute;
|
||||||
|
|
||||||
private _velocity = velocity _item;
|
private _velocity = velocity _object;
|
||||||
|
|
||||||
_item attachTo [_parachute, [0,0,1]];
|
_object attachTo [_parachute, [0,0,1]];
|
||||||
_parachute setVelocity _velocity;
|
_parachute setVelocity _velocity;
|
||||||
|
|
||||||
if ((GVAR(disableParadropEffectsClasstypes) findIf {_item isKindOf _x}) == -1) then {
|
if ((GVAR(disableParadropEffectsClasstypes) findIf {_object isKindOf _x}) == -1) then {
|
||||||
private _light = "Chemlight_yellow" createVehicle [0,0,0];
|
private _light = "Chemlight_yellow" createVehicle [0,0,0];
|
||||||
_light attachTo [_item, [0,0,0]];
|
_light attachTo [_object, [0,0,0]];
|
||||||
};
|
};
|
||||||
|
|
||||||
}, [_itemObject], 0.7] call CBA_fnc_waitAndExecute;
|
}, [_object], 0.7] call CBA_fnc_waitAndExecute;
|
||||||
|
|
||||||
// smoke effect when crate landed
|
// smoke effect when crate landed
|
||||||
[{
|
[{
|
||||||
(_this select 0) params ["_item"];
|
(_this select 0) params ["_object"];
|
||||||
|
|
||||||
if (isNull _item) exitWith {
|
if (isNull _object) exitWith {
|
||||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (getPos _item select 2 < 1) then {
|
if (getPos _object select 2 < 1) then {
|
||||||
if ((GVAR(disableParadropEffectsClasstypes) findIf {_item isKindOf _x}) == -1) then {
|
if ((GVAR(disableParadropEffectsClasstypes) findIf {_object isKindOf _x}) == -1) then {
|
||||||
private _smoke = "SmokeshellYellow" createVehicle [0,0,0];
|
private _smoke = "SmokeshellYellow" createVehicle [0,0,0];
|
||||||
_smoke attachTo [_item, [0,0,0]];
|
_smoke attachTo [_object, [0,0,0]];
|
||||||
};
|
};
|
||||||
|
|
||||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
}, 1, [_itemObject]] call CBA_fnc_addPerFrameHandler;
|
}, 1, [_object]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
if (_showHint) then {
|
if (_showHint) then {
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
LSTRING(UnloadedItem),
|
LSTRING(UnloadedItem),
|
||||||
getText (configOf _itemObject >> "displayName"),
|
getText (configOf _object >> "displayName"),
|
||||||
getText (configOf _vehicle >> "displayName")
|
getText (configOf _vehicle >> "displayName")
|
||||||
],
|
],
|
||||||
3
|
3
|
||||||
@ -107,6 +106,6 @@ if (_showHint) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Invoke listenable event
|
// Invoke listenable event
|
||||||
["ace_cargoUnloaded", [_item, _vehicle, "paradrop"]] call CBA_fnc_globalEvent;
|
["ace_cargoUnloaded", [_object, _vehicle, "paradrop"]] call CBA_fnc_globalEvent;
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -47,14 +47,16 @@ private _space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
|||||||
private _itemSize = [_item] call FUNC(getSizeItem);
|
private _itemSize = [_item] call FUNC(getSizeItem);
|
||||||
_vehicle setVariable [QGVAR(space), (_space + _itemSize), true];
|
_vehicle setVariable [QGVAR(space), (_space + _itemSize), true];
|
||||||
|
|
||||||
if (_item isEqualType objNull) then {
|
private _object = _item;
|
||||||
detach _item;
|
if (_object isEqualType objNull) then {
|
||||||
|
detach _object;
|
||||||
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
|
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
|
||||||
// do both on server to ensure they are executed in the correct order
|
// do both on server to ensure they are executed in the correct order
|
||||||
[QGVAR(serverUnload), [_item, _emptyPosAGL]] call CBA_fnc_serverEvent;
|
[QGVAR(serverUnload), [_object, _emptyPosAGL]] call CBA_fnc_serverEvent;
|
||||||
} else {
|
} else {
|
||||||
private _newItem = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"];
|
_object = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"];
|
||||||
_newItem setPosASL (AGLtoASL _emptyPosAGL);
|
_object setPosASL (AGLtoASL _emptyPosAGL);
|
||||||
};
|
};
|
||||||
|
// Invoke listenable event
|
||||||
|
["ace_cargoUnloaded", [_object, _vehicle, "unload"]] call CBA_fnc_globalEvent;
|
||||||
true
|
true
|
||||||
|
Loading…
Reference in New Issue
Block a user