Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions addons/sandbag/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
};
};

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 {
Expand All @@ -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));
Expand Down
37 changes: 14 additions & 23 deletions addons/sandbag/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

class CBA_Extended_EventHandlers_base;

class CfgVehicles {
class Man;
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);
Expand All @@ -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 {
Expand All @@ -66,28 +51,30 @@ 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)
};
};

class ACE_Actions {
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[] = {};
Expand All @@ -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;
Expand Down
14 changes: 0 additions & 14 deletions addons/sandbag/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class CfgWeapons {
class ACE_ItemCore;
class CBA_MiscItem_ItemInfo;
Expand All @@ -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;
};
};
*/
};
6 changes: 0 additions & 6 deletions addons/sandbag/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -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);
7 changes: 6 additions & 1 deletion addons/sandbag/XEH_missionDisplayLoad.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}];
90 changes: 77 additions & 13 deletions addons/sandbag/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -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;
};
6 changes: 2 additions & 4 deletions addons/sandbag/functions/fnc_canDeploy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
* Can deploy <BOOL>
*
* 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
36 changes: 19 additions & 17 deletions addons/sandbag/functions/fnc_deploy.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
* 0: Unit <OBJECT>
*
* 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];
Loading