mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
function to return attachments, muzzles with magazines and ammo, moved stuff around
This commit is contained in:
parent
66c026d4a0
commit
d12ba196c5
@ -95,6 +95,9 @@ PREP(getVehicleCrew);
|
||||
PREP(getVersion);
|
||||
PREP(getWeaponAzimuthAndInclination);
|
||||
PREP(getWeaponIndex);
|
||||
PREP(getWeaponModes);
|
||||
PREP(getWeaponMuzzles);
|
||||
PREP(getWeaponState);
|
||||
PREP(getWeaponType);
|
||||
PREP(getWindDirection);
|
||||
PREP(goKneeling);
|
||||
|
73
addons/common/functions/fnc_getWeaponState.sqf
Normal file
73
addons/common/functions/fnc_getWeaponState.sqf
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Return current state of the weapon. Attachments and magazines with ammo.
|
||||
*
|
||||
* Argument:
|
||||
* 0: A unit (Object)
|
||||
* 1: A weapon (String)
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weapon"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
|
||||
private "_muzzles";
|
||||
_muzzles = [_weapon] call FUNC(getWeaponMuzzles);
|
||||
|
||||
private "_weaponInfo";
|
||||
_weaponInfo = [];
|
||||
|
||||
switch (_weapon) do {
|
||||
case (primaryWeapon _unit): {
|
||||
_weaponInfo pushBack primaryWeaponItems _unit;
|
||||
|
||||
};
|
||||
|
||||
case (secondaryWeapon _unit): {
|
||||
_weaponInfo pushBack secondaryWeaponItems _unit;
|
||||
|
||||
};
|
||||
|
||||
case (handgunWeapon _unit): {
|
||||
_weaponInfo pushBack handgunItems _unit;
|
||||
|
||||
};
|
||||
|
||||
default {
|
||||
_weaponInfo pushBack ["","","",""];
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
// get loaded magazines and ammo
|
||||
private ["_magazines", "_ammo"];
|
||||
|
||||
_magazines = [];
|
||||
_ammo = [];
|
||||
|
||||
{
|
||||
_magazines pushBack "";
|
||||
_ammo pushBack 0;
|
||||
} forEach _muzzles;
|
||||
|
||||
{
|
||||
if (_x select 2) then {
|
||||
private "_index";
|
||||
_index = _muzzles find (_x select 4);
|
||||
|
||||
if (_index != -1) then {
|
||||
_magazines set [_index, _x select 0];
|
||||
_ammo set [_index, _x select 1];
|
||||
};
|
||||
};
|
||||
} forEach magazinesAmmoFull _unit;
|
||||
|
||||
_weaponInfo append [_muzzles, _magazines, _ammo];
|
||||
|
||||
_weaponInfo
|
@ -8,8 +8,6 @@ PREP(findNextGrenadeMagazine);
|
||||
PREP(findNextGrenadeMuzzle);
|
||||
PREP(fireSmokeLauncher);
|
||||
PREP(getSelectedGrenade);
|
||||
PREP(getWeaponModes);
|
||||
PREP(getWeaponMuzzles);
|
||||
PREP(playChangeFiremodeSound);
|
||||
PREP(putWeaponAway);
|
||||
PREP(selectGrenadeAll);
|
||||
|
@ -29,8 +29,8 @@ if (_weapon in (_unit getVariable [QEGVAR(safemode,safedWeapons), []])) exitWith
|
||||
|
||||
private ["_muzzles", "_modes"];
|
||||
|
||||
_muzzles = [_weapon] call FUNC(getWeaponMuzzles);
|
||||
_modes = [_weapon] call FUNC(getWeaponModes);
|
||||
_muzzles = [_weapon] call EFUNC(common,getWeaponMuzzles);
|
||||
_modes = [_weapon] call EFUNC(common,getWeaponModes);
|
||||
|
||||
|
||||
private ["_index", "_muzzle", "_mode"];
|
||||
|
@ -19,7 +19,7 @@ _weapon = _this select 1;
|
||||
if (_weapon == "") exitWith {};
|
||||
|
||||
private "_muzzles";
|
||||
_muzzles = [_weapon] call FUNC(getWeaponMuzzles);
|
||||
_muzzles = [_weapon] call EFUNC(common,getWeaponMuzzles);
|
||||
|
||||
if (currentWeapon _unit != _weapon) exitWith {
|
||||
if (count _muzzles > 1) then {
|
||||
|
Loading…
Reference in New Issue
Block a user