diff --git a/addons/sandbag/CfgEventHandlers.hpp b/addons/sandbag/CfgEventHandlers.hpp index fc20af2e083..d17adf2696d 100644 --- a/addons/sandbag/CfgEventHandlers.hpp +++ b/addons/sandbag/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreStart_EventHandlers { class ADDON { init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); @@ -6,9 +5,9 @@ class Extended_PreStart_EventHandlers { }; class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); - }; + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; }; class Extended_PostInit_EventHandlers { @@ -17,22 +16,6 @@ class Extended_PostInit_EventHandlers { }; }; -class Extended_Init_EventHandlers { - class ACE_SandbagObject { - class ADDON { - init = QUOTE(call EFUNC(dragging,initObject)); - }; - }; -}; - -class Extended_Killed_EventHandlers { - class CAManBase { - class ADDON { - killed = QUOTE(call FUNC(handleKilled)); - }; - }; -}; - class Extended_DisplayLoad_EventHandlers { class RscDisplayMission { ADDON = QUOTE(call COMPILE_SCRIPT(XEH_missionDisplayLoad)); diff --git a/addons/sandbag/CfgVehicles.hpp b/addons/sandbag/CfgVehicles.hpp index 3fce474c247..25ce2e37a41 100644 --- a/addons/sandbag/CfgVehicles.hpp +++ b/addons/sandbag/CfgVehicles.hpp @@ -1,4 +1,3 @@ - class CBA_Extended_EventHandlers_base; class CfgVehicles { @@ -6,10 +5,10 @@ class CfgVehicles { class CAManBase: Man { class ACE_SelfActions { class GVAR(place) { - displayName = CSTRING(DeploySandbag); + displayName = CSTRING(deploySandbag); condition = QUOTE(call FUNC(canDeploy)); - //wait a frame to handle "Do When releasing action menu key" option - statement = QUOTE([ARR_2({_this call FUNC(deploy)},_this)] call CBA_fnc_execNextFrame); + // Wait a frame to handle "Do When releasing action menu key" option + statement = QUOTE([ARR_2(LINKFUNC(deploy),_this)] call CBA_fnc_execNextFrame); exceptions[] = {"isNotSwimming"}; showDisabled = 0; icon = QPATHTOF(UI\icon_sandbag_ca.paa); @@ -32,20 +31,6 @@ class CfgVehicles { }; }; - /*class ACE_Item_Sandbag: Item_Base_F { - author = ECSTRING(common,ACETeam); - scope = 2; - scopeCurator = 2; - displayName = CSTRING(sandbag_displayName); - vehicleClass = "Items"; - class TransportItems { - class ACE_Sandbag { - name = "ACE_Sandbag"; - count = 1; - }; - }; - };*/ - class ThingX; class ACE_SandbagObject: ThingX { class EventHandlers { @@ -66,14 +51,16 @@ class CfgVehicles { accuracy = 1000; destrType = "DestructDefault"; + EGVAR(dragging,canCarry) = 1; + class DestructionEffects {}; class Damage { tex[] = {}; mat[] = { - "z\ace\addons\sandbag\data\bag_destruct.rvmat", - "z\ace\addons\sandbag\data\bag_destruct.rvmat", - "z\ace\addons\sandbag\data\bag_destruct.rvmat" + QPATHTO_R(data\bag_destruct.rvmat), + QPATHTO_R(data\bag_destruct.rvmat), + QPATHTO_R(data\bag_destruct.rvmat) }; }; @@ -81,13 +68,13 @@ class CfgVehicles { class ACE_MainActions { selection = ""; distance = 5; - condition = "(true)"; + condition = "true"; class ACE_PickUp { selection = ""; displayName = CSTRING(PICKUPSB); distance = 4; - condition = QUOTE(!(_player getVariable [ARR_2(QUOTE(QGVAR(isUsingSandbag)),false)])); + condition = QUOTE(!(_player getVariable [ARR_2(QQGVAR(isUsingSandbag),false)])); statement = QUOTE([ARR_2(_player,_target)] call FUNC(pickup)); showDisabled = 0; exceptions[] = {}; @@ -104,6 +91,10 @@ class CfgVehicles { class ACE_SandbagObject_NoGeo: ACE_SandbagObject { scope = 1; model = QPATHTOF(data\ace_sandbag_nogeo.p3d); + + class EventHandlers: EventHandlers { + class CBA_Extended_EventHandlers {}; + }; }; class Box_NATO_Support_F; diff --git a/addons/sandbag/CfgWeapons.hpp b/addons/sandbag/CfgWeapons.hpp index 72336e8bbfe..f76bcac1fa9 100644 --- a/addons/sandbag/CfgWeapons.hpp +++ b/addons/sandbag/CfgWeapons.hpp @@ -1,4 +1,3 @@ - class CfgWeapons { class ACE_ItemCore; class CBA_MiscItem_ItemInfo; @@ -14,17 +13,4 @@ class CfgWeapons { mass = 8; }; }; - /* - class ACE_Sandbag: ACE_ItemCore { - author = ECSTRING(common,ACETeam); - scope = 2; - displayName = CSTRING(sandbag_displayName); - model = QPATHTOF(data\ace_sandbag_build.p3d); - picture = QPATHTOF(data\m_sandbag_ca.paa); - - class ItemInfo: CBA_MiscItem_ItemInfo { - mass = 160; - }; - }; - */ }; diff --git a/addons/sandbag/XEH_PREP.hpp b/addons/sandbag/XEH_PREP.hpp index 399655a8914..891b21e24f3 100644 --- a/addons/sandbag/XEH_PREP.hpp +++ b/addons/sandbag/XEH_PREP.hpp @@ -1,12 +1,6 @@ - PREP(canDeploy); PREP(deploy); PREP(deployCancel); PREP(deployConfirm); -PREP(handleInteractMenuOpened); -PREP(handleKilled); -PREP(handlePlayerChanged); -PREP(handlePlayerInventoryChanged); PREP(handleScrollWheel); -PREP(handleUnconscious); PREP(pickup); diff --git a/addons/sandbag/XEH_missionDisplayLoad.sqf b/addons/sandbag/XEH_missionDisplayLoad.sqf index cb85ffb9fbf..c4966178335 100644 --- a/addons/sandbag/XEH_missionDisplayLoad.sqf +++ b/addons/sandbag/XEH_missionDisplayLoad.sqf @@ -3,4 +3,9 @@ params ["_display"]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; -_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(deployCancel)}]; +_display displayAddEventHandler ["MouseButtonDown", { + // Right clicking cancels deployment + if (_this select 1 == 1) then { + ACE_player call FUNC(deployCancel); + }; +}]; diff --git a/addons/sandbag/XEH_postInit.sqf b/addons/sandbag/XEH_postInit.sqf index 8185bb31074..1bcb3a90685 100644 --- a/addons/sandbag/XEH_postInit.sqf +++ b/addons/sandbag/XEH_postInit.sqf @@ -1,25 +1,89 @@ #include "script_component.hpp" if (isServer) then { - // Cancel deploy on hard disconnection. Function is identical to killed - addMissionEventHandler ["HandleDisconnect", {call FUNC(handleKilled)}]; + // Cancel deploy on hard disconnection. Function is identical to interrupted + addMissionEventHandler ["HandleDisconnect", {(_this select 0) call FUNC(deployCancel)}]; }; +// To be safe for FUNC(deployCancel) if called by dedicated server +GVAR(deployPFH) = -1; + if (!hasInterface) exitWith {}; -GVAR(sandBag) = objNull; -GVAR(deployPFH) = -1; +GVAR(deployDistance) = -1; GVAR(deployDirection) = 0; +GVAR(deployHeight) = 0; + +// Cancel deploy on player change. This does work when returning to lobby, but not when hard disconnecting +["unit", { + params ["_newPlayer", "_oldPlayer"]; + + _newPlayer call FUNC(deployCancel); + _oldPlayer call FUNC(deployCancel); +}] call CBA_fnc_addPlayerEventHandler; + +// Handle loadout change +["loadout", { + params ["_unit"]; + + // If the unit still has a sandbag, don't cancel deployment + if ([_unit, "ACE_Sandbag_empty"] call EFUNC(common,hasItem)) exitWith {}; + + _unit call FUNC(deployCancel); +}] call CBA_fnc_addPlayerEventHandler; + +["vehicle", {(_this select 0) call FUNC(deployCancel)}] call CBA_fnc_addPlayerEventHandler; +["weapon", {(_this select 0) call FUNC(deployCancel)}] call CBA_fnc_addPlayerEventHandler; +["featureCamera", {(_this select 0) call FUNC(deployCancel)}] call CBA_fnc_addPlayerEventHandler; + +// Handle death +[QGVAR(killedEH), "Killed", {(_this select 0) call FUNC(deployCancel)}] call CBA_fnc_addBISPlayerEventHandler; -// Cancel deploy sandbag if interact menu opened -["ace_interactMenuOpened", {[ACE_player] call FUNC(handleInteractMenuOpened)}] call CBA_fnc_addEventHandler; +// Cancel object deployment if interact menu opened +["ace_interactMenuOpened", {ACE_player call FUNC(deployCancel)}] call CBA_fnc_addEventHandler; -// Cancel deploy on player change. This does work when returning to lobby, but not when hard disconnecting. -["unit", LINKFUNC(handlePlayerChanged)] call CBA_fnc_addPlayerEventHandler; -["loadout", LINKFUNC(handlePlayerInventoryChanged)] call CBA_fnc_addPlayerEventHandler; -["vehicle", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call CBA_fnc_addPlayerEventHandler; +// Handle falling unconscious while trying to deploy +["ace_unconscious", { + params ["_unit", "_isUnconscious"]; -// handle waking up dragged unit and falling unconscious while dragging -["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler; + // Since global event, let clients handle local objects themselves + if !(_isUnconscious && {local _unit}) exitWith {}; -//@todo Captivity? + _unit call FUNC(deployCancel); +}] call CBA_fnc_addEventHandler; + +// Handle surrendering and handcuffing +["ace_captiveStatusChanged", { + params ["_unit", "_state"]; + + // Since global event, let clients handle local objects themselves + if !(_state && {local _unit}) exitWith {}; + + _unit call FUNC(deployCancel); +}] call CBA_fnc_addEventHandler; + +if (["ace_dragging"] call EFUNC(common,isModLoaded)) then { + // When carrying starts, update surrounding sandbags + [QEGVAR(dragging,setupCarry), { + params ["", "_target"]; + + if !(_target isKindOf "ACE_SandbagObject") exitWith {}; + + // Force PhysX update + { + [QEGVAR(common,awake), [_x, true]] call CBA_fnc_globalEvent; + } forEach ((_target nearObjects ["ACE_SandbagObject", 5]) - [_target]); + }] call CBA_fnc_addEventHandler; + + // When carrying stops, update surrounding sandbags + [QEGVAR(dragging,stoppedCarry), { + params ["", "_target", "_loadCargo"]; + + if (_loadCargo || {!(_target isKindOf "ACE_SandbagObject")}) exitWith {}; + + // Force PhysX update + { + [QEGVAR(common,awake), [_x, true]] call CBA_fnc_globalEvent; + } forEach ((_target nearObjects ["ACE_SandbagObject", 5]) - [_target]); + }] call CBA_fnc_addEventHandler; +}; diff --git a/addons/sandbag/functions/fnc_canDeploy.sqf b/addons/sandbag/functions/fnc_canDeploy.sqf index bc0751d6b08..803a9db9b21 100644 --- a/addons/sandbag/functions/fnc_canDeploy.sqf +++ b/addons/sandbag/functions/fnc_canDeploy.sqf @@ -10,13 +10,11 @@ * Can deploy * * Example: - * [ACE_player] call ace_sandbag_fnc_canDeploy + * player call ace_sandbag_fnc_canDeploy * * Public: No */ params ["_unit"]; -if !("ACE_Sandbag_empty" in (_unit call EFUNC(common,uniqueItems))) exitWith {false}; - -_unit call EFUNC(common,canDig) +([_unit, "ACE_Sandbag_empty"] call EFUNC(common,hasItem)) && {!(_unit getVariable [QGVAR(isUsingSandbag), false])} && {_unit call EFUNC(common,canDig)} // return diff --git a/addons/sandbag/functions/fnc_deploy.sqf b/addons/sandbag/functions/fnc_deploy.sqf index dd055504631..431ecc94f47 100644 --- a/addons/sandbag/functions/fnc_deploy.sqf +++ b/addons/sandbag/functions/fnc_deploy.sqf @@ -1,55 +1,57 @@ #include "..\script_component.hpp" /* * Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support - * Starts the deploy process for sandbags. + * Starts the deployment process for sandbags. * * Arguments: - * 0: unit + * 0: Unit * * Return Value: * None * * Example: - * [ACE_player] call ace_sandbag_fnc_deploy + * player call ace_sandbag_fnc_deploy * * Public: No */ params ["_unit"]; -// prevent the placing unit from running +// Prevent the placing unit from running [_unit, "forceWalk", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set); [_unit, "blockThrow", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set); -// create the sandbag +// Create the sandbag private _sandBag = createVehicle ["ACE_SandbagObject_NoGeo", [0, 0, 0], [], 0, "NONE"]; -GVAR(sandBag) = _sandBag; - -// prevent collisions with sandbag +// Prevent collisions with sandbag [QEGVAR(common,enableSimulationGlobal), [_sandBag, false]] call CBA_fnc_serverEvent; +GVAR(deployDistance) = 1; GVAR(deployDirection) = 0; +GVAR(deployHeight) = 0; -// pfh that runs while the deployment is in progress +// PFH that runs while the deployment is in progress GVAR(deployPFH) = [{ (_this select 0) params ["_unit", "_sandBag"]; if (isNull _sandBag) exitWith { - [_unit] call FUNC(deployCancel); + _unit call FUNC(deployCancel); }; - _sandBag setPosASL (eyePos _unit vectorAdd (positionCameraToWorld [0, 0, 1] vectorDiff positionCameraToWorld [0, 0, 0])); + _sandBag setPosASL (eyePos _unit vectorAdd (positionCameraToWorld [0, GVAR(deployHeight), GVAR(deployDistance)] vectorDiff positionCameraToWorld [0, 0, 0])); _sandBag setDir (GVAR(deployDirection) + getDir _unit); }, 0, [_unit, _sandBag]] call CBA_fnc_addPerFrameHandler; -// add mouse button action and hint -[localize LSTRING(ConfirmDeployment), localize LSTRING(CancelDeployment), localize LSTRING(ScrollAction)] call EFUNC(interaction,showMouseHint); +// Add mouse button action and hint +[LLSTRING(confirmDeployment), LLSTRING(cancelDeployment), LLSTRING(scrollAction)] call EFUNC(interaction,showMouseHint); -_unit setVariable [QGVAR(Deploy), [ - _unit, "DefaultAction", +// Intercept left mouse button to confirm sandbag deployment +_unit setVariable [QGVAR(deploy), [ + _unit, + "DefaultAction", {GVAR(deployPFH) != -1}, - {[_this select 1] call FUNC(deployConfirm)} + {(_this select 1) call FUNC(deployConfirm)} ] call EFUNC(common,addActionEventHandler)]; -_unit setVariable [QGVAR(isDeploying), true, true]; +_unit setVariable [QGVAR(sandbag), _sandBag, true]; diff --git a/addons/sandbag/functions/fnc_deployCancel.sqf b/addons/sandbag/functions/fnc_deployCancel.sqf index eff3400577c..76923a65535 100644 --- a/addons/sandbag/functions/fnc_deployCancel.sqf +++ b/addons/sandbag/functions/fnc_deployCancel.sqf @@ -1,40 +1,52 @@ #include "..\script_component.hpp" /* * Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support - * Cancels sandbag deployment + * Cancels sandbag deployment. * * Arguments: * 0: Unit - * 1: Key (1 for left mouse button) (default: 1) * * Return Value: * None * * Example: - * [ACE_player] call ace_sandbag_fnc_deployCancel + * player call ace_sandbag_fnc_deployCancel * * Public: No */ -params ["_unit", ["_key", 1]]; +params ["_unit"]; -if (_key != 1 || {GVAR(deployPFH) == -1}) exitWith {}; +if (isNull _unit) exitWith {}; -// enable running again +// Enable running again [_unit, "forceWalk", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set); [_unit, "blockThrow", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set); -// delete placement dummy -deleteVehicle GVAR(sandBag); +private _sandbag = _unit getVariable [QGVAR(sandBag), objNull]; -// remove deployment pfh -[GVAR(deployPFH)] call CBA_fnc_removePerFrameHandler; -GVAR(deployPFH) = -1; +// Delete placement dummy, if present (don't early exit, in case dummy was deleted by something else, as still need to clean up) +if (!isNull _sandbag) then { + deleteVehicle _sandbag; -// remove mouse button actions -call EFUNC(interaction,hideMouseHint); + _unit setVariable [QGVAR(sandbag), nil, true]; +}; + +// Stop intercepting left mouse button +private _ehID = _unit getVariable [QGVAR(deploy), -1]; + +if (_ehID != -1) then { + [_unit, "DefaultAction", _ehID] call EFUNC(common,removeActionEventHandler); -[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); -[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); + _unit setVariable [QGVAR(deploy), nil]; +}; -_unit setVariable [QGVAR(isDeploying), false, true]; +// Only remove deployment PFH if unit is current player +if (_unit != ACE_player || {GVAR(deployPFH) == -1}) exitWith {}; + +// Remove deployment PFH +GVAR(deployPFH) call CBA_fnc_removePerFrameHandler; +GVAR(deployPFH) = -1; + +// Remove mouse button actions +call EFUNC(interaction,hideMouseHint); diff --git a/addons/sandbag/functions/fnc_deployConfirm.sqf b/addons/sandbag/functions/fnc_deployConfirm.sqf index ef2aafd97c7..e4b34aef085 100644 --- a/addons/sandbag/functions/fnc_deployConfirm.sqf +++ b/addons/sandbag/functions/fnc_deployConfirm.sqf @@ -1,57 +1,58 @@ #include "..\script_component.hpp" /* * Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support - * Confirms sandbag deployment + * Confirms sandbag deployment. * * Arguments: - * 0: unit + * 0: Unit * * Return Value: * None * * Example: - * [ACE_player] call ace_sandbag_fnc_deployConfirm + * player call ace_sandbag_fnc_deployConfirm * * Public: No */ params ["_unit"]; -// enable running again -[_unit, "forceWalk", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set); -[_unit, "blockThrow", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set); +private _sandbag = _unit getVariable [QGVAR(sandBag), objNull]; -// remove sandbag from inventory -_unit removeItem "ACE_Sandbag_empty"; +// Save placement dummy data; Need to check now, as it's deleted later +private _dummyDeleted = isNull _sandbag; +private _position = getPosASL _sandbag; +private _direction = getDir _sandbag; -// delete placement dummy and create real sandbag -[{ - if (isNull GVAR(sandBag)) exitWith {}; +// Clean up hints and dummy +_unit call FUNC(deployCancel); - params ["_unit"]; +// Make sure unit still has empty sandbag, otherwise quit +if (_dummyDeleted || {!alive _unit} || {!([_unit, "ACE_Sandbag_empty"] call EFUNC(common,hasItem))}) exitWith {}; - private _position = getPosASL GVAR(sandBag); - private _direction = getDir GVAR(sandBag); +_unit setVariable [QGVAR(isUsingSandbag), true]; - deleteVehicle GVAR(sandBag); +// Play animation +[_unit, "PutDown"] call EFUNC(common,doGesture); - private _sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"]; - _sandBag setPosASL _position; - _sandBag setDir _direction; +[{ + params ["_unit", "_direction", "_position"]; - GVAR(sandBag) = objNull; -}, [_unit], 1] call CBA_fnc_waitAndExecute; + _unit setVariable [QGVAR(isUsingSandbag), false]; -// remove deployment pfh -[GVAR(deployPFH)] call CBA_fnc_removePerFrameHandler; -GVAR(deployPFH) = -1; + // Make sure unit still has empty sandbag, otherwise quit + if (!alive _unit || {!([_unit, "ACE_Sandbag_empty"] call EFUNC(common,hasItem))}) exitWith {}; -// remove mouse button actions -call EFUNC(interaction,hideMouseHint); + // Remove sandbag from inventory + _unit removeItem "ACE_Sandbag_empty"; -[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); + // Create real sandbag + private _sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"]; -// play animation -[_unit, "PutDown"] call EFUNC(common,doGesture); + _sandBag setDir _direction; + _sandBag setPosASL _position; -_unit setVariable [QGVAR(isDeploying), false, true]; + // Prevent collision damage + [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; + [QEGVAR(common,fixCollision), _sandBag] call CBA_fnc_localEvent; +}, [_unit, _direction, _position], 0.5] call CBA_fnc_waitAndExecute; diff --git a/addons/sandbag/functions/fnc_handleInteractMenuOpened.sqf b/addons/sandbag/functions/fnc_handleInteractMenuOpened.sqf deleted file mode 100644 index cb6cb4ddf14..00000000000 --- a/addons/sandbag/functions/fnc_handleInteractMenuOpened.sqf +++ /dev/null @@ -1,22 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: commy2 - * Handle opening of interaction menu. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [bob] call ace_sandbag_fnc_handleInteractMenuOpened - * - * Public: No -*/ - -params ["_unit"]; - -if (_unit getVariable [QGVAR(isDeploying), false]) then { - [_unit] call FUNC(deployCancel); -}; diff --git a/addons/sandbag/functions/fnc_handleKilled.sqf b/addons/sandbag/functions/fnc_handleKilled.sqf deleted file mode 100644 index 100ed2e930c..00000000000 --- a/addons/sandbag/functions/fnc_handleKilled.sqf +++ /dev/null @@ -1,22 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: commy2 - * Handle death. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [bob] call ace_sandbag_fnc_handleKilled - * - * Public: No -*/ - -params ["_unit"]; - -if (_unit getVariable [QGVAR(isDeploying), false]) then { - [_unit] call FUNC(deployCancel); -}; diff --git a/addons/sandbag/functions/fnc_handlePlayerChanged.sqf b/addons/sandbag/functions/fnc_handlePlayerChanged.sqf deleted file mode 100644 index 6882ed553e9..00000000000 --- a/addons/sandbag/functions/fnc_handlePlayerChanged.sqf +++ /dev/null @@ -1,27 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: commy2 - * Handle player changes. - * - * Arguments: - * 0: New Player Unit - * 1: Old Player Unit - * - * Return Value: - * None - * - * Example: - * [bob, kevin] call ace_sandbag_fnc_handlePlayerChanged - * - * Public: No -*/ - -params ["_newPlayer", "_oldPlayer"]; - -if (_newPlayer getVariable [QGVAR(isDeploying), false]) then { - [_newPlayer] call FUNC(deployCancel); -}; - -if (_oldPlayer getVariable [QGVAR(isDeploying), false]) then { - [_oldPlayer] call FUNC(deployCancel); -}; diff --git a/addons/sandbag/functions/fnc_handlePlayerInventoryChanged.sqf b/addons/sandbag/functions/fnc_handlePlayerInventoryChanged.sqf deleted file mode 100644 index 1e557cba1f5..00000000000 --- a/addons/sandbag/functions/fnc_handlePlayerInventoryChanged.sqf +++ /dev/null @@ -1,25 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: commy2 - * Handle the InventoryChanged event. - * - * Arguments: - * 0: Unit - * 1: Weapon - * - * Return Value: - * None - * - * Example: - * [bob, "weapon"] call ace_sandbag_fnc_handlePlayerInventoryChanged - * - * Public: No -*/ - -params ["_unit"]; - -if (_unit getVariable [QGVAR(isDeploying), false]) then { - if !("ACE_Sandbag_empty" in (_unit call EFUNC(common,uniqueItems))) then { - [_unit] call FUNC(deployCancel); - }; -}; diff --git a/addons/sandbag/functions/fnc_handleScrollWheel.sqf b/addons/sandbag/functions/fnc_handleScrollWheel.sqf index 3a4f00a502e..86d48586275 100644 --- a/addons/sandbag/functions/fnc_handleScrollWheel.sqf +++ b/addons/sandbag/functions/fnc_handleScrollWheel.sqf @@ -1,24 +1,41 @@ #include "..\script_component.hpp" /* - * Author: Garth 'L-H' de Wet, Ruthberg - * Handles sandbag rotation + * Author: Garth 'L-H' de Wet, Ruthberg, Smith + * Handles sandbag rotation. * * Arguments: - * 0: scroll amount + * 0: Scroll amount * * Return Value: - * handled + * If the scroll was handled * * Example: - * [1.2] call ace_sandbag_fnc_handleScrollWheel + * 1.2 call ace_sandbag_fnc_handleScrollWheel * * Public: No */ -if (GVAR(deployPFH) == -1) exitWith {false}; +if (GVAR(deployPFH) == -1) exitWith { + false // return +}; params ["_scroll"]; -GVAR(deployDirection) = GVAR(deployDirection) + (_scroll * 5); +// Change direction +if (CBA_events_control) exitWith { + GVAR(deployDirection) = GVAR(deployDirection) + (_scroll * 5); -true + true // return +}; + +// Change height +if (CBA_events_alt) exitWith { + GVAR(deployHeight) = 1.5 min (-1.5 max (GVAR(deployHeight) + (_scroll * 0.1))); + + true // return +}; + +// Change distance +GVAR(deployDistance) = 1.5 min (0.36 max (GVAR(deployDistance) + (_scroll * 0.1))); + +true // return diff --git a/addons/sandbag/functions/fnc_handleUnconscious.sqf b/addons/sandbag/functions/fnc_handleUnconscious.sqf deleted file mode 100644 index 3ad90a0cc50..00000000000 --- a/addons/sandbag/functions/fnc_handleUnconscious.sqf +++ /dev/null @@ -1,24 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: commy2 - * Handle unconsciousness. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [bob] call ace_sandbag_fnc_handleUnconscious - * - * Public: No -*/ - -params ["_unit"]; - -if (!local _unit) exitWith {}; - -if (_unit getVariable [QGVAR(isDeploying), false]) then { - [_unit] call FUNC(deployCancel); -}; diff --git a/addons/sandbag/functions/fnc_pickup.sqf b/addons/sandbag/functions/fnc_pickup.sqf index 07a6285e685..f16292f8895 100644 --- a/addons/sandbag/functions/fnc_pickup.sqf +++ b/addons/sandbag/functions/fnc_pickup.sqf @@ -1,17 +1,17 @@ #include "..\script_component.hpp" /* * Author: Ruthberg - * Pick up sandbag + * Picks up a sandbag. * * Arguments: - * 0: unit - * 1: sandbag + * 0: Unit + * 1: Sandbag * * Return Value: * None * * Example: - * [_unit, _sandbag] call ace_sandbag_fnc_pickup + * [player, cursorObject] call ace_sandbag_fnc_pickup * * Public: No */ @@ -27,14 +27,17 @@ _unit setVariable [QGVAR(isUsingSandbag), true]; _unit setVariable [QGVAR(isUsingSandbag), false]; - if (isNull _sandbag) exitWith {}; + // If another unit picked up the sandbag or otherwise sandbag no longer present, exit + if (!alive _unit || {!alive _sandbag}) exitWith {}; + + private _nearSandbags = (_sandbag nearObjects ["ACE_SandbagObject", 5]) - [_sandbag]; deleteVehicle _sandbag; - // Force physx update + // Force PhysX update { - _x setPosASL (getPosASL _x); - } forEach (_unit nearObjects ["ACE_SandbagObject", 5]); + [QEGVAR(common,awake), [_x, true]] call CBA_fnc_globalEvent; + } forEach _nearSandbags; [_unit, "ACE_Sandbag_empty"] call EFUNC(common,addToInventory); -}, [_unit, _sandbag], 1.5] call CBA_fnc_waitAndExecute; +}, [_unit, _sandbag], 1] call CBA_fnc_waitAndExecute; diff --git a/addons/sandbag/stringtable.xml b/addons/sandbag/stringtable.xml index 8aadb390e88..e0f1122acd7 100644 --- a/addons/sandbag/stringtable.xml +++ b/addons/sandbag/stringtable.xml @@ -182,22 +182,20 @@ Ящик мішків із піском - Rotate - Otočit - Tourner - Girar - Rotazione - Obrót - Rotaciona - Bращать - Drehen - 돌리기 - 回転 - 旋轉 - 旋转 - Yönlendir - Forgatás - Обертати + Distance | (Ctrl + Scroll) Rotate | (Alt + Scroll) Height + Vzdálenost | (Ctrl + Kolečko myši) Otáčet | (Alt + Kolečko myši) Výška + Distance | (Ctrl + Scroll) Rotation | (Alt + Scroll) Hauteur + Distancia | (Ctrl + Scroll) Rotar | (Alt + Scroll) Altura + Distanza | (Ctrl + Rotellina) Ruota | (Alt + Rotellina) Altezza + Odległość | (Ctrl + Kółko myszy) obracanie | (Alt + Kółko myszy) Wysokość + Distância | (Ctrl + Scroll) Rotacionar | (Alt + Scroll) Altura + Дистанция | (Ctrl + Скролл) Крутить | (Alt + Скролл) Высота + Entfernung | (Strg + Scrollen) Drehen | (Alt + Scrollen) Höhe + 거리 | (컨트롤 + 스크롤) 회전 | (Alt + 스크롤) 고도 + 距離 | (Ctrl + スクロール) 回転 | (Alt + スクロール) 高さ + 距离 |(Ctrl + 鼠标滚轮)旋转 |(Alt + 鼠标滚轮)高度 + Mesafe | (Ctrl + Tekerlek) Döndür | (Alt + Tekerlek) Yükseklik + Дистанція | (Ctrl + Скрол) Крутити | (Alt + Скрол) Висота Sandbag (empty)