Fixes and updates

This commit is contained in:
Githawk 2016-02-01 20:05:53 +01:00
parent 4d041c3c94
commit cc624f58dd
24 changed files with 45 additions and 54 deletions

View File

@ -16,7 +16,7 @@
#include "script_component.hpp"
private ["_vehicleActions", "_actions", "_action", "_vehicles", "_vehicle", "_needToAdd", "_magazineHelper", "_turretPath", "_magazines", "_magazine", "_icon", "_cnt"];
params ["_target"];
params [["_target", objNull, [objNull]]];
_vehicles = nearestObjects [_target, ["AllVehicles"], 20];
if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles
@ -31,16 +31,11 @@ _vehicleActions = [];
_magazineHelper = [];
{
_turretPath = _x;
_magazines = [];
if (_turretPath isEqualTo [-1]) then {
_magazines = [_vehicle, _turretPath] call FUNC(getConfigMagazines);
} else {
_magazines = _vehicle magazinesTurret _turretPath;
};
_magazines = [_vehicle, _turretPath] call FUNC(getConfigMagazines);
{
_magazine = _x;
_cnt = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
if ((_cnt < ([_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines))) && !(_magazine in _magazineHelper)) then {
_currentMagazines = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
if ((_currentMagazines < ([_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines))) && !(_magazine in _magazineHelper)) then {
_action = [_magazine,
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),

View File

@ -17,7 +17,7 @@
#include "script_component.hpp"
private ["_dummy","_magazineClass"];
params ["_target", "_unit"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_target distance _unit > REARM_ACTION_DISTANCE} || {_target getVariable [QGVAR(disabled), false]}) exitWith {false};

View File

@ -16,7 +16,7 @@
*/
#include "script_component.hpp"
params ["_target", "_unit"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||

View File

@ -16,7 +16,7 @@
*/
#include "script_component.hpp"
params ["_target", "_unit"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||

View File

@ -17,7 +17,7 @@
#include "script_component.hpp"
private ["_ammo", "_dummyName", "_dummy"];
params ["_unit", "_magazineClass"];
params [["_unit", objNull, [objNull]], ["_magazineClass", "", [""]]];
_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
_dummyName = getText (configFile >> "CfgAmmo" >> _ammo >> QGVAR(dummy));

View File

@ -18,7 +18,7 @@
#include "script_component.hpp"
private ["_dummy", "_actionID"];
params ["_unit", ["_delete", false], ["_unholster", true]];
params [["_unit", objNull, [objNull]], ["_delete", false, [false]], ["_unholster", true, [true]]];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) then {

View File

@ -16,7 +16,7 @@
*/
#include "script_component.hpp"
params ["_target", "_turretPath"];
params [["_target", objNull, [objNull]], ["_turretPath", [], [[]]]];
if (isNull _target) exitWith {[]};

View File

@ -18,7 +18,7 @@
#include "script_component.hpp"
private ["_count", "_cfg"];
params ["_target", "_turretPath", "_magazineClass"];
params [["_target", objNull, [objNull]], ["_turretPath", [], [[]]], ["_magazineClass", "", [""]]];
if (isNull _target) exitWith {0};

View File

@ -10,7 +10,7 @@
* Return Value <ARRAY>
* 0: Can Rearm <BOOL>
* 1: TurretPath <ARRAY>
* 2: Magazine Classname <STRING>
* 2: Number of current magazines in turret path <NUMBER>
*
* Example:
* [tank, "mag"] call ace_rearm_fnc_getNeedRearmMagazines
@ -19,27 +19,22 @@
*/
#include "script_component.hpp"
private ["_return", "_magazines", "_cnt"];
private ["_return", "_magazines", "_currentMagazines"];
params ["_target", "_magazineClass"];
_return = [false, [], 0];
{
_magazines = [];
if (_x isEqualTo [-1]) then {
_magazines = [_target, _x] call FUNC(getConfigMagazines);
} else {
_magazines = _target magazinesTurret _x;
};
_magazines = [_target, _x] call FUNC(getConfigMagazines);
if (_magazineClass in _magazines) then {
_cnt = {_x == _magazineClass} count (_target magazinesTurret _x);
_currentMagazines = {_x == _magazineClass} count (_target magazinesTurret _x);
if ((_target magazineTurretAmmo [_magazineClass, _x]) < getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count")) exitWith {
_return = [true, _x, _cnt];
_return = [true, _x, _currentMagazines];
};
if (_cnt < ([_target, _x, _magazineClass] call FUNC(getMaxMagazines))) exitWith {
_return = [true, _x, _cnt];
if (_currentMagazines < ([_target, _x, _magazineClass] call FUNC(getMaxMagazines))) exitWith {
_return = [true, _x, _currentMagazines];
};
};

View File

@ -16,7 +16,7 @@
*/
#include "script_component.hpp"
params ["_dummy", "_unit"];
params [["_dummy", objNull, [objNull]], ["_unit", objNull, [objNull]]];
REARM_HOLSTER_WEAPON
[_unit, QGVAR(vehRearm), true] call EFUNC(common,setForceWalkStatus);

View File

@ -15,7 +15,7 @@
*/
#include "script_component.hpp"
params ["_unit"];
params [["_unit", objNull, [objNull]]];
if (!local _unit) exitWith {};

View File

@ -16,7 +16,7 @@
*/
#include "script_component.hpp"
params ["_unit", "_isUnconscious"];
params [["_unit", objNull, [objNull], ["_isUnconscious", false, [false]]]
if (!local _unit || {!_isUnconscious}) exitWith {};

View File

@ -16,7 +16,7 @@
*/
#include "script_component.hpp"
params ["_obj", "_dirAndUp"];
params [["_obj", objNull, [objNull], ["_dirAndUp", [[1,0,0],[0,0,1]], [[]]]]
_obj setVectorDirAndUp _dirAndUp;
_obj allowDamage false;

View File

@ -17,7 +17,7 @@
*/
#include "script_component.hpp"
params ["_logic", "", "_activated"];
params ["_logic", "", ["_activated", false, [false]]];
if (!_activated) exitWith {};

View File

@ -17,7 +17,7 @@
#include "script_component.hpp"
private ["_magazineClass"];
params ["_target", "_unit"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) exitWith {};

View File

@ -16,7 +16,7 @@
#include "script_component.hpp"
private ["_magazineClass", "_ammo", "_tmpCal", "_cal", "_idx", "_needRearmMags", "_magazineDisplayName"];
params ["_unit"];
params [["_unit", objNull, [objNull]]];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {false};

View File

@ -16,8 +16,7 @@
* Public: No
*/
#include "script_component.hpp"
params ["_target", "_unit", "_vehicle"]; // _target is for future possible finite ammo, _unit placeholder
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]], ["_vehicle", objNull, [objNull]]]; // _target is for future possible finite ammo, _unit placeholder
[
10,

View File

@ -16,7 +16,7 @@
#include "script_component.hpp"
private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"];
params ["_vehicle"];
params [["_vehicle", objNull, [objNull]]];
if (isServer) then {
{

View File

@ -4,6 +4,7 @@
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: TurretPath <ARRAY>
*
* Return Value:
* None
@ -16,14 +17,9 @@
#include "script_component.hpp"
private ["_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"];
params ["_vehicle", "_turretPath"];
params [["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]]];
_magazines = [];
if (_turretPath isEqualTo [-1]) then {
_magazines = [_vehicle, _turretPath] call FUNC(getConfigMagazines);
} else {
_magazines = _vehicle magazinesTurret _turretPath;
};
_magazines = [_vehicle, _turretPath] call FUNC(getConfigMagazines);
{
_magazine = _x;
_currentMagazines = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);

View File

@ -22,7 +22,7 @@
#include "script_component.hpp"
private ["_dummy", "_weaponSelect", "_turretOwnerID"];
params ["_args"];
params [["_args", [objNull, objNull, [], 0, "", 0], [[]]], [6]];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazineClass, _numRounds];

View File

@ -21,8 +21,8 @@
*/
#include "script_component.hpp"
private ["_rounds", "_currentRounds", "_maxMagazines", "_dummy", "_weaponSelect"];
params ["_args"];
private ["_rounds", "_currentRounds", "_maxMagazines", "_currentMagazines", "_dummy", "_weaponSelect"];
params [["_args", [objNull, objNull, [], 0, "", 0], [[]]], [6]];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5\nUnit: %6", _target, _turretPath, _numMagazines, _magazineClass, _numRounds, _unit];
@ -32,6 +32,10 @@ _currentRounds = 0;
_maxMagazines = [_target, _turretPath, _magazineClass] call FUNC(getMaxMagazines);
if (_maxMagazines == 1) then {
_currentMagazines = { _x == _magazineClass } count (_target magazinesTurret _turretPath);
if (_currentMagazines == 0) then {
_target addMagazineTurret [_magazineClass, _turretPath];
};
if (GVAR(level) == 1) then {
// Fill magazine completely
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
@ -46,9 +50,12 @@ if (_maxMagazines == 1) then {
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
};
} else {
for "_idx" from 1 to _maxMagazines do {
for "_idx" from 1 to (_maxMagazines+1) do {
_currentRounds = _target magazineTurretAmmo [_magazineClass, _turretPath];
if (_currentRounds > 0) exitWith {
if (_currentRounds > 0 || {_idx == (_maxMagazines+1)}) exitWith {
if (_idx == (_maxMagazines+1)) then {
_target addMagazineTurret [_magazineClass, _turretPath];
};
if (GVAR(level) == 2) then {
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nMagazine: %5\nNumRounds: %6\nMagazine: %7", _target, _turretPath, _numMagazines, _maxMagazines, _currentRounds, _numRounds, _magazineClass];
// Fill only at most _numRounds

View File

@ -17,12 +17,11 @@
#include "script_component.hpp"
private "_dummy";
params ["_target", "_unit"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {};
[
5,
_unit,

View File

@ -21,7 +21,7 @@
private ["_ammo", "_tmpCal", "_cal", "_idx"];
params ["_target", "_unit", "_args"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]], ["_args", ["", objNull]], [[]]];
_args params ["_magazineClass", "_vehicle"];
_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");

View File

@ -19,7 +19,7 @@
#include "script_component.hpp"
private ["_ammo", "_dummyName", "_dummy", "_actionID"];
params ["_args"];
params [["_args", [objNull, "", objNull]], [[]]];
_args params ["_unit", "_magazineClass", "_target"]; // _target is for future possible finite ammo
[_unit, QGVAR(vehRearm), true] call EFUNC(common,setForceWalkStatus);