This commit is contained in:
Githawk 2016-02-27 21:05:19 +01:00
parent 734c8b1962
commit 3d7c51bdf1
31 changed files with 157 additions and 158 deletions

View File

@ -3,7 +3,7 @@
* Adds magazines to the supply.
*
* Argument:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Magazine Classname <STRING>
* 2: Only partial <BOOL><OPTIONAL>
*
@ -17,27 +17,27 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_magazineClass", "", [""]], ["_partial", false, [false]]];
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]], ["_partial", false, [false]]];
if (isNull _target ||
if (isNull _truck ||
{_magazineClass isEqualTo ""} ||
{GVAR(supply) == 0}) exitWith {};
// With limited supply, we add the caliber to the supply count
if (GVAR(supply) == 1) then {
private _supply = [_target] call FUNC(getSupplyCount);
private _supply = [_truck] call FUNC(getSupplyCount);
([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];
if (!_partial || {GVAR(level) == 1}) then {
[_target, _supply + _cal] call FUNC(setSupplyCount);
[_truck, _supply + _cal] call FUNC(setSupplyCount);
} else {
private _magazinePart = ((REARM_COUNT select _idx) / (getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count"))) min 1;
[_target, (_supply + (_cal * _magazinePart))] call FUNC(setSupplyCount);
[_truck, (_supply + (_cal * _magazinePart))] call FUNC(setSupplyCount);
};
};
// With magazine specific supply, we add or update the magazineSupply array
if (GVAR(supply) == 2) then {
private _magazineSupply = _target getVariable [QGVAR(magazineSupply), []];
private _magazineSupply = _truck getVariable [QGVAR(magazineSupply), []];
private _magazineIdx = -1;
{
_x params ["_magazine", "_rounds"];
@ -60,5 +60,5 @@ if (GVAR(supply) == 2) then {
(_magazineSupply select _magazineIdx) params ["", "_rounds"];
_magazineSupply set [_magazineIdx, [_magazineClass, (_rounds + _roundsPerTransaction)]];
};
_target setVariable [QGVAR(magazineSupply), _magazineSupply, true];
_truck setVariable [QGVAR(magazineSupply), _magazineSupply, true];
};

View File

@ -15,9 +15,9 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]]];
params [["_truck", objNull, [objNull]]];
private _vehicles = nearestObjects [_target, ["AllVehicles"], 20];
private _vehicles = nearestObjects [_truck, ["AllVehicles"], 20];
if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles
private _vehicleActions = [];
@ -26,7 +26,7 @@ private _vehicleActions = [];
private _vehicle = _x;
private _needToAdd = false;
private _action = [];
if !((_vehicle == _target) || (_vehicle isKindOf "CAManBase")) then {
if !((_vehicle == _truck) || (_vehicle isKindOf "CAManBase")) then {
private _magazineHelper = [];
{
private _turretPath = _x;
@ -42,8 +42,8 @@ private _vehicleActions = [];
{true},
{},
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
if (GVAR(supply) == 0 || {(GVAR(supply) == 1) && ([_target, _magazine] call FUNC(hasEnoughSupply))} || {(GVAR(supply) == 2) && ([_target, _magazine] call FUNC(magazineInSupply))}) then {
_actions pushBack [_action, [], _target];
if (GVAR(supply) == 0 || {(GVAR(supply) == 1) && ([_truck, _magazine] call FUNC(hasEnoughSupply))} || {(GVAR(supply) == 2) && ([_truck, _magazine] call FUNC(magazineInSupply))}) then {
_actions pushBack [_action, [], _truck];
_magazineHelper pushBack _magazine;
_needToAdd = true;
};
@ -56,8 +56,8 @@ private _vehicleActions = [];
{true},
{},
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
if (GVAR(supply) == 0 || {(GVAR(supply) == 1) && ([_target, _magazine] call FUNC(hasEnoughSupply))} || {(GVAR(supply) == 2) && ([_target, _magazine] call FUNC(magazineInSupply))}) then {
_actions pushBack [_action, [], _target];
if (GVAR(supply) == 0 || {(GVAR(supply) == 1) && ([_truck, _magazine] call FUNC(hasEnoughSupply))} || {(GVAR(supply) == 2) && ([_truck, _magazine] call FUNC(magazineInSupply))}) then {
_actions pushBack [_action, [], _truck];
_magazineHelper pushBack _magazine;
_needToAdd = true;
};
@ -79,7 +79,7 @@ private _vehicleActions = [];
{true},
{},
_vehicle] call EFUNC(interact_menu,createAction);
_vehicleActions pushBack [_action, [], _target];
_vehicleActions pushBack [_action, [], _truck];
} else {
_action = [_vehicle,
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
@ -88,7 +88,7 @@ private _vehicleActions = [];
{true},
{},
[]] call EFUNC(interact_menu,createAction);
_vehicleActions pushBack [_action, _actions, _target];
_vehicleActions pushBack [_action, _actions, _truck];
};
};
} forEach _vehicles;

View File

@ -20,9 +20,9 @@
*/
#include "script_component.hpp"
params [["_ammoTruck", objNull, [objNull]], ["_vehicle", objNull, [objNull, ""]]];
params [["_truck", objNull, [objNull]], ["_vehicle", objNull, [objNull, ""]]];
if (isNull _ammoTruck ||
if (isNull _truck ||
{typeName _vehicle == "OBJECT" && {isNull _vehicle}}) exitWith {};
private _string = "";
@ -37,6 +37,6 @@ if (_string == "") exitWith {[]};
private _turretPath = _x;
private _magazines = [_string, _turretPath] call FUNC(getConfigMagazines);
{
[_ammoTruck, _x] call FUNC(addMagazineToSupply);
[_truck, _x] call FUNC(addMagazineToSupply);
} forEach _magazines;
} forEach REARM_TURRET_PATHS;

View File

@ -10,17 +10,17 @@
* Can read supply counter <BOOL>
*
* Example:
* [truck, player] call ace_rearm_fnc_canReadSupplyCounter
* [ammo_truck, player] call ace_rearm_fnc_canReadSupplyCounter
*
* Public: No
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||
{!local _unit} ||
{!alive _target} ||
{(_target distance _unit) > REARM_ACTION_DISTANCE} ||
{!alive _truck} ||
{(_truck distance _unit) > REARM_ACTION_DISTANCE} ||
{GVAR(supply) == 0})

View File

@ -3,27 +3,26 @@
* Check if a unit can rearm.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can Rearm <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canRearm
* [tank, player] call ace_rearm_fnc_canRearm
*
* Public: No
*/
#include "script_component.hpp"
private ["_dummy","_magazineClass"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_vehicle", 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};
if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_vehicle distance _unit > REARM_ACTION_DISTANCE} || {_vehicle getVariable [QGVAR(disabled), false]}) exitWith {false};
_dummy = _unit getVariable [QGVAR(dummy), objNull];
private _dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {false};
_magazineClass = _dummy getVariable QGVAR(magazineClass);
private _magazineClass = _dummy getVariable QGVAR(magazineClass);
if (isNil "_magazineClass") exitWith {false};
([_target, _magazineClass] call FUNC(getNeedRearmMagazines)) select 0
([_vehicle, _magazineClass] call FUNC(getNeedRearmMagazines)) select 0

View File

@ -3,24 +3,24 @@
* Check if a unit can rearm a vehicle.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can Pick Up Ammo <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canRearmVehicle
* [tank, player] call ace_rearm_fnc_canRearmVehicle
*
* Public: No
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_vehicle", objNull, [objNull]], ["_unit", objNull, [objNull]]];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||
{!local _unit} ||
{(_target distance _unit) > REARM_ACTION_DISTANCE} ||
{(_vehicle distance _unit) > REARM_ACTION_DISTANCE} ||
{!isNull (_unit getVariable [QGVAR(dummy), objNull])} ||
{GVAR(level) > 0})

View File

@ -10,16 +10,16 @@
* Can Store Ammo <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canStoreAmmo
* [ammo_truck, player] call ace_rearm_fnc_canStoreAmmo
*
* Public: No
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||
{!local _unit} ||
{(_target distance _unit) > REARM_ACTION_DISTANCE} ||
{(_truck distance _unit) > REARM_ACTION_DISTANCE} ||
{isNull (_unit getVariable [QGVAR(dummy), objNull])})

View File

@ -10,17 +10,17 @@
* Can Pick Up Ammo <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canTakeAmmo
* [ammo_truck, player] call ace_rearm_fnc_canTakeAmmo
*
* Public: No
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||
{!local _unit} ||
{(_target distance _unit) > REARM_ACTION_DISTANCE} ||
{(_truck distance _unit) > REARM_ACTION_DISTANCE} ||
{!isNull (_unit getVariable [QGVAR(dummy), objNull])} ||
{GVAR(level) == 0})

View File

@ -10,7 +10,7 @@
* Created Dummy <OBJECT>
*
* Example:
* ["500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_createDummy
* [player, "500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_createDummy
*
* Public: No
*/

View File

@ -3,7 +3,7 @@
* Disables rearm for a vehicle.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Disable <BOOL><OPTIONAL>
*
* Return Value:
@ -17,5 +17,5 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_disable", true, [true]]];
_target setVariable [QGVAR(disabled), _disable, true];
params [["_vehicle", objNull, [objNull]], ["_disable", true, [true]]];
_vehicle setVariable [QGVAR(disabled), _disable, true];

View File

@ -4,8 +4,8 @@
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Delete dummy object <BOOL> (optional)
* 2: Unholster Weapon <BOOL> (optional)
* 1: Delete dummy object <BOOL><OPTIONAL>
* 2: Unholster Weapon <BOOL><OPTIONAL>
*
* Return Value:
* None

View File

@ -11,7 +11,7 @@
* 1: Caliber index <NUMBER>
*
* Example:
* ["500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_hasEnoughSupply
* ["500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_getCaliber
*
* Public: No
*/

View File

@ -3,7 +3,7 @@
* Calculates the maximum number of magazines a turret can hold according to config.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Turret Path <ARRAY>
* 2: Magazine Classname <STRING>
*
@ -17,9 +17,9 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_turretPath", [], [[]]], ["_magazineClass", "", [""]]];
params [["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]], ["_magazineClass", "", [""]]];
if (isNull _target) exitWith {0};
if (isNull _vehicle) exitWith {0};
private _count = {_x == _magazineClass} count ([_target, _turretPath] call FUNC(getVehicleMagazines));
private _count = {_x == _magazineClass} count ([_vehicle, _turretPath] call FUNC(getVehicleMagazines));
_count

View File

@ -3,7 +3,7 @@
* Get rearm return value.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Magazine Classname <STRING>
*
* Return Value:
@ -19,20 +19,20 @@
*/
#include "script_component.hpp"
params ["_target", "_magazineClass"];
params ["_vehicle", "_magazineClass"];
private _return = [false, [], 0];
{
private _magazines = [_target, _x] call FUNC(getVehicleMagazines);
private _magazines = [_vehicle, _x] call FUNC(getVehicleMagazines);
if (_magazineClass in _magazines) then {
private _currentMagazines = {_x == _magazineClass} count (_target magazinesTurret _x);
private _currentMagazines = {_x == _magazineClass} count (_vehicle magazinesTurret _x);
if ((_target magazineTurretAmmo [_magazineClass, _x]) < getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count")) exitWith {
if ((_vehicle magazineTurretAmmo [_magazineClass, _x]) < getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count")) exitWith {
_return = [true, _x, _currentMagazines];
};
if (_currentMagazines < ([_target, _x, _magazineClass] call FUNC(getMaxMagazines))) exitWith {
if (_currentMagazines < ([_vehicle, _x, _magazineClass] call FUNC(getMaxMagazines))) exitWith {
_return = [true, _x, _currentMagazines];
};
};

View File

@ -3,7 +3,7 @@
* Get the supply count.
*
* Argument:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
*
* Return value:
* Supply count <NUMBER>
@ -15,13 +15,13 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]]];
params [["_truck", objNull, [objNull]]];
private _supply = _target getVariable QGVAR(currentSupply);
private _supply = _truck getVariable QGVAR(currentSupply);
if (isNil "_supply") then {
_supply = getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(defaultSupply));
_target setVariable [QGVAR(currentSupply), _supply, true];
_supply = getNumber (configFile >> "CfgVehicles" >> typeOf _truck >> QGVAR(defaultSupply));
_truck setVariable [QGVAR(currentSupply), _supply, true];
};
_supply

View File

@ -3,7 +3,7 @@
* Returns all magazines a turret can hold according to config.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Turret Path <ARRAY>
*
* Return Value:
@ -16,8 +16,8 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_turretPath", [], [[]]]];
params [["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]]];
if (isNull _target) exitWith {[]};
if (isNull _vehicle) exitWith {[]};
([typeOf _target, _turretPath] call FUNC(getConfigMagazines))
([typeOf _vehicle, _turretPath] call FUNC(getConfigMagazines))

View File

@ -3,7 +3,7 @@
* Check whether enough supply is left to take the magazine.
*
* Argument:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Magazine Classname <STRING>
*
* Return value:
@ -16,9 +16,9 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_magazineClass", "", [""]]];
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]]];
if (isNull _target ||
if (isNull _truck ||
{_magazineClass isEqualTo ""}) exitWith {false};
// With infinite supply, there is always enough
@ -26,7 +26,7 @@ if (GVAR(supply) == 0) exitWith {true};
// With magazine specific supply, we need to check stored magazines
if (GVAR(supply) == 2) exitWith {_this call FUNC(magazineInSupply)};
private _supply = [_target] call FUNC(getSupplyCount);
private _supply = [_truck] call FUNC(getSupplyCount);
([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];
// With caliber based rearming, we only need partial supply

View File

@ -3,7 +3,7 @@
* Returns true if the magazine is in the current supply
*
* Argument:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Magazine Classname <STRING>
*
* Return value:
@ -16,16 +16,16 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_magazineClass", "", [""]]];
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]]];
if (isNull _target ||
if (isNull _truck ||
{_magazineClass isEqualTo ""}) exitWith {false};
// With limited supply, we need to check supply
if (GVAR(supply) == 1) exitWith {_this call FUNC(hasEnoughSupply)};
// With magazine specific supply, we need to check them
if (GVAR(supply) == 2) exitWith {
private _magazineSupply = _target getVariable [QGVAR(magazineSupply), []];
private _magazineSupply = _truck getVariable [QGVAR(magazineSupply), []];
private _magazinePresent = false;
{
_x params ["_magazine", "_rounds"];

View File

@ -16,13 +16,13 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_dummy", objNull, [objNull]], ["_unit", objNull, [objNull]]];
private _dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) exitWith {};
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _attachedDummy) exitWith {};
_target attachTo [_unit, [0,1,0], "pelvis"];
_dummy attachTo [_unit, [0,1,0], "pelvis"];
{
[[_target, [[-1,0,0],[0,0,1]]], QFUNC(makeDummy), _x] call EFUNC(common,execRemoteFnc);
[[_dummy, [[-1,0,0],[0,0,1]]], QFUNC(makeDummy), _x] call EFUNC(common,execRemoteFnc);
} count (position _unit nearObjects ["CAManBase", 100]);
_unit setVariable [QGVAR(dummy), _target];
_unit setVariable [QGVAR(dummy), _dummy];

View File

@ -1,6 +1,6 @@
/*
* Author: GitHawk
* Get the remaining ammunition amount
* Get the remaining ammunition amount.
*
* Arguments:
* 0: Ammo Truck <OBJECT>
@ -16,17 +16,17 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]];
if (GVAR(supply) == 0) exitWith {};
if (GVAR(supply) == 1) then {
[
5,
[_unit, _target, [_target] call FUNC(getSupplyCount)],
[_unit, _truck, [_truck] call FUNC(getSupplyCount)],
{
params ["_args"];
_args params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]], ["_supplyCount", 0, [0]]];
_args params [["_unit", objNull, [objNull]], ["_truck", objNull, [objNull]], ["_supplyCount", 0, [0]]];
if (_supplyCount > 0 ) then {
["displayTextStructured", [_unit], [[LSTRING(Hint_RemainingSupplyPoints), _supplyCount], 2, _unit]] call EFUNC(common,targetEvent);
} else {
@ -42,14 +42,14 @@ if (GVAR(supply) == 1) then {
} else {
[
5,
[_unit, _target],
[_unit, _truck],
{
params ["_args"];
_args params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
_args params [["_unit", objNull, [objNull]], ["_truck", objNull, [objNull]]];
private _supply = 1.5;
private _numChars = count (localize LSTRING(Hint_RemainingAmmo));
private _text = "";
private _magazines = _target getVariable QGVAR(magazineSupply);
private _magazines = _truck getVariable QGVAR(magazineSupply);
if !(isNil "_magazines") then {
{
_x params ["_magazineClass", "_rounds"];

View File

@ -17,9 +17,9 @@
params [["_unit", objNull, [objNull]]];
private _dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {false};
private _magazineClass = _dummy getVariable QGVAR(magazineClass);
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _attachedDummy) exitwith {false};
private _magazineClass = _attachedDummy getVariable QGVAR(magazineClass);
if (isNil "_magazineClass") exitWith {false};
([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];

View File

@ -17,11 +17,11 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]], ["_vehicle", objNull, [objNull]]];
params [["_truck", objNull, [objNull]], "", ["_vehicle", objNull, [objNull]]];
[
10,
[_target, _vehicle],
[_truck, _vehicle],
FUNC(rearmEntireVehicleSuccess),
"",
format [localize LSTRING(BasicRearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],

View File

@ -4,7 +4,7 @@
*
* Arguments:
* 0: Rearm information <ARRAY>
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Vehicle <OBJECT
*
* Return Value:
@ -18,15 +18,15 @@
#include "script_component.hpp"
params ["_args"];
_args params [["_target", objNull, [objNull]], ["_vehicle", objNull, [objNull]]];
_args params [["_truck", objNull, [objNull]], ["_vehicle", objNull, [objNull]]];
if (isServer) then {
{
_turretOwnerID = _vehicle turretOwner _x;
if (_turretOwnerID == 0) then {
[[_target, _vehicle, _x], QFUNC(rearmEntireVehicleSuccessLocal), _target] call EFUNC(common,execRemoteFnc);
[[_truck, _vehicle, _x], QFUNC(rearmEntireVehicleSuccessLocal), _truck] call EFUNC(common,execRemoteFnc);
} else {
EGVAR(common,remoteFnc) = [[_target, _vehicle, _x], QFUNC(rearmEntireVehicleSuccessLocal), 0];
EGVAR(common,remoteFnc) = [[_truck, _vehicle, _x], QFUNC(rearmEntireVehicleSuccessLocal), 0];
_turretOwnerID publicVariableClient QEGVAR(common,remoteFnc);
};
} count REARM_TURRET_PATHS;

View File

@ -3,7 +3,7 @@
* Rearm an entire turret locally.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Vehicle <OBJECT>
* 2: TurretPath <ARRAY>
*
@ -17,7 +17,7 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]]];
params [["_truck", objNull, [objNull]], ["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]]];
private _magazines = [_vehicle, _turretPath] call FUNC(getVehicleMagazines);
if (isNil "_magazines") exitWith {};
@ -37,14 +37,14 @@ if (isNil "_magazines") exitWith {};
if (_currentMagazines < _maxMagazines) then {
private _success = true;
if (GVAR(supply) > 0) then {
_success = [_target, _magazine, (_maxRounds - _currentRounds)] call FUNC(removeMagazineFromSupply);
_success = [_truck, _magazine, (_maxRounds - _currentRounds)] call FUNC(removeMagazineFromSupply);
};
if (_success) then {
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
for "_idx" from 1 to (_maxMagazines - _currentMagazines) do {
_success = true;
if (GVAR(supply) > 0) then {
_success = [_target, _magazine, _maxRounds] call FUNC(removeMagazineFromSupply);
_success = [_truck, _magazine, _maxRounds] call FUNC(removeMagazineFromSupply);
};
_vehicle addMagazineTurret [_magazine, _turretPath];
};
@ -52,7 +52,7 @@ if (isNil "_magazines") exitWith {};
} else {
private _success = true;
if (GVAR(supply) > 0) then {
_success = [_target, _magazine, (_maxRounds - _currentRounds)] call FUNC(removeMagazineFromSupply);
_success = [_truck, _magazine, (_maxRounds - _currentRounds)] call FUNC(removeMagazineFromSupply);
};
if (_success) then {
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];

View File

@ -4,7 +4,7 @@
*
* Arguments:
* 0: Params <ARRAY>
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Unit <OBJECT>
* 2: Turret Path <ARRAY>
* 3: Number of magazines <NUMBER>
@ -22,18 +22,18 @@
#include "script_component.hpp"
params [["_args", [objNull, objNull, [], 0, "", 0], [[]], [6]]];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
_args params ["_vehicle", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazineClass, _numRounds];
//hint format ["Vehicle: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _vehicle, _turretPath, _numMagazines, _magazineClass, _numRounds];
if (local _unit) then {
[_unit, true, true] call FUNC(dropAmmo);
};
if (isServer) then {
private _turretOwnerID = _target turretOwner _turretPath;
private _turretOwnerID = _vehicle turretOwner _turretPath;
if (_turretOwnerID == 0) then {
[_this, QFUNC(rearmSuccessLocal), _target] call EFUNC(common,execRemoteFnc);
[_this, QFUNC(rearmSuccessLocal), _vehicle] call EFUNC(common,execRemoteFnc);
} else {
EGVAR(common,remoteFnc) = [_this, QFUNC(rearmSuccessLocal), 0];
_turretOwnerID publicVariableClient QEGVAR(common,remoteFnc);

View File

@ -4,7 +4,7 @@
*
* Arguments:
* 0: Params <ARRAY>
* 0: Target <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Unit <OBJECT>
* 2: Turret Path <ARRAY>
* 3: Number of magazines <NUMBER>
@ -22,67 +22,67 @@
#include "script_component.hpp"
params [["_args", [objNull, objNull, [], 0, "", 0], [[]], [6]]];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
_args params ["_vehicle", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
private _rounds = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count");
private _currentRounds = 0;
private _maxMagazines = [_target, _turretPath, _magazineClass] call FUNC(getMaxMagazines);
private _maxMagazines = [_vehicle, _turretPath, _magazineClass] call FUNC(getMaxMagazines);
if (_maxMagazines == 1) then {
private _currentMagazines = { _x == _magazineClass } count (_target magazinesTurret _turretPath);
private _currentMagazines = { _x == _magazineClass } count (_vehicle magazinesTurret _turretPath);
if (_currentMagazines == 0 && {!(_turretPath isEqualTo [-1])}) then {
// Driver gun will always retain it's magazines
_target addMagazineTurret [_magazineClass, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, 0, _turretPath];
_vehicle addMagazineTurret [_magazineClass, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, 0, _turretPath];
};
if (GVAR(level) == 1) then {
// Fill magazine completely
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _rounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
} else {
// Fill only at most _numRounds
_target setMagazineTurretAmmo [_magazineClass, ((_target magazineTurretAmmo [_magazineClass, _turretPath]) + _numRounds) min _rounds, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, ((_vehicle magazineTurretAmmo [_magazineClass, _turretPath]) + _numRounds) min _rounds, _turretPath];
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _numRounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
};
} else {
for "_idx" from 1 to (_maxMagazines+1) do {
_currentRounds = _target magazineTurretAmmo [_magazineClass, _turretPath];
_currentRounds = _vehicle magazineTurretAmmo [_magazineClass, _turretPath];
if (_currentRounds > 0 || {_idx == (_maxMagazines+1)}) exitWith {
if (_idx == (_maxMagazines+1) && {!(_turretPath isEqualTo [-1])}) then {
_target addMagazineTurret [_magazineClass, _turretPath];
_vehicle 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];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nMagazine: %5\nNumRounds: %6\nMagazine: %7", _vehicle, _turretPath, _numMagazines, _maxMagazines, _currentRounds, _numRounds, _magazineClass];
// Fill only at most _numRounds
if ((_currentRounds + _numRounds) > _rounds) then {
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
if (_numMagazines < _maxMagazines) then {
_target addMagazineTurret [_magazineClass, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds - _rounds, _turretPath];
_vehicle addMagazineTurret [_magazineClass, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds - _rounds, _turretPath];
};
} else {
_target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds, _turretPath];
};
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _numRounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
} else {
// Fill current magazine completely and fill next magazine partially
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
if (_numMagazines < _maxMagazines) then {
_target addMagazineTurret [_magazineClass, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _currentRounds, _turretPath];
_vehicle addMagazineTurret [_magazineClass, _turretPath];
_vehicle setMagazineTurretAmmo [_magazineClass, _currentRounds, _turretPath];
};
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _rounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
};
};
_target removeMagazineTurret [_magazineClass, _turretPath];
_vehicle removeMagazineTurret [_magazineClass, _turretPath];
_numMagazines = _numMagazines - 1;
};
};

View File

@ -3,7 +3,7 @@
* Removes a magazine from the supply.
*
* Argument:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Magazine Classname <STRING>
* 2: Number of Rounds to withdraw <NUMBER><OPTIONAL>
*
@ -17,16 +17,16 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_magazineClass", "", [""]], ["_numRounds", -1, [0]]];
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]], ["_numRounds", -1, [0]]];
if (isNull _target ||
if (isNull _truck ||
{_magazineClass isEqualTo ""}) exitWith {false};
private _return = false;
([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];
if (GVAR(supply) == 1) then {
private _supply = [_target] call FUNC(getSupplyCount);
private _supply = [_truck] call FUNC(getSupplyCount);
if (GVAR(level) == 2) then {
// Remove partial magazine supply count
private _rearmAmount = (REARM_COUNT select _idx);
@ -35,19 +35,19 @@ if (GVAR(supply) == 1) then {
};
private _magazinePart = (_rearmAmount / (getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count"))) min 1;
if (_supply >= (_cal * _magazinePart)) then {
[_target, (_supply - (_cal * _magazinePart))] call FUNC(setSupplyCount);
[_truck, (_supply - (_cal * _magazinePart))] call FUNC(setSupplyCount);
_return = true;
};
} else {
// Remove entire magazine supply count
if (_supply >= _cal) then {
[_target, (_supply - _cal)] call FUNC(setSupplyCount);
[_truck, (_supply - _cal)] call FUNC(setSupplyCount);
_return = true;
};
};
};
if (GVAR(supply) == 2) then {
private _magazineSupply = _target getVariable [QGVAR(magazineSupply), []];
private _magazineSupply = _truck getVariable [QGVAR(magazineSupply), []];
private _magazineIdx = -1;
{
_x params ["_magazine"];
@ -71,14 +71,14 @@ if (GVAR(supply) == 2) then {
private _roundsPerTransaction = _rearmAmount min _configRounds;
if (_rounds >= _roundsPerTransaction) then {
_magazineSupply set [_magazineIdx, [_magazineClass, (_rounds - _roundsPerTransaction)]];
_target setVariable [QGVAR(magazineSupply), _magazineSupply, true];
_truck setVariable [QGVAR(magazineSupply), _magazineSupply, true];
_return = true;
};
} else {
// Remove entire magazine
if (_rounds >= _configRounds) then {
_magazineSupply set [_magazineIdx, [_magazineClass, (_rounds - _configRounds)]];
_target setVariable [QGVAR(magazineSupply), _magazineSupply, true];
_truck setVariable [QGVAR(magazineSupply), _magazineSupply, true];
_return = true;
};
};

View File

@ -3,7 +3,7 @@
* Sets the supply count.
*
* Argument:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Supply Count <NUMBER>
*
* Return value:
@ -16,8 +16,8 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_supply", 0, [0]]];
params [["_truck", objNull, [objNull]], ["_supply", 0, [0]]];
if (isNull _target) exitWith {};
if (isNull _truck) exitWith {};
_target setVariable [QGVAR(currentSupply), (_supply max 0), true];
_truck setVariable [QGVAR(currentSupply), (_supply max 0), true];

View File

@ -3,35 +3,35 @@
* Stores ammo in an ammo truck.
*
* Arguments:
* 0: Target <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, dummy] call ace_rearm_fnc_storeAmmo
* [ammo_truck, player] call ace_rearm_fnc_storeAmmo
*
* Public: No
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]];
private _dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {};
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _attachedDummy) exitwith {};
[
5,
[_unit, _target, _dummy],
[_unit, _truck, _attachedDummy],
{
params ["_args"];
_args params ["_unit", "_target", "_dummy"];
[_target, (_dummy getVariable [QGVAR(magazineClass), ""]), true] call FUNC(addMagazineToSupply);
_args params ["_unit", "_truck", "_attachedDummy"];
[_truck, (_attachedDummy getVariable [QGVAR(magazineClass), ""]), true] call FUNC(addMagazineToSupply);
[_unit, true, true] call FUNC(dropAmmo);
},
"",
format [localize LSTRING(StoreAmmoAction), getText(configFile >> "CfgMagazines" >> (_dummy getVariable QGVAR(magazineClass)) >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")],
format [localize LSTRING(StoreAmmoAction), getText(configFile >> "CfgMagazines" >> (_attachedDummy getVariable QGVAR(magazineClass)) >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _truck) >> "displayName")],
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -19,7 +19,7 @@
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]], ["_args", ["", objNull], [[]]]];
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]], ["_args", ["", objNull], [[]]]];
_args params ["_magazineClass", "_vehicle"];
([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];
@ -28,7 +28,7 @@ REARM_HOLSTER_WEAPON
[
(REARM_DURATION_TAKE select _idx),
[_unit, _magazineClass, _target],
[_unit, _magazineClass, _truck],
FUNC(takeSuccess),
"",
format [localize LSTRING(TakeAction), getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],

View File

@ -19,11 +19,11 @@
#include "script_component.hpp"
params [["_args", [objNull, "", objNull], [[]], 3]];
_args params ["_unit", "_magazineClass", "_target"];
_args params ["_unit", "_magazineClass", "_truck"];
private _success = true;
if (GVAR(supply) > 0) then {
_success = [_target, _magazineClass] call FUNC(removeMagazineFromSupply);
_success = [_truck, _magazineClass] call FUNC(removeMagazineFromSupply);
};
if !(_success) exitWith {};
@ -39,6 +39,6 @@ private _actionID = _unit addAction [
false,
true,
"",
'!isNull (_target getVariable [QGVAR(dummy), objNull])'
'!isNull (_truck getVariable [QGVAR(dummy), objNull])'
];
_unit setVariable [QGVAR(ReleaseActionID), _actionID];