Skip to content

Commit

Permalink
Merge pull request #2607 from acemod/340cleanupBackpacks
Browse files Browse the repository at this point in the history
Code cleanup Backpacks
  • Loading branch information
commy2 committed Sep 27, 2015
2 parents 1a5f65e + 9ae2157 commit af24428
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion addons/backpacks/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "script_component.hpp"

["backpackOpened", DFUNC(backpackOpened)] call EFUNC(common,addEventHandler);
["backpackOpened", {_this call FUNC(backpackOpened)}] call EFUNC(common,addEventHandler);
19 changes: 10 additions & 9 deletions addons/backpacks/functions/fnc_backpackOpened.sqf
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
/*
* Author: commy2
* Someone opened your backpack. Play sound and camshake. Execute locally.
*
* Someone opened your backpack. Execute locally.
*
* Argument:
* Arguments:
* 0: Who accessed your inventory? (Object)
* 1: Unit that wields the backpack (Object)
* 2: The backpack object (Object)
*
* Return value:
* None.
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_sounds", "_position"];

params ["_target", "_backpack"];

// do cam shake if the target is the player
if ([_target] call EFUNC(common,isPlayer)) then {
addCamShake [4, 0.5, 5];
};

// play a rustling sound
// play a zipper sound effect
private ["_sounds", "_position"];

_sounds = [
/*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss",
Expand All @@ -32,8 +34,7 @@ _sounds = [
QUOTE(PATHTO_R(sounds\zip_out.wav))
];

_position = _target modelToWorldVisual (_target selectionPosition "Spine3");
_position = _position call EFUNC(common,positionToASL);
_position = AGLToASL (_target modelToWorldVisual (_target selectionPosition "Spine3"));

playSound3D [
_sounds select floor random count _sounds,
Expand Down
15 changes: 8 additions & 7 deletions addons/backpacks/functions/fnc_isBackpack.sqf
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/*
* Author: commy2
* Check if the given backpack is an actual backpack that can store items. Parachute, static weapon packs, etc. will return false.
*
* Check if the given backpack is an actual backpack that can store items. Parachute backpacks will return false for example.
* Arguments:
* 0: Backpack <OBJECT, STRING>
*
* Argument:
* 0: A backpack (Object or String)
* Return Value:
* Boolean <BOOL>
*
* Return value:
* Boolean (Bool)
* Public: Yes
*/
#include "script_component.hpp"

private ["_config"];
params ["_backpack"];

if (typeName _backpack == "OBJECT") then {
_backpack = typeOf _backpack;
};

private "_config";
_config = configFile >> "CfgVehicles" >> _backpack;

getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0}
getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0} // return
14 changes: 8 additions & 6 deletions addons/backpacks/functions/fnc_onOpenInventory.sqf
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/*
* Author: commy2
* Handle the open inventory event. Camshake and sound on target client.
*
* Handle the open inventory event. Display message on target client.
* Arguments:
* 0: Unit <OBJECT>
* 1: Backpack <OBJECT>
*
* Argument:
* Input from "InventoryOpened" eventhandler
*
* Return value:
* Return Value:
* false. Always open the inventory dialog. (Bool)
*
* Public: No
*/
#include "script_component.hpp"

params ["_unit","_backpack"];
params ["_unit", "_backpack"];

// exit if the target is not a real backpack, i.e. parachute, static weapon bag etc.
if !([_backpack] call FUNC(isBackpack)) exitWith {false};
Expand Down

0 comments on commit af24428

Please sign in to comment.