mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
fix missing magazines after certain scenarios
This commit is contained in:
parent
10950d5fab
commit
38422e6586
@ -140,4 +140,10 @@ class CfgVehicles {
|
||||
isBicycle = 1;
|
||||
XEH_DISABLED;
|
||||
};
|
||||
|
||||
class Bag_Base;
|
||||
class ACE_FakeBackpack: Bag_Base {
|
||||
scope = 1;
|
||||
maximumLoad = 1E6;
|
||||
};
|
||||
};
|
||||
|
@ -146,8 +146,10 @@ PREP(resetAllDefaults);
|
||||
PREP(restoreVariablesJIP);
|
||||
PREP(runAfterSettingsInit);
|
||||
PREP(sanitizeString);
|
||||
PREP(selectWeaponMode);
|
||||
PREP(sendRequest);
|
||||
PREP(serverLog);
|
||||
PREP(setAllGear);
|
||||
PREP(setCaptivityStatus);
|
||||
PREP(setDefinedVariable);
|
||||
PREP(setDisableUserInputStatus);
|
||||
@ -220,6 +222,10 @@ PREP(getDoorTurrets);
|
||||
PREP(getTurretsFFV);
|
||||
PREP(getTurretsOther);
|
||||
|
||||
// missing inventory commands
|
||||
PREP(binocularMagazine);
|
||||
PREP(removeBinocularMagazine);
|
||||
|
||||
// ACE_Debug
|
||||
PREP(exportConfig);
|
||||
PREP(getChildren);
|
||||
|
35
addons/common/functions/fnc_binocularMagazine.sqf
Normal file
35
addons/common/functions/fnc_binocularMagazine.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Returns the magazine of the units rangefinder.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Magazine of the units binocular <STRING>
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_common_fnc_binocularMagazine
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private ["_binocular", "_muzzle", "_mode", "_magazine"];
|
||||
|
||||
_binocular = binocular _unit;
|
||||
|
||||
if (_binocular == "") exitWith {""};
|
||||
|
||||
_muzzle = currentMuzzle _unit;
|
||||
_mode = currentWeaponMode _unit;
|
||||
|
||||
_unit selectWeapon _binocular;
|
||||
|
||||
_magazine = currentMagazine _unit;
|
||||
|
||||
[_unit, _muzzle, _mode] call FUNC(selectWeaponMode);
|
||||
|
||||
_magazine
|
@ -18,7 +18,7 @@ private ["_backpackObject", "_holder"];
|
||||
|
||||
_backpackObject = backpackContainer _unit;
|
||||
|
||||
_unit addBackpack "Bag_Base";
|
||||
_unit addBackpack "ACE_FakeBackpack";
|
||||
removeBackpack _unit;
|
||||
|
||||
objectParent _backpackObject // return
|
||||
|
@ -25,6 +25,7 @@
|
||||
* 16: Handgun Magazines <ARRAY>
|
||||
* 17: Assigned Items (map, compass, watch, etc.) <ARRAY>
|
||||
* 18: Binoculars <STRING>
|
||||
* 19: Binocular Magazine (E.g. Laserbatteries) <STRING>
|
||||
*
|
||||
* Public: Yes
|
||||
*
|
||||
@ -44,6 +45,7 @@ if (isNull _unit) exitWith {[
|
||||
"", ["","","",""], [],
|
||||
"", ["","","",""], [],
|
||||
[],
|
||||
"",
|
||||
""
|
||||
]};
|
||||
|
||||
@ -57,5 +59,6 @@ if (isNull _unit) exitWith {[
|
||||
secondaryWeapon _unit, secondaryWeaponItems _unit, secondaryWeaponMagazine _unit,
|
||||
handgunWeapon _unit, handgunItems _unit, handgunMagazine _unit,
|
||||
assignedItems _unit,
|
||||
binocular _unit
|
||||
binocular _unit,
|
||||
[_unit] call FUNC(binocularMagazine)
|
||||
]
|
||||
|
30
addons/common/functions/fnc_removeBinocularMagazine.sqf
Normal file
30
addons/common/functions/fnc_removeBinocularMagazine.sqf
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Removes the magazine of the units rangefinder.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_common_fnc_removeBinocularMagazine
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private ["_binocular", "_selectBinocular"];
|
||||
|
||||
_binocular = binocular _unit;
|
||||
|
||||
_selectBinocular = currentWeapon _unit == _binocular;
|
||||
|
||||
_unit addWeapon _binocular;
|
||||
|
||||
if (_selectBinocular) then {
|
||||
_unit selectWeapon _binocular;
|
||||
};
|
31
addons/common/functions/fnc_selectWeaponMode.sqf
Normal file
31
addons/common/functions/fnc_selectWeaponMode.sqf
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Unit selects given muzzle and weapon mode.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
* 1: weapon or Muzzle <STRING>
|
||||
* 2: weapon Mode <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Successful? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [player, primaryWeapon player, "FullAuto"] call ace_common_fnc_selectWeaponMode
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_muzzle", "_mode"];
|
||||
|
||||
local _index = 0;
|
||||
|
||||
while {
|
||||
_index < 100 && {currentMuzzle _unit != _muzzle || {currentWeaponMode _unit != _mode}}
|
||||
} do {
|
||||
_unit action ["SwitchWeapon", _unit, _unit, _index];
|
||||
_index = _index + 1;
|
||||
};
|
||||
|
||||
_index < 100 // return
|
172
addons/common/functions/fnc_setAllGear.sqf
Normal file
172
addons/common/functions/fnc_setAllGear.sqf
Normal file
@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Author: bux578, commy2
|
||||
* Applies gear to unit.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: All Gear based on return value of ACE_common_fnc_getAllGear <ARRAY>
|
||||
* 2: Remove all attachments from weapons? (default: false) <BOOL>
|
||||
* 3: Remove all items from prefilled backpacks? (default: false) <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, gear_array, true, true] call ace_common_fnc_setAllGear
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_allGear", ["_clearAttachments", false], ["_clearBackpack", false]];
|
||||
|
||||
// remove all starting gear of a player
|
||||
removeAllWeapons _unit;
|
||||
removeGoggles _unit;
|
||||
removeHeadgear _unit;
|
||||
removeVest _unit;
|
||||
removeUniform _unit;
|
||||
removeAllAssignedItems _unit;
|
||||
removeBackpack _unit;
|
||||
|
||||
_allGear params [
|
||||
"_headgear", "_goggles",
|
||||
"_uniform", "_uniformitems",
|
||||
"_vest", "_vestitems",
|
||||
"_backpack", "_backpackitems",
|
||||
"_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine",
|
||||
"_secondaryweapon", "_secondaryweaponitems", "_secondaryweaponmagazine",
|
||||
"_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine",
|
||||
"_assigneditems",
|
||||
"_binocular",
|
||||
"_binocularmagazine"
|
||||
];
|
||||
|
||||
// start restoring the items
|
||||
if (_headgear != "") then {_unit addHeadgear _headgear};
|
||||
if (_goggles != "") then {_unit addGoggles _goggles};
|
||||
|
||||
// ensure all weapons being loaded
|
||||
_unit addBackpack "ACE_FakeBackpack";
|
||||
|
||||
// primaryWeapon
|
||||
if (_primaryweapon != "") then {
|
||||
{
|
||||
_unit addMagazine _x;
|
||||
false
|
||||
} count _primaryweaponmagazine;
|
||||
|
||||
_unit addWeapon _primaryweapon;
|
||||
|
||||
if (_clearAttachments) then {
|
||||
removeAllPrimaryWeaponItems _unit;
|
||||
};
|
||||
|
||||
{
|
||||
if (_x != "") then {
|
||||
_unit addPrimaryWeaponItem _x;
|
||||
};
|
||||
false
|
||||
} count _primaryweaponitems;
|
||||
};
|
||||
|
||||
// secondaryWeapon
|
||||
if (_secondaryweapon != "") then {
|
||||
{
|
||||
_unit addMagazine _x;
|
||||
false
|
||||
} count _secondaryweaponmagazine;
|
||||
|
||||
_unit addWeapon _secondaryweapon;
|
||||
|
||||
if (_clearAttachments) then {
|
||||
//removeAllSecondaryWeaponItems _unit;
|
||||
{
|
||||
_unit removeSecondaryWeaponItem _x;
|
||||
false
|
||||
} count secondaryWeaponItems _unit;
|
||||
};
|
||||
|
||||
{
|
||||
if (_x != "") then {
|
||||
_unit addSecondaryWeaponItem _x;
|
||||
};
|
||||
false
|
||||
} count _secondaryweaponitems;
|
||||
};
|
||||
|
||||
// handgun
|
||||
if (_handgunweapon != "") then {
|
||||
{
|
||||
_unit addMagazine _x;
|
||||
false
|
||||
} count _handgunweaponmagazine;
|
||||
|
||||
_unit addWeapon _handgunweapon;
|
||||
|
||||
if (_clearAttachments) then {
|
||||
removeAllHandgunItems _unit;
|
||||
};
|
||||
|
||||
{
|
||||
if (_x != "") then {
|
||||
_unit addHandgunItem _x;
|
||||
};
|
||||
false
|
||||
} count _handgunweaponitems;
|
||||
};
|
||||
|
||||
// binocular
|
||||
_unit addWeapon _binocular;
|
||||
_unit addMagazine _binocularmagazine;
|
||||
|
||||
// done with dummy backpack. now remove
|
||||
removeBackpack _unit;
|
||||
|
||||
// uniform
|
||||
if (_uniform != "") then {
|
||||
_unit forceAddUniform _uniform;
|
||||
};
|
||||
|
||||
{
|
||||
_unit addItemToUniform _x;
|
||||
false
|
||||
} count _uniformitems;
|
||||
|
||||
// vest
|
||||
if (_vest != "") then {
|
||||
_unit addVest _vest;
|
||||
};
|
||||
|
||||
{
|
||||
_unit addItemToVest _x;
|
||||
false
|
||||
} count _vestitems;
|
||||
|
||||
// backpack
|
||||
if (_backpack != "") then {
|
||||
_unit addBackpack _backpack;
|
||||
|
||||
if (_clearBackpack) then {
|
||||
local _backpackObject = unitBackpack _unit;
|
||||
|
||||
clearMagazineCargoGlobal _backpackObject;
|
||||
clearWeaponCargoGlobal _backpackObject;
|
||||
clearItemCargoGlobal _backpackObject;
|
||||
};
|
||||
|
||||
{
|
||||
_unit addItemToBackpack _x;
|
||||
false
|
||||
} count _backpackitems;
|
||||
};
|
||||
|
||||
// assigned items
|
||||
_assignedItems deleteAt (_assignedItems find _binocular);
|
||||
|
||||
{
|
||||
_unit linkItem _x;
|
||||
false
|
||||
} count _assignedItems;
|
||||
|
||||
nil
|
@ -35,7 +35,7 @@ if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber
|
||||
_unit removeMagazines _magazine;
|
||||
|
||||
if (backpack _unit == "") then {
|
||||
_unit addBackpack "Bag_Base";
|
||||
_unit addBackpack "ACE_FakeBackpack";
|
||||
_unit removeWeapon _launcher;
|
||||
_unit addMagazine _magazine;
|
||||
_didAdd = _magazine in (magazines _unit);
|
||||
|
@ -24,7 +24,7 @@ if (ACE_player == _unit) then {
|
||||
|
||||
if (GVAR(SavePreDeathGear)) then {
|
||||
GVAR(unitGear) = [_unit] call EFUNC(common,getAllGear);
|
||||
GVAR(unitGear) pushBack [currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit];
|
||||
GVAR(unitGear) append [currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: bux578
|
||||
* Author: bux578, commy2
|
||||
* Restores previously saved gear.
|
||||
*
|
||||
* Arguments:
|
||||
@ -10,150 +10,16 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_Player, stored_allGear] call ace_respawn_fnc_restoreGear
|
||||
* [ACE_Player, stored_allGear, active_weapon_muzzle_and_mode] call ace_respawn_fnc_restoreGear
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_allGear"];
|
||||
params ["_unit", "_allGear", "_activeWeaponAndMuzzle"];
|
||||
|
||||
// remove all starting gear of a player
|
||||
removeAllWeapons _unit;
|
||||
removeGoggles _unit;
|
||||
removeHeadgear _unit;
|
||||
removeVest _unit;
|
||||
removeUniform _unit;
|
||||
removeAllAssignedItems _unit;
|
||||
clearAllItemsFromBackpack _unit;
|
||||
removeBackpack _unit;
|
||||
|
||||
_allGear params [
|
||||
"_headgear", "_goggles",
|
||||
"_uniform", "_uniformitems",
|
||||
"_vest", "_vestitems",
|
||||
"_backpack", "_backpackitems",
|
||||
"_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine",
|
||||
"_secondaryweapon", "_secondaryweaponitems", "_secondaryweaponmagazine",
|
||||
"_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine",
|
||||
"_assigneditems", "_binocular",
|
||||
"_activeWeaponAndMuzzle"
|
||||
];
|
||||
|
||||
// start restoring the items
|
||||
if (_headgear != "") then {_unit addHeadgear _headgear};
|
||||
if (_goggles != "") then {_unit addGoggles _goggles};
|
||||
if (_uniform != "") then {_unit forceAddUniform _uniform};
|
||||
if (_vest != "") then {_unit addVest _vest};
|
||||
|
||||
{
|
||||
_unit addItemToUniform _x;
|
||||
false
|
||||
} count _uniformitems;
|
||||
|
||||
{
|
||||
_unit addItemToVest _x;
|
||||
false
|
||||
} count _vestitems;
|
||||
|
||||
private "_flagRemoveDummyBag";
|
||||
|
||||
if (format ["%1", _backpack] != "") then {
|
||||
_unit addBackpack _backpack;
|
||||
|
||||
// make sure the backpack is empty. Some bags are prefilled by config
|
||||
private "_backpackObject";
|
||||
_backpackObject = unitBackpack _unit;
|
||||
|
||||
clearMagazineCargoGlobal _backpackObject;
|
||||
clearWeaponCargoGlobal _backpackObject;
|
||||
clearItemCargoGlobal _backpackObject;
|
||||
|
||||
{
|
||||
_unit addItemToBackpack _x;
|
||||
false
|
||||
} count _backpackitems;
|
||||
|
||||
_flagRemoveDummyBag = false;
|
||||
} else {
|
||||
// dummy backpack to ensure mags being loaded
|
||||
_unit addBackpack "Bag_Base";
|
||||
|
||||
_flagRemoveDummyBag = true;
|
||||
};
|
||||
|
||||
// primaryWeapon
|
||||
if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then {
|
||||
{
|
||||
_unit addMagazine _x;
|
||||
false
|
||||
} count _primaryweaponmagazine;
|
||||
|
||||
_unit addWeapon _primaryweapon;
|
||||
|
||||
{
|
||||
if (_x != "") then {
|
||||
_unit addPrimaryWeaponItem _x;
|
||||
};
|
||||
false
|
||||
} count _primaryweaponitems;
|
||||
};
|
||||
|
||||
// secondaryWeapon
|
||||
if (_secondaryweapon != "") then {
|
||||
{
|
||||
_unit addMagazine _x;
|
||||
false
|
||||
} count _secondaryweaponmagazine;
|
||||
|
||||
_unit addWeapon _secondaryweapon;
|
||||
|
||||
{
|
||||
if (_x != "") then {
|
||||
_unit addSecondaryWeaponItem _x;
|
||||
};
|
||||
false
|
||||
} count _secondaryweaponitems;
|
||||
};
|
||||
|
||||
// handgun
|
||||
if (_handgunweapon != "") then {
|
||||
{
|
||||
_unit addMagazine _x;
|
||||
false
|
||||
} count _handgunweaponmagazine;
|
||||
|
||||
_unit addWeapon _handgunweapon;
|
||||
|
||||
{
|
||||
if (_x != "") then {
|
||||
_unit addHandgunItem _x;
|
||||
};
|
||||
false
|
||||
} count _handgunweaponitems;
|
||||
};
|
||||
|
||||
// remove dummy bagpack
|
||||
if (_flagRemoveDummyBag) then {
|
||||
removeBackpack _unit;
|
||||
};
|
||||
|
||||
_assignedItems deleteAt (_assignedItems find _binocular);
|
||||
|
||||
// items
|
||||
{_unit linkItem _x; false} count _assignedItems;
|
||||
|
||||
_unit addWeapon _binocular;
|
||||
|
||||
// reload Laserdesignator
|
||||
// we assume that if the unit had a Laserdesignator it probably had batteries for it
|
||||
if ("Laserdesignator" in assignedItems _unit) then {
|
||||
_unit selectWeapon "Laserdesignator";
|
||||
|
||||
if (currentMagazine _unit == "") then {
|
||||
_unit addMagazine "Laserbatteries";
|
||||
};
|
||||
};
|
||||
// restore all gear
|
||||
[_unit, _allGear, true, true] call EFUNC(common,setAllGear);
|
||||
|
||||
// restore the last active weapon, muzzle and weaponMode
|
||||
_activeWeaponAndMuzzle params ["_activeWeapon", "_activeMuzzle", "_activeWeaponMode"];
|
||||
@ -171,8 +37,7 @@ if (
|
||||
};
|
||||
|
||||
if (currentWeapon _unit != "") then {
|
||||
private "_index";
|
||||
_index = 0;
|
||||
local _index = 0;
|
||||
|
||||
while {
|
||||
_index < 100 && {currentWeaponMode _unit != _activeWeaponMode}
|
||||
|
Loading…
Reference in New Issue
Block a user