Updated parameterization in Backpack module.

This commit is contained in:
jokoho48 2015-08-05 01:12:55 +02:00
parent 275b0c4300
commit 57d484d382
3 changed files with 23 additions and 27 deletions

View File

@ -2,18 +2,18 @@
* Author: commy2 * Author: commy2
* *
* Someone opened your backpack. Execute locally. * Someone opened your backpack. Execute locally.
* *
* Argument: * 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.
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_sounds", "_position"];
PARAMS_3(_unit,_target,_backpack); params ["_target", "_backpack"];
// do cam shake if the target is the player // do cam shake if the target is the player
if ([_target] call EFUNC(common,isPlayer)) then { if ([_target] call EFUNC(common,isPlayer)) then {
@ -21,7 +21,6 @@ if ([_target] call EFUNC(common,isPlayer)) then {
}; };
// play a rustling sound // play a rustling sound
private ["_sounds", "_position"];
_sounds = [ _sounds = [
/*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss", /*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss",
@ -29,8 +28,8 @@ _sounds = [
"a3\sounds_f\characters\ingame\AinvPpneMstpSlayWpstDnon_medic.wss", "a3\sounds_f\characters\ingame\AinvPpneMstpSlayWpstDnon_medic.wss",
"a3\sounds_f\characters\ingame\AinvPpneMstpSlayWrflDnon_medic.wss"*/ "a3\sounds_f\characters\ingame\AinvPpneMstpSlayWrflDnon_medic.wss"*/
QUOTE(PATHTO_R(sounds\zip_in.wav)), QUOTE(PATHTOF(sounds\zip_in.wav)),
QUOTE(PATHTO_R(sounds\zip_out.wav)) QUOTE(PATHTOF(sounds\zip_out.wav))
]; ];
_position = _target modelToWorldVisual (_target selectionPosition "Spine3"); _position = _target modelToWorldVisual (_target selectionPosition "Spine3");

View File

@ -2,21 +2,20 @@
* Author: commy2 * Author: commy2
* *
* Returns the unit that has the given backpack object equipped. * Returns the unit that has the given backpack object equipped.
* *
* Argument: * Argument:
* 0: A backpack object (Object) * 0: Executing Unit (Object)
* * 1: A backpack object (Object)
*
* Return value: * Return value:
* Unit that has the backpack equipped. (Object) * Unit that has the backpack equipped. (Object)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
scopeName "main";
private ["_backpack", "_unit"]; params ["_unit","_backpack"];
_target = objNull;
_backpack = _this select 0;
_unit = objNull;
{ {
if (backpackContainer _x == _backpack) exitWith {_unit = _x}; if (backpackContainer _x == _backpack) then {_target = _x; breakTo "main"};
} forEach (allUnits + allDeadMen); } forEach nearestObjects [_unit, ["Man"],2];
_unit _target

View File

@ -2,29 +2,27 @@
* Author: commy2 * Author: commy2
* *
* Handle the open inventory event. Display message on traget client. * Handle the open inventory event. Display message on traget client.
* *
* Argument: * Argument:
* Input from "InventoryOpened" eventhandler * Input from "InventoryOpened" eventhandler
* *
* Return value: * Return value:
* false. Always open the inventory dialog. (Bool) * false. Always open the inventory dialog. (Bool)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit", "_backpack"]; private "_target";
params ["","_backpack"];
_unit = _this select 0;
_backpack = _this select 1;
// exit if the target is not a backpack // exit if the target is not a backpack
if !([_backpack] call FUNC(isBackpack)) exitWith {}; if !([_backpack] call FUNC(isBackpack)) exitWith {};
// get the unit that wears the backpack object // get the unit that wears the backpack object
private "_target"; _target = _this call FUNC(getBackpackAssignedUnit);
_target = [_backpack] call FUNC(getBackpackAssignedUnit);
if (isNull _target) exitWith {false};
// raise event on target unit // raise event on target unit
["backpackOpened", _target, [_unit, _target, _backpack]] call EFUNC(common,targetEvent); ["backpackOpened", _target, [_target, _backpack]] call EFUNC(common,targetEvent);
// return false to open inventory as usual // return false to open inventory as usual
false false