Skip to content

Commit

Permalink
Merge pull request #3730 from acemod/cleanupReloadLaunchers
Browse files Browse the repository at this point in the history
Cleanup reload launchers
  • Loading branch information
commy2 committed May 4, 2016
2 parents 83a8c48 + 398b76f commit 01cf551
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 37 deletions.
28 changes: 16 additions & 12 deletions addons/reloadlaunchers/functions/fnc_addMissileReloadActions.sqf
Expand Up @@ -3,28 +3,31 @@
* Create one action per reloadable missile
*
* Argument:
* 1: Player (Object)
* 0: Target (Object)
* 2: Parameters ??? (Array)
* 1: Target (Object)
* 0: Player (Object)
*
* Return value:
* Children actions (Array)
*
* Public: No
*
*/
#include "script_component.hpp"

private ["_unit", "_target", "_parameters"];

_unit = _this select 1;
_target = _this select 0;
_parameters = _this select 2; // ???
params ["_target", "_unit"];
TRACE_2("params",_target,_unit);

private ["_actions", "_weapon", "_loadableMissiles"];
//Fast exit for common case:
private _weapon = secondaryWeapon _target;
if ((_weapon == "") || {(getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled))) == 0}) exitWith {
TRACE_1("weapon not supported",_weapon);
[]
};

_actions = [];
private _actions = [];

_weapon = secondaryWeapon _target;
_loadableMissiles = [_unit, _weapon] call FUNC(getLoadableMissiles);
private _loadableMissiles = [_unit, _weapon] call FUNC(getLoadableMissiles);
TRACE_2("",_weapon,_loadableMissiles);

{
private ["_name", "_displayName", "_statement", "_condition", "_action"];
Expand All @@ -45,4 +48,5 @@ _loadableMissiles = [_unit, _weapon] call FUNC(getLoadableMissiles);
_actions pushBack [_action, [], _unit];
} forEach _loadableMissiles;

TRACE_1("return",_actions);
_actions
11 changes: 4 additions & 7 deletions addons/reloadlaunchers/functions/fnc_canLoad.sqf
@@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Check of the unit can reload the launcher of target unit.
*
* Argument:
Expand All @@ -11,15 +10,13 @@
*
* Return value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"

private ["_unit", "_target", "_weapon", "_magazine"];

_unit = _this select 0;
_target = _this select 1;
_weapon = _this select 2;
_magazine = _this select 3;
params ["_unit", "_target", "_weapon", "_magazine"];
TRACE_4("params",_unit,_target,_weapon,_magazine);

if (!alive _target) exitWith {false};
if (vehicle _target != _target) exitWith {false};
Expand Down
12 changes: 5 additions & 7 deletions addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf
@@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Return all magazine types from reloaders inventory that are compatible with given weapon.
*
* Argument:
Expand All @@ -9,17 +8,16 @@
*
* Return value:
* Reloable magazines (Array)
*
* Public: No
*/
#include "script_component.hpp"

private ["_unit", "_weapon"];

_unit = _this select 0;
_weapon = _this select 1;
params ["_unit", "_weapon"];
TRACE_2("params",_unit,_weapon);

// get available magazines of reloader, Note: "magazines" does not include currently loaded magazines
private "_magazines";
_magazines = magazines _unit;
private _magazines = magazines _unit;

// case sensitvity
_magazines = _magazines apply {toLower _x};
Expand Down
18 changes: 9 additions & 9 deletions addons/reloadlaunchers/functions/fnc_load.sqf
@@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Reload a launcher
*
* Argument:
Expand All @@ -11,18 +10,19 @@
*
* Return value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"

private ["_unit", "_target", "_weapon", "_magazine"];
params ["_unit", "_target", "_weapon", "_magazine"];
TRACE_4("params",_unit,_target,_weapon,_magazine);

_unit = _this select 0;
_target = _this select 1;
_weapon = _this select 2;
_magazine = _this select 3;

private "_reloadTime";
_reloadTime = getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime");
private _reloadTime = if (isNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(buddyReloadTime))) then {
getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(buddyReloadTime))
} else {
2.5
};

// do animation
[_unit] call EFUNC(common,goKneeling);
Expand Down
6 changes: 4 additions & 2 deletions addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf
@@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Reload a launcher
*
* Argument:
Expand All @@ -11,10 +10,13 @@
*
* Return value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"

PARAMS_4(_unit,_target,_weapon,_magazine);
params ["_unit","_target","_weapon","_magazine"];
TRACE_4("params",_unit,_target,_weapon,_magazine);

_target selectWeapon _weapon;

Expand Down

0 comments on commit 01cf551

Please sign in to comment.