mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added different rearm levels
This commit is contained in:
parent
957756893c
commit
3eaaca84fb
@ -9,6 +9,8 @@ PREP(getMaxMagazines);
|
||||
PREP(pickUpAmmo);
|
||||
PREP(pickUpSuccess);
|
||||
PREP(rearm);
|
||||
PREP(rearmEntireVehicle);
|
||||
PREP(rearmEntireVehicleSuccess);
|
||||
PREP(rearmSuccess);
|
||||
PREP(moduleRearmSettings);
|
||||
|
||||
|
@ -37,13 +37,25 @@ _vehicleActions = [];
|
||||
_magazine = _x;
|
||||
_cnt = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
|
||||
if ((_cnt < ([_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines))) && !(_magazine in _magazineHelper)) then {
|
||||
_action = [_magazine, getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), getText(configFile >> "CfgMagazines" >> _magazine >> "picture"), {_this call FUNC(pickUpAmmo)}, {true}, {}, [_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
|
||||
_action = [_magazine,
|
||||
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
|
||||
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
|
||||
{_this call FUNC(pickUpAmmo)},
|
||||
{true},
|
||||
{},
|
||||
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _target];
|
||||
_magazineHelper pushBack _magazine;
|
||||
_needToAdd = true;
|
||||
} else {
|
||||
if (((_vehicle magazineTurretAmmo [_magazine, _turretPath]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) && !(_magazine in _magazineHelper)) then {
|
||||
_action = [_magazine, getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), getText(configFile >> "CfgMagazines" >> _magazine >> "picture"), {_this call FUNC(pickUpAmmo)}, {true}, {}, [_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
|
||||
_action = [_magazine,
|
||||
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
|
||||
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
|
||||
{_this call FUNC(pickUpAmmo)},
|
||||
{true},
|
||||
{},
|
||||
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _target];
|
||||
_magazineHelper pushBack _magazine;
|
||||
_needToAdd = true;
|
||||
@ -57,9 +69,27 @@ _vehicleActions = [];
|
||||
if !((_icon select [0, 1]) == "\") then {
|
||||
_icon = "";
|
||||
};
|
||||
_action = [_vehicle, getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"), _icon, "", {true}, {}, []] call EFUNC(interact_menu,createAction);
|
||||
_vehicleActions pushBack [_action, _actions, _target];
|
||||
if (GVAR(level) == 0) then {
|
||||
_action = [_vehicle,
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
|
||||
_icon,
|
||||
{_this call FUNC(rearmEntireVehicle)},
|
||||
{true},
|
||||
{},
|
||||
_vehicle] call EFUNC(interact_menu,createAction);
|
||||
_vehicleActions pushBack [_action, [], _target];
|
||||
} else {
|
||||
_action = [_vehicle,
|
||||
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
|
||||
_icon,
|
||||
{},
|
||||
{true},
|
||||
{},
|
||||
[]] call EFUNC(interact_menu,createAction);
|
||||
_vehicleActions pushBack [_action, _actions, _target];
|
||||
};
|
||||
};
|
||||
} foreach _vehicles;
|
||||
|
||||
|
||||
_vehicleActions
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Can rearm
|
||||
*
|
||||
* Example:
|
||||
* [tank] call ace_rearm_fnc_canPickUpAmmo
|
||||
* [player, tank] call ace_rearm_fnc_canPickUpAmmo
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicles", "_magazine", "_magazines", "_path", "_return", "_cnt"];
|
||||
private ["_magazine", "_return", "_magazines", "_path", "_cnt"];
|
||||
params ["_unit", "_vehicle"];
|
||||
|
||||
#define GETRETURNVALUE \
|
||||
@ -29,13 +29,11 @@ if ((_vehicle magazineTurretAmmo [_magazine, _path]) < getNumber (configFile >>
|
||||
}; \
|
||||
};
|
||||
|
||||
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_vehicle distance _unit) > 7}) exitWith {false};
|
||||
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_vehicle distance _unit) > 7} || {GVAR(level) == 0}) exitWith {false};
|
||||
|
||||
_magazine = _unit getVariable QGVAR(carriedMagazine);
|
||||
if (isNil "_magazine") exitWith {false};
|
||||
|
||||
// TODO move into loop
|
||||
|
||||
_return = false;
|
||||
_magazines = _vehicle magazinesTurret [-1];
|
||||
if (_magazine in _magazines) then {
|
||||
|
@ -27,7 +27,7 @@ if ((_target magazineTurretAmmo [_magazine, _path]) < getNumber (configFile >> "
|
||||
}; \
|
||||
};
|
||||
|
||||
private ["_ammo", "_tmpCal", "_cal", "_idx", "_cnt","_return"];
|
||||
private ["_ammo", "_tmpCal", "_cal", "_idx", "_return", "_cnt", "_magazineDisplayName"];
|
||||
params ["_unit", "_vehicle"];
|
||||
|
||||
_magazine = _unit getVariable QGVAR(carriedMagazine);
|
||||
@ -98,18 +98,24 @@ if (!_return) then {
|
||||
_path = [2];
|
||||
GETRETURNVALUE
|
||||
} else {
|
||||
diag_log format ["ACE_Rearm: Could not find turret for %1 in %2", _magazine, (typeOf _target)];
|
||||
diag_log format ["ACE_Rearm: Could not find turret for %1 in %2", _magazine, typeOf _target];
|
||||
};
|
||||
};
|
||||
|
||||
//hint format ["Magazine: %1\nAmmo: %2\nCaliber: %3\nIndex: %4\nTurretPath: %5\nDURATION_REARM: %6\nCount: %7", _magazine, _ammo, _cal, _idx, _turretPath, (DURATION_REARM select _idx), (COUNT select _idx)];
|
||||
|
||||
_magazineDisplayName = getText(configFile >> "CfgMagazines" >> _magazine >> "displayName");
|
||||
if (_magazineDisplayName == "") then {
|
||||
_magazineDisplayName = _magazine;
|
||||
diag_log format ["ACE_Rearm: Magazine is missing display name [%1]", _magazine];
|
||||
};
|
||||
|
||||
[
|
||||
(DURATION_REARM select _idx),
|
||||
[_target, _unit, _turretPath, _cnt, _magazine, (COUNT select _idx)],
|
||||
FUNC(rearmSuccess),
|
||||
"",
|
||||
format [localize LSTRING(RearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName"), getText(configFile >> "CfgMagazines" >> _magazine >> "displayName")],
|
||||
format [localize LSTRING(RearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName"), _magazineDisplayName],
|
||||
{true},
|
||||
["isnotinside"]
|
||||
] call EFUNC(common,progressBar);
|
31
addons/rearm/functions/fnc_rearmEntireVehicle.sqf
Normal file
31
addons/rearm/functions/fnc_rearmEntireVehicle.sqf
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Rearms an entire vehicle
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Ammo Truck <OBJECT>
|
||||
* 1: The Player <OBJECT>
|
||||
* 2: The Vehicle to be armed <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ammo_truck, player, tank] call ace_rearm_fnc_rearmEntireVehicle
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_ammo", "_tmpCal", "_cal"];
|
||||
params ["_target","_unit","_vehicle"];
|
||||
|
||||
[
|
||||
10,
|
||||
_vehicle,
|
||||
FUNC(rearmEntireVehicleSuccess),
|
||||
"",
|
||||
format [localize LSTRING(BasicRearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],
|
||||
{true},
|
||||
["isnotinside"]
|
||||
] call EFUNC(common,progressBar);
|
49
addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf
Normal file
49
addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Rearm an entire vehicle
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Vehicle <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [tank] call ace_rearm_fnc_rearmEntireVehicleSuccess
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_rounds"];
|
||||
params ["_vehicle"];
|
||||
|
||||
if !(local _vehicle) exitWith {
|
||||
[_this, QUOTE(DFUNC(rearmEntireVehicleSuccess)), _vehicle] call EFUNC(common,execRemoteFnc);
|
||||
};
|
||||
|
||||
{
|
||||
_turretPath = _x;
|
||||
_magazines = _vehicle magazinesTurret _turretPath;
|
||||
{
|
||||
_magazine = _x;
|
||||
_currentMagazines = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
|
||||
_maxMagazines = [_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines);
|
||||
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
|
||||
_currentRounds = _vehicle magazineTurretAmmo [_magazine, _turretPath];
|
||||
|
||||
//diag_log format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nNumRounds: %5\nMaxRounds: %6\nMagazine: %7", _vehicle, _turretPath, _currentMagazines, _maxMagazines, _currentRounds, _maxRounds, _magazine];
|
||||
if (_currentMagazines < _maxMagazines) then {
|
||||
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
|
||||
for "_idx" from 1 to (_maxMagazines - _currentMagazines) do {
|
||||
_vehicle addMagazineTurret [_magazine, _turretPath];
|
||||
};
|
||||
} else {
|
||||
if (_currentRounds > 0) then {
|
||||
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
|
||||
} else {
|
||||
_vehicle removeMagazineTurret [_magazine, _turretPath];
|
||||
};
|
||||
};
|
||||
} foreach _magazines;
|
||||
} foreach [[-1], [0], [0,0], [0,1], [1], [2]];
|
@ -23,7 +23,7 @@
|
||||
|
||||
private ["_rounds", "_currentRounds", "_maxMagazines"];
|
||||
params ["_args"];
|
||||
_args params ["_target", "_caller", "_turretPath", "_numMagazines", "_magazine", "_numRounds"];
|
||||
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazine", "_numRounds"];
|
||||
|
||||
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazine, _numRounds];
|
||||
|
||||
@ -36,23 +36,41 @@ _currentRounds = 0;
|
||||
|
||||
_maxMagazines = [_target, _turretPath, _magazine] call FUNC(getMaxMagazines);
|
||||
if (_maxMagazines == 1) then {
|
||||
_target setMagazineTurretAmmo [_magazine, ((_target magazineTurretAmmo [_magazine, _turretPath]) + _numRounds) min _rounds, _turretPath];
|
||||
ace_player setVariable [QGVAR(carriedMagazine), nil]; // TODO replace by item
|
||||
if (GVAR(level) == 1) then {
|
||||
// Fill magazine completely
|
||||
_target setMagazineTurretAmmo [_magazine, _rounds, _turretPath];
|
||||
} else {
|
||||
// Fill only at most _numRounds
|
||||
_target setMagazineTurretAmmo [_magazine, ((_target magazineTurretAmmo [_magazine, _turretPath]) + _numRounds) min _rounds, _turretPath];
|
||||
};
|
||||
_unit setVariable [QGVAR(carriedMagazine), nil]; // TODO replace by item
|
||||
} else {
|
||||
for "_idx" from 1 to _maxMagazines do {
|
||||
_currentRounds = _target magazineTurretAmmo [_magazine, _turretPath];
|
||||
if (_currentRounds > 0) exitWith {
|
||||
if ((_currentRounds + _numRounds) > _rounds) then {
|
||||
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, _magazine];
|
||||
// Fill only at most _numRounds
|
||||
if ((_currentRounds + _numRounds) > _rounds) then {
|
||||
_target setMagazineTurretAmmo [_magazine, _rounds, _turretPath];
|
||||
if (_numMagazines < _maxMagazines) then {
|
||||
_target addMagazineTurret [_magazine, _turretPath];
|
||||
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds - _rounds, _turretPath];
|
||||
};
|
||||
} else {
|
||||
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds, _turretPath];
|
||||
};
|
||||
} else {
|
||||
// Fill current magazine completely and fill next magazine partially
|
||||
_target setMagazineTurretAmmo [_magazine, _rounds, _turretPath];
|
||||
if (_numMagazines < _maxMagazines) then {
|
||||
_target addMagazineTurret [_magazine, _turretPath];
|
||||
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds - _rounds, _turretPath];
|
||||
_target setMagazineTurretAmmo [_magazine, _currentRounds, _turretPath];
|
||||
};
|
||||
} else {
|
||||
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds, _turretPath];
|
||||
};
|
||||
ace_player setVariable [QGVAR(carriedMagazine), nil]; // TODO replace by item
|
||||
_unit setVariable [QGVAR(carriedMagazine), nil]; // TODO replace by item
|
||||
};
|
||||
_target removeMagazineTurret [_magazine, _turretPath];
|
||||
_numMagazines = _numMagazines - 1;
|
||||
};
|
||||
};
|
@ -5,11 +5,11 @@
|
||||
<English>Rearm Settings</English>
|
||||
<German>Aufmunitioniereinstellungen</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Rearm_RearmSettings_speed_DisplayName">
|
||||
<English>Rearm speed</English>
|
||||
<German>Aufmunitioniergeschwindigkeit</German>
|
||||
<Key ID="STR_ACE_Rearm_RearmSettings_level_DisplayName">
|
||||
<English>Rearm amount</English>
|
||||
<German>Aufmunitioniermenge</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Rearm_RearmSettings_speed_Description">
|
||||
<Key ID="STR_ACE_Rearm_RearmSettings_level_Description">
|
||||
<English>How fast should a vehicle be rearmed?</English>
|
||||
<German>Wie schnell soll ein Fahrzeug aufmunitioniert werden?</German>
|
||||
</Key>
|
||||
@ -33,6 +33,10 @@
|
||||
<English>Rearming %1 with %2</English>
|
||||
<German>Munitioniere %1 auf mit %2</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Rearm_BasicRearmAction">
|
||||
<English>Rearming %1</English>
|
||||
<German>Munitioniere %1 auf</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Rearm_PickUpAction">
|
||||
<English>Taking %1 for %2</English>
|
||||
<German>Nehme %1 für %2</German>
|
||||
|
Loading…
Reference in New Issue
Block a user