Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup reload launchers #3730

Merged
merged 3 commits into from May 4, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
15 changes: 6 additions & 9 deletions addons/reloadlaunchers/functions/fnc_load.sqf
@@ -1,6 +1,5 @@
/*
* Author: commy2
*
* Reload a launcher
*
* Argument:
Expand All @@ -11,18 +10,16 @@
*
* 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);

private "_reloadTime";
_reloadTime = getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime");
// private _reloadTime = getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime"); //Not a good config value, use a constant for now:
private _reloadTime = 2.5;
Copy link
Member

@bux bux May 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to introduce a new config value?
e.g. ACE_reloadlaunchers_buddyReloadTime
Maybe some launchers in the CUP or RHS weapon pack need more/less reload time?


// 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