Code cleanup Backpacks

This commit is contained in:
commy2 2015-09-26 20:29:08 +02:00
parent f77242fce3
commit 9ae215704c
4 changed files with 27 additions and 23 deletions

View File

@ -1,3 +1,3 @@
#include "script_component.hpp" #include "script_component.hpp"
["backpackOpened", DFUNC(backpackOpened)] call EFUNC(common,addEventHandler); ["backpackOpened", {_this call FUNC(backpackOpened)}] call EFUNC(common,addEventHandler);

View File

@ -1,18 +1,19 @@
/* /*
* Author: commy2 * Author: commy2
* Someone opened your backpack. Play sound and camshake. Execute locally.
* *
* Someone opened your backpack. Execute locally. * Arguments:
*
* Argument:
* 0: Who accessed your inventory? (Object) * 0: Who accessed your inventory? (Object)
* 1: Unit that wields the backpack (Object) * 1: Unit that wields the backpack (Object)
* 2: The backpack object (Object) * 2: The backpack object (Object)
* *
* Return value: * Return Value:
* None. * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_sounds", "_position"];
params ["_target", "_backpack"]; params ["_target", "_backpack"];
// do cam shake if the target is the player // do cam shake if the target is the player
@ -20,7 +21,8 @@ if ([_target] call EFUNC(common,isPlayer)) then {
addCamShake [4, 0.5, 5]; addCamShake [4, 0.5, 5];
}; };
// play a rustling sound // play a zipper sound effect
private ["_sounds", "_position"];
_sounds = [ _sounds = [
/*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss", /*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss",
@ -32,8 +34,7 @@ _sounds = [
QUOTE(PATHTO_R(sounds\zip_out.wav)) QUOTE(PATHTO_R(sounds\zip_out.wav))
]; ];
_position = _target modelToWorldVisual (_target selectionPosition "Spine3"); _position = AGLToASL (_target modelToWorldVisual (_target selectionPosition "Spine3"));
_position = _position call EFUNC(common,positionToASL);
playSound3D [ playSound3D [
_sounds select floor random count _sounds, _sounds select floor random count _sounds,

View File

@ -1,23 +1,24 @@
/* /*
* Author: commy2 * 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: * Return Value:
* 0: A backpack (Object or String) * Boolean <BOOL>
* *
* Return value: * Public: Yes
* Boolean (Bool)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_config"];
params ["_backpack"]; params ["_backpack"];
if (typeName _backpack == "OBJECT") then { if (typeName _backpack == "OBJECT") then {
_backpack = typeOf _backpack; _backpack = typeOf _backpack;
}; };
private "_config";
_config = configFile >> "CfgVehicles" >> _backpack; _config = configFile >> "CfgVehicles" >> _backpack;
getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0} getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0} // return

View File

@ -1,13 +1,15 @@
/* /*
* Author: commy2 * 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: * Return Value:
* Input from "InventoryOpened" eventhandler
*
* Return value:
* false. Always open the inventory dialog. (Bool) * false. Always open the inventory dialog. (Bool)
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"