mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
106 lines
3.1 KiB
Plaintext
106 lines
3.1 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: marc_book, commy2, CAA-Picard
|
|
* Unload and paradrop object from plane or helicopter.
|
|
*
|
|
* Arguments:
|
|
* 0: Object <OBJECT>
|
|
* 1: Vehicle <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* Object unloaded <BOOL>
|
|
*
|
|
* Example:
|
|
* [object, vehicle] call ace_cargo_fnc_paradropItem
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_item", "_vehicle"];
|
|
TRACE_2("params",_item,_vehicle);
|
|
|
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
|
|
|
if !(_item in _loaded) exitWith {false};
|
|
|
|
// unload item from cargo
|
|
_loaded deleteAt (_loaded find _item);
|
|
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
|
|
|
private _cargoSpace = [_vehicle] call FUNC(getCargoSpaceLeft);
|
|
private _itemSize = [_item] call FUNC(getSizeItem);
|
|
_vehicle setVariable [QGVAR(space), (_cargoSpace + _itemSize), true];
|
|
|
|
(boundingBoxReal _vehicle) params ["_bb1", "_bb2"];
|
|
private _distBehind = ((_bb1 select 1) min (_bb2 select 1)) - 4; // 4 meters behind max bounding box
|
|
TRACE_1("",_distBehind);
|
|
private _posBehindVehicleAGL = _vehicle modelToWorld [0, _distBehind, -2];
|
|
|
|
|
|
private _itemObject = if (_item isEqualType objNull) then {
|
|
detach _item;
|
|
// 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
|
|
[QGVAR(serverUnload), [_item, _posBehindVehicleAGL]] call CBA_fnc_serverEvent;
|
|
_item
|
|
} else {
|
|
private _newItem = createVehicle [_item, _posBehindVehicleAGL, [], 0, "NONE"];
|
|
_newItem setPosASL (AGLtoASL _posBehindVehicleAGL);
|
|
_newItem
|
|
};
|
|
|
|
_itemObject setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vectorDir _vehicle)) vectorMultiply -5));
|
|
|
|
// open parachute and ir light effect
|
|
[{
|
|
params ["_item"];
|
|
|
|
if (isNull _item || {getPos _item select 2 < 1}) exitWith {};
|
|
|
|
private _parachute = createVehicle ["B_Parachute_02_F", [0,0,0], [], 0, "CAN_COLLIDE"];
|
|
|
|
// cannot use setPos on parachutes without them closing down
|
|
_parachute attachTo [_item, [0,0,0]];
|
|
detach _parachute;
|
|
|
|
private _velocity = velocity _item;
|
|
|
|
_item attachTo [_parachute, [0,0,1]];
|
|
_parachute setVelocity _velocity;
|
|
|
|
private _light = "Chemlight_yellow" createVehicle [0,0,0];
|
|
_light attachTo [_item, [0,0,0]];
|
|
|
|
}, [_itemObject], 0.7] call CBA_fnc_waitAndExecute;
|
|
|
|
// smoke effect when crate landed
|
|
[{
|
|
(_this select 0) params ["_item"];
|
|
|
|
if (isNull _item) exitWith {
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
};
|
|
|
|
if (getPos _item select 2 < 1) then {
|
|
private _smoke = "SmokeshellYellow" createVehicle [0,0,0];
|
|
_smoke attachTo [_item, [0,0,0]];
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
};
|
|
|
|
}, 1, [_itemObject]] call CBA_fnc_addPerFrameHandler;
|
|
|
|
[
|
|
[
|
|
LSTRING(UnloadedItem),
|
|
getText (configFile >> "CfgVehicles" >> typeOf _itemObject >> "displayName"),
|
|
getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName")
|
|
],
|
|
3
|
|
] call EFUNC(common,displayTextStructured);
|
|
|
|
// Invoke listenable event
|
|
["ace_cargoUnloaded", [_item, _vehicle, "paradrop"]] call CBA_fnc_globalEvent;
|
|
|
|
true
|