mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2016 from jokoho48/codeCleanupBackpack
Code cleanup of the Backpack module.
This commit is contained in:
commit
05def2f62b
@ -1,3 +1,3 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
["backpackOpened", {_this call FUNC(backpackOpened)}] call EFUNC(common,addEventHandler);
|
||||
["backpackOpened", DFUNC(backpackOpened)] call EFUNC(common,addEventHandler);
|
||||
|
@ -2,18 +2,18 @@
|
||||
* Author: commy2
|
||||
*
|
||||
* Someone opened your backpack. Execute locally.
|
||||
*
|
||||
*
|
||||
* Argument:
|
||||
* 0: Who accessed your inventory? (Object)
|
||||
* 1: Unit that wields the backpack (Object)
|
||||
* 2: The backpack object (Object)
|
||||
*
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_unit,_target,_backpack);
|
||||
private ["_sounds", "_position"];
|
||||
params ["_target", "_backpack"];
|
||||
|
||||
// do cam shake if the target is the player
|
||||
if ([_target] call EFUNC(common,isPlayer)) then {
|
||||
@ -21,7 +21,6 @@ if ([_target] call EFUNC(common,isPlayer)) then {
|
||||
};
|
||||
|
||||
// play a rustling sound
|
||||
private ["_sounds", "_position"];
|
||||
|
||||
_sounds = [
|
||||
/*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss",
|
||||
|
@ -2,21 +2,21 @@
|
||||
* Author: commy2
|
||||
*
|
||||
* Returns the unit that has the given backpack object equipped.
|
||||
*
|
||||
*
|
||||
* Argument:
|
||||
* 0: A backpack object (Object)
|
||||
*
|
||||
* 0: Executing Unit (Object)
|
||||
* 1: A backpack object (Object)
|
||||
*
|
||||
* Return value:
|
||||
* Unit that has the backpack equipped. (Object)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
scopeName "main";
|
||||
|
||||
private ["_backpack", "_unit"];
|
||||
|
||||
_backpack = _this select 0;
|
||||
|
||||
_unit = objNull;
|
||||
params ["_unit","_backpack"];
|
||||
_target = objNull;
|
||||
{
|
||||
if (backpackContainer _x == _backpack) exitWith {_unit = _x};
|
||||
} forEach (allUnits + allDeadMen);
|
||||
_unit
|
||||
if (backpackContainer _x == _backpack) then {_target = _x; breakTo "main"};
|
||||
} count nearestObjects [_unit, ["Man"], 5];
|
||||
if (isNull _target) exitWith {ACE_Player};
|
||||
_target
|
||||
|
@ -11,9 +11,8 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_backpack", "_config"];
|
||||
|
||||
_backpack = _this select 0;
|
||||
private ["_config"];
|
||||
params ["_backpack"];
|
||||
|
||||
if (typeName _backpack == "OBJECT") then {
|
||||
_backpack = typeOf _backpack;
|
||||
|
@ -2,29 +2,27 @@
|
||||
* Author: commy2
|
||||
*
|
||||
* Handle the open inventory event. Display message on traget client.
|
||||
*
|
||||
*
|
||||
* Argument:
|
||||
* Input from "InventoryOpened" eventhandler
|
||||
*
|
||||
*
|
||||
* Return value:
|
||||
* false. Always open the inventory dialog. (Bool)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_backpack"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_backpack = _this select 1;
|
||||
private "_target";
|
||||
params ["","_backpack"];
|
||||
|
||||
// exit if the target is not a backpack
|
||||
if !([_backpack] call FUNC(isBackpack)) exitWith {};
|
||||
|
||||
// get the unit that wears the backpack object
|
||||
private "_target";
|
||||
_target = [_backpack] call FUNC(getBackpackAssignedUnit);
|
||||
_target = _this call FUNC(getBackpackAssignedUnit);
|
||||
|
||||
if (isNull _target) exitWith {false};
|
||||
// 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
|
||||
false
|
||||
|
Loading…
Reference in New Issue
Block a user