mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2550 from acemod/commoncleanup10
common code cleanup part 10, close #2319
This commit is contained in:
commit
414151de38
@ -208,6 +208,7 @@ PREP(getConfigGunner);
|
||||
PREP(getConfigCommander);
|
||||
PREP(getHitPoints);
|
||||
PREP(getHitPointsWithSelections);
|
||||
PREP(getSelectionsWithoutHitPoints);
|
||||
PREP(getReflectorsWithSelections);
|
||||
PREP(getLightProperties);
|
||||
PREP(getLightPropertiesWeapon);
|
||||
|
@ -1,23 +1,31 @@
|
||||
/**
|
||||
* fn_getFirstIntersection.sqf
|
||||
* @Descr: Returns the the first intersection with an object between two positions
|
||||
* @Author: Ruthberg
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
* Returns the the first intersection with terrain between two positions. @todo rewrite using lineIntersectsSurfaces?
|
||||
*
|
||||
* @Arguments: [position PositionASL, position PositionASL, accuracy FLOAT]
|
||||
* @Return: [intersects BOOL, intersection PositionASL]
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: PositionASL <ARRAY>
|
||||
* 1: PositionATL <ARRAY>
|
||||
* 2: Accuracy <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: Intersects <BOOL>
|
||||
* 1: Intersection Position ASL <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_distance", "_lower", "_upper", "_mid", "_intersections", "_result", "_dir"];
|
||||
params ["_source", "_destination", "_accuracy"];
|
||||
|
||||
PARAMS_3(_source,_destination,_accuracy);
|
||||
private ["_result", "_distance"];
|
||||
|
||||
_result = [false, [0, 0, 0]];
|
||||
|
||||
_distance = _source vectorDistance _destination;
|
||||
|
||||
if (count (lineIntersectsWith [_source, _destination]) > 0) then {
|
||||
if !(lineIntersectsWith [_source, _destination] isEqualTo []) then {
|
||||
private ["_lower", "_upper", "_mid", "_dir"];
|
||||
|
||||
_lower = 0;
|
||||
_upper = 1;
|
||||
_mid = 0.5;
|
||||
@ -27,9 +35,7 @@ if (count (lineIntersectsWith [_source, _destination]) > 0) then {
|
||||
while {(_upper - _lower) * _distance > _accuracy} do {
|
||||
_mid = _lower + (_upper - _lower) / 2;
|
||||
|
||||
_intersections = count (lineIntersectsWith [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))]);
|
||||
|
||||
if (_intersections > 0) then {
|
||||
if !(lineIntersectsWith [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))] isEqualTo []) then {
|
||||
_upper = _mid;
|
||||
} else {
|
||||
_lower = _mid;
|
||||
|
@ -1,23 +1,31 @@
|
||||
/**
|
||||
* fn_getFirstIntersection.sqf
|
||||
* @Descr: Returns the the first intersection with an object between two positions
|
||||
* @Author: Ruthberg
|
||||
/*
|
||||
* Author: Ruthberg
|
||||
* Returns the the first intersection with an object between two positions. @todo rewrite using lineIntersectsSurfaces?
|
||||
*
|
||||
* @Arguments: [position PositionASL, position PositionASL, accuracy FLOAT]
|
||||
* @Return: [intersects BOOL, intersection PositionASL]
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: PositionASL <ARRAY>
|
||||
* 1: PositionATL <ARRAY>
|
||||
* 2: Accuracy <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* 0: Intersects <BOOL>
|
||||
* 1: Intersection Position ASL <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_distance", "_lower", "_upper", "_mid", "_intersection", "_result", "_dir"];
|
||||
params ["_source", "_destination", "_accuracy"];
|
||||
|
||||
PARAMS_3(_source,_destination,_accuracy);
|
||||
private ["_result", "_distance"];
|
||||
|
||||
_result = [false, [0, 0, 0]];
|
||||
|
||||
_distance = _source vectorDistance _destination;
|
||||
|
||||
if (terrainIntersectASL [_source, _destination]) then {
|
||||
private ["_lower", "_upper", "_mid", "_dir"];
|
||||
|
||||
_lower = 0;
|
||||
_upper = 1;
|
||||
_mid = 0.5;
|
||||
@ -27,9 +35,7 @@ if (terrainIntersectASL [_source, _destination]) then {
|
||||
while {(_upper - _lower) * _distance > _accuracy} do {
|
||||
_mid = _lower + (_upper - _lower) / 2;
|
||||
|
||||
_intersection = terrainIntersectASL [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))];
|
||||
|
||||
if (_intersection) then {
|
||||
if (terrainIntersectASL [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))]) then {
|
||||
_upper = _mid;
|
||||
} else {
|
||||
_lower = _mid;
|
||||
|
@ -1,56 +1,19 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Returns all hitpoints of any vehicle. Non unique hitpoints in turrets are ignored.
|
||||
* Returns all hitpoints and their selections of any vehicle. Might contain duplicates if the turrets contain non unique hitpoints with different selection names.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A vehicle, not the classname (Object)
|
||||
* 0: Vehicle <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* The hitpoints (Array)
|
||||
* Hitpoints <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*
|
||||
* Deprecated
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_config", "_hitpoints", "_i"];
|
||||
params ["_vehicle"];
|
||||
|
||||
PARAMS_1(_vehicle);
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
|
||||
|
||||
_hitpoints = [];
|
||||
|
||||
// get all classes that can contain hitpoints
|
||||
private "_hitpointClasses";
|
||||
_hitpointClasses = [_config >> "HitPoints"];
|
||||
{
|
||||
private "_class";
|
||||
_class = ([_config, _x] call FUNC(getTurretConfigPath)) >> "HitPoints";
|
||||
|
||||
if (isClass _class) then {
|
||||
_hitpointClasses pushBack _class;
|
||||
};
|
||||
|
||||
} forEach allTurrets _vehicle;
|
||||
|
||||
// iterate through all classes with hitpoints and their parents
|
||||
{
|
||||
private "_class";
|
||||
_class = _x;
|
||||
|
||||
while {isClass _class} do {
|
||||
|
||||
for "_i" from 0 to (count _class - 1) do {
|
||||
private "_entry";
|
||||
_entry = configName (_class select _i);
|
||||
|
||||
if (!(_entry in _hitpoints) && {!isNil {_vehicle getHitPointDamage _entry}}) then {
|
||||
_hitpoints pushBack _entry;
|
||||
};
|
||||
};
|
||||
|
||||
_class = inheritsFrom _class;
|
||||
};
|
||||
|
||||
} forEach _hitpointClasses;
|
||||
|
||||
_hitpoints
|
||||
(getAllHitPointsDamage _vehicle select 0) - [""]
|
||||
|
@ -1,61 +1,25 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Returns all hitpoints and their selections of any vehicle. Might contain duplicates if the turrets contain non unique hitpoints with different selection names.
|
||||
* Returns all hitpoints and their respective selections of any vehicle. Might contain duplicates for non unique hitpoints in turrets.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A vehicle, not the classname (Object)
|
||||
* 0: Vehicle <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* The hitpoints with selections. Format: [hitpoints, selections]. They correspond by index. (Array)
|
||||
* 0: Hitpoints <ARRAY>
|
||||
* 1: Selections <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*
|
||||
* Deprecated
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_config", "_hitpoints", "_selections", "_i"];
|
||||
params ["_vehicle"];
|
||||
|
||||
PARAMS_1(_vehicle);
|
||||
private "_hitPointsWithSelections";
|
||||
_hitPointsWithSelections = getAllHitPointsDamage _vehicle;
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
|
||||
_hitPointsWithSelections resize 2;
|
||||
|
||||
_hitpoints = [];
|
||||
_selections = [];
|
||||
|
||||
// get all classes that can contain hitpoints
|
||||
private "_hitpointClasses";
|
||||
_hitpointClasses = [_config >> "HitPoints"];
|
||||
{
|
||||
private "_class";
|
||||
_class = ([_config, _x] call FUNC(getTurretConfigPath)) >> "HitPoints";
|
||||
|
||||
if (isClass _class) then {
|
||||
_hitpointClasses pushBack _class;
|
||||
};
|
||||
|
||||
} forEach allTurrets _vehicle;
|
||||
|
||||
// iterate through all classes with hitpoints and their parents
|
||||
{
|
||||
private "_class";
|
||||
_class = _x;
|
||||
|
||||
while {isClass _class} do {
|
||||
|
||||
for "_i" from 0 to (count _class - 1) do {
|
||||
if (isClass (_class select _i)) then {
|
||||
private ["_entry", "_selection"];
|
||||
_entry = configName (_class select _i);
|
||||
_selection = getText (_class select _i >> "name");
|
||||
|
||||
if (!(_selection in _selections) && {!isNil {_vehicle getHit _selection}}) then {
|
||||
_hitpoints pushBack _entry;
|
||||
_selections pushBack _selection;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_class = inheritsFrom _class;
|
||||
};
|
||||
|
||||
} forEach _hitpointClasses;
|
||||
|
||||
[_hitpoints, _selections]
|
||||
_hitPointsWithSelections
|
||||
|
@ -1,28 +1,28 @@
|
||||
/*
|
||||
* Author: VKing
|
||||
* Gets the current map's MGRS grid zone designator and 100km square.
|
||||
* Also gets longitude, latitude and altitude offset for the map
|
||||
* Also gets longitude, latitude and altitude offset for the map.
|
||||
* Writes return values to GVAR(MGRS_data) if run on the current map.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Optional: Map name, if undefined the current map is used (String)
|
||||
* 0: Map name (default: worldName) <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* 0: Grid zone designator (String)
|
||||
* 1: 100km square (String)
|
||||
* 2: GZD + 100km sq. as a single string (String)
|
||||
* Writes return values to GVAR(MGRS_data) if run on the current map
|
||||
* Return Value:
|
||||
* 0: Grid zone designator <STRING>
|
||||
* 1: 100km square <STRING>
|
||||
* 2: GZD + 100km sq. as a single string <STRING>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing", "_altitude"];
|
||||
params [["_map", worldName]];
|
||||
|
||||
DEFAULT_PARAM(0,_map,worldName);
|
||||
private ["_long", "_lat", "_altitude", "_UTM", "_easting", "_northing", "_zone", "_band", "_GZD"];
|
||||
|
||||
_long = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "longitude");
|
||||
_lat = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "latitude");
|
||||
_altitude = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "elevationOffset");
|
||||
_long = getNumber (configFile >> "CfgWorlds" >> _map >> "longitude");
|
||||
_lat = getNumber (configFile >> "CfgWorlds" >> _map >> "latitude");
|
||||
_altitude = getNumber (configFile >> "CfgWorlds" >> _map >> "elevationOffset");
|
||||
|
||||
if (_map in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; _altitude = 0; };
|
||||
if (_map in ["Altis", "Stratis"]) then { _lat = 40; _altitude = 0; };
|
||||
@ -46,11 +46,10 @@ if (_map in ["lingor"]) then { _lat = -4; _altitude = 0; };
|
||||
if (_map in ["Panthera3"]) then { _lat = 46; _altitude = 0; };
|
||||
if (_map in ["Kunduz"]) then { _lat = 37; _altitude = 400; };
|
||||
|
||||
|
||||
_UTM = [_long,_lat] call BIS_fnc_posDegToUTM;
|
||||
_easting = _UTM select 0;
|
||||
_northing = _UTM select 1;
|
||||
// _zone = _UTM select 2;
|
||||
//_zone = _UTM select 2;
|
||||
TRACE_4("",_UTM,_easting,_northing,_zone);
|
||||
|
||||
/*
|
||||
@ -76,9 +75,11 @@ _band = switch (true) do {
|
||||
case (_lat>8): {"P"};
|
||||
case (_lat>=0): {"N"};
|
||||
};
|
||||
*/
|
||||
*/
|
||||
|
||||
_zone = 1 + (floor ((_long + 180) / 6));
|
||||
_band = "Z";
|
||||
|
||||
if (_lat <= -80) then {
|
||||
_band = "A";
|
||||
} else {
|
||||
@ -86,13 +87,13 @@ if (_lat <= -80) then {
|
||||
_band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_lat / 8) + 10)), 1];
|
||||
};
|
||||
};
|
||||
|
||||
if (_map == "VR") then {_zone = 0; _band = "RV";};
|
||||
|
||||
_GZD = format ["%1%2",_zone,_band];
|
||||
TRACE_3("",_zone,_band,_GZD);
|
||||
|
||||
|
||||
private ["_set1","_set2","_set3","_set4","_set5","_set6","_metaE","_metaN","_letterE","_letterN","_grid100km"];
|
||||
private ["_set1", "_set2", "_set3", "_set4", "_set5", "_set6", "_metaE", "_metaN", "_letterE", "_letterN", "_grid100km"];
|
||||
|
||||
_set1 = [1,7,13,19,25,31,37,43,49,55];
|
||||
_set2 = [2,8,14,20,26,32,38,44,50,56];
|
||||
@ -102,25 +103,25 @@ _set5 = [5,11,17,23,29,35,41,47,53,59];
|
||||
_set6 = [6,12,18,24,30,36,42,48,54,60];
|
||||
|
||||
switch (true) do {
|
||||
case (_zone in _set1): {_metaE = 1; _metaN = 1;};
|
||||
case (_zone in _set2): {_metaE = 2; _metaN = 2;};
|
||||
case (_zone in _set3): {_metaE = 3; _metaN = 1;};
|
||||
case (_zone in _set4): {_metaE = 1; _metaN = 2;};
|
||||
case (_zone in _set5): {_metaE = 2; _metaN = 1;};
|
||||
case (_zone in _set6): {_metaE = 3; _metaN = 2;};
|
||||
case (_zone in _set1): {_metaE = 1; _metaN = 1;};
|
||||
case (_zone in _set2): {_metaE = 2; _metaN = 2;};
|
||||
case (_zone in _set3): {_metaE = 3; _metaN = 1;};
|
||||
case (_zone in _set4): {_metaE = 1; _metaN = 2;};
|
||||
case (_zone in _set5): {_metaE = 2; _metaN = 1;};
|
||||
case (_zone in _set6): {_metaE = 3; _metaN = 2;};
|
||||
};
|
||||
TRACE_2("",_metaE,_metaN);
|
||||
|
||||
switch (true) do {
|
||||
case (_zone == 0): {_letterE = "E"};
|
||||
case (_easting > 800000): {LOG("E8"); switch (_metaE) do {case 1: {_letterE="H"}; case 2: {_letterE="R"}; case 3: {_letterE="Z"}; }; };
|
||||
case (_easting > 700000): {LOG("E7"); switch (_metaE) do {case 1: {_letterE="G"}; case 2: {_letterE="Q"}; case 3: {_letterE="Y"}; }; };
|
||||
case (_easting > 600000): {LOG("E6"); switch (_metaE) do {case 1: {_letterE="F"}; case 2: {_letterE="P"}; case 3: {_letterE="X"}; }; };
|
||||
case (_easting > 500000): {LOG("E5"); switch (_metaE) do {case 1: {_letterE="E"}; case 2: {_letterE="N"}; case 3: {_letterE="W"}; }; };
|
||||
case (_easting > 400000): {LOG("E4"); switch (_metaE) do {case 1: {_letterE="D"}; case 2: {_letterE="M"}; case 3: {_letterE="V"}; }; };
|
||||
case (_easting > 300000): {LOG("E3"); switch (_metaE) do {case 1: {_letterE="C"}; case 2: {_letterE="L"}; case 3: {_letterE="U"}; }; };
|
||||
case (_easting > 200000): {LOG("E2"); switch (_metaE) do {case 1: {_letterE="B"}; case 2: {_letterE="K"}; case 3: {_letterE="T"}; }; };
|
||||
case (_easting > 100000): {LOG("E1"); switch (_metaE) do {case 1: {_letterE="A"}; case 2: {_letterE="J"}; case 3: {_letterE="S"}; }; };
|
||||
case (_zone == 0): {_letterE = "E"};
|
||||
case (_easting > 800000): {LOG("E8"); switch (_metaE) do {case 1: {_letterE="H"}; case 2: {_letterE="R"}; case 3: {_letterE="Z"}; }; };
|
||||
case (_easting > 700000): {LOG("E7"); switch (_metaE) do {case 1: {_letterE="G"}; case 2: {_letterE="Q"}; case 3: {_letterE="Y"}; }; };
|
||||
case (_easting > 600000): {LOG("E6"); switch (_metaE) do {case 1: {_letterE="F"}; case 2: {_letterE="P"}; case 3: {_letterE="X"}; }; };
|
||||
case (_easting > 500000): {LOG("E5"); switch (_metaE) do {case 1: {_letterE="E"}; case 2: {_letterE="N"}; case 3: {_letterE="W"}; }; };
|
||||
case (_easting > 400000): {LOG("E4"); switch (_metaE) do {case 1: {_letterE="D"}; case 2: {_letterE="M"}; case 3: {_letterE="V"}; }; };
|
||||
case (_easting > 300000): {LOG("E3"); switch (_metaE) do {case 1: {_letterE="C"}; case 2: {_letterE="L"}; case 3: {_letterE="U"}; }; };
|
||||
case (_easting > 200000): {LOG("E2"); switch (_metaE) do {case 1: {_letterE="B"}; case 2: {_letterE="K"}; case 3: {_letterE="T"}; }; };
|
||||
case (_easting > 100000): {LOG("E1"); switch (_metaE) do {case 1: {_letterE="A"}; case 2: {_letterE="J"}; case 3: {_letterE="S"}; }; };
|
||||
default {_letterE="@"};
|
||||
};
|
||||
TRACE_1("",_letterE);
|
||||
@ -129,37 +130,38 @@ _northing = _northing mod 2000000;
|
||||
TRACE_1("",_northing);
|
||||
|
||||
switch (true) do {
|
||||
case (_zone == 0): {_letterN = "N"};
|
||||
case (_northing > 1900000): {LOG("N19"); switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; };
|
||||
case (_northing > 1800000): {LOG("N18"); switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; };
|
||||
case (_northing > 1700000): {LOG("N17"); switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; };
|
||||
case (_northing > 1600000): {LOG("N16"); switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; };
|
||||
case (_northing > 1500000): {LOG("N15"); switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; };
|
||||
case (_northing > 1400000): {LOG("N14"); switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; };
|
||||
case (_northing > 1300000): {LOG("N13"); switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; };
|
||||
case (_northing > 1200000): {LOG("N12"); switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; };
|
||||
case (_northing > 1100000): {LOG("N11"); switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; };
|
||||
case (_northing > 1000000): {LOG("N10"); switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; };
|
||||
case (_northing > 900000): {LOG("N09"); switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; };
|
||||
case (_northing > 800000): {LOG("N08"); switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; };
|
||||
case (_northing > 700000): {LOG("N07"); switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; };
|
||||
case (_northing > 600000): {LOG("N06"); switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; };
|
||||
case (_northing > 500000): {LOG("N05"); switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; };
|
||||
case (_northing > 400000): {LOG("N04"); switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; };
|
||||
case (_northing > 300000): {LOG("N03"); switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; };
|
||||
case (_northing > 200000): {LOG("N02"); switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; };
|
||||
case (_northing > 100000): {LOG("N01"); switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; };
|
||||
case (_northing > 0): {LOG("N00"); switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; };
|
||||
case (_zone == 0): {_letterN = "N"};
|
||||
case (_northing > 1900000): {LOG("N19"); switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; };
|
||||
case (_northing > 1800000): {LOG("N18"); switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; };
|
||||
case (_northing > 1700000): {LOG("N17"); switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; };
|
||||
case (_northing > 1600000): {LOG("N16"); switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; };
|
||||
case (_northing > 1500000): {LOG("N15"); switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; };
|
||||
case (_northing > 1400000): {LOG("N14"); switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; };
|
||||
case (_northing > 1300000): {LOG("N13"); switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; };
|
||||
case (_northing > 1200000): {LOG("N12"); switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; };
|
||||
case (_northing > 1100000): {LOG("N11"); switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; };
|
||||
case (_northing > 1000000): {LOG("N10"); switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; };
|
||||
case (_northing > 900000): {LOG("N09"); switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; };
|
||||
case (_northing > 800000): {LOG("N08"); switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; };
|
||||
case (_northing > 700000): {LOG("N07"); switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; };
|
||||
case (_northing > 600000): {LOG("N06"); switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; };
|
||||
case (_northing > 500000): {LOG("N05"); switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; };
|
||||
case (_northing > 400000): {LOG("N04"); switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; };
|
||||
case (_northing > 300000): {LOG("N03"); switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; };
|
||||
case (_northing > 200000): {LOG("N02"); switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; };
|
||||
case (_northing > 100000): {LOG("N01"); switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; };
|
||||
case (_northing > 0): {LOG("N00"); switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; };
|
||||
};
|
||||
TRACE_1("",_letterN);
|
||||
|
||||
_grid100km = _letterE+_letterN;
|
||||
_grid100km = _letterE + _letterN;
|
||||
TRACE_1("",_grid100km);
|
||||
|
||||
if (_map == worldName) then {
|
||||
GVAR(MGRS_data) = [_GZD,_grid100km,_GZD+_grid100km];
|
||||
GVAR(MGRS_data) = [_GZD, _grid100km, _GZD + _grid100km];
|
||||
GVAR(mapAltitude) = _altitude;
|
||||
GVAR(mapLatitude) = _lat;
|
||||
GVAR(mapLongitude) = _long;
|
||||
};
|
||||
[_GZD,_grid100km,_GZD+_grid100km]
|
||||
|
||||
[_GZD, _grid100km, _GZD + _grid100km]
|
||||
|
@ -1,12 +1,13 @@
|
||||
/*
|
||||
* Author: PabstMirror (ideas from Nou's mapGridToPos and BIS_fnc_gridToPos)
|
||||
* Author: PabstMirror
|
||||
* Finds real x/y offset and map step for a 10 digit grid
|
||||
* Save time by preparing data one time at startup
|
||||
* Ideas from Nou's mapGridToPos and BIS_fnc_gridToPos
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return values:
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
@ -16,10 +17,10 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private["_cfgGrid", "_formatX", "_formatY", "_heightOffset", "_offsetX", "_offsetY", "_originGrid", "_realOffsetY", "_startGrid", "_stepX", "_stepY", "_zoom", "_zoomMax", "_letterGrid"];
|
||||
|
||||
GVAR(mapGridData) = [];
|
||||
|
||||
private ["_cfgGrid", "_offsetX", "_offsetY", "_zoomMax", "_formatX", "_formatY", "_stepX", "_stepY", "_zoom", "_letterGrid", "_heightOffset", "_startGrid", "_originGrid", "_realOffsetY"];
|
||||
|
||||
//--- Extract grid values from world config (Borrowed from BIS_fnc_gridToPos)
|
||||
_cfgGrid = configFile >> "CfgWorlds" >> worldName >> "Grid";
|
||||
_offsetX = getNumber (_cfgGrid >> "offsetX");
|
||||
@ -29,6 +30,7 @@ _formatX = "";
|
||||
_formatY = "";
|
||||
_stepX = 1e10;
|
||||
_stepY = 1e10;
|
||||
|
||||
{
|
||||
_zoom = getnumber (_x >> "zoomMax");
|
||||
if (_zoom < _zoomMax) then {
|
||||
@ -38,11 +40,14 @@ _stepY = 1e10;
|
||||
_stepX = getNumber (_x >> "stepX");
|
||||
_stepY = getNumber (_x >> "stepY");
|
||||
};
|
||||
} foreach configProperties [_cfgGrid, "isClass _x", false];
|
||||
false
|
||||
} count configProperties [_cfgGrid, "isClass _x", false];
|
||||
|
||||
_letterGrid = false;
|
||||
if (((toLower _formatX) find "a") != -1) then {_letterGrid = true};
|
||||
if (((toLower _formatY) find "a") != -1) then {_letterGrid = true};
|
||||
|
||||
if (toLower _formatX find "a" != -1) then {_letterGrid = true};
|
||||
if (toLower _formatY find "a" != -1) then {_letterGrid = true};
|
||||
|
||||
if (_letterGrid) exitWith {
|
||||
ACE_LOGWARNING_3("Map Grid Warning (%1) - Map uses letter grids [%2, %3]",worldName,_formatX,_formatY);
|
||||
};
|
||||
@ -51,13 +56,14 @@ if (_letterGrid) exitWith {
|
||||
_heightOffset = 500;
|
||||
_startGrid = mapGridPosition [0, _heightOffset];
|
||||
_originGrid = _startGrid;
|
||||
|
||||
while {_startGrid == _originGrid} do {
|
||||
_heightOffset = _heightOffset + 1;
|
||||
_originGrid = mapGridPosition [0, _heightOffset];
|
||||
};
|
||||
|
||||
//Calculate the real y offset
|
||||
_realOffsetY = parseNumber (_originGrid select [(count _formatX), (count _formatY)]) * _stepY + _heightOffset - 1;
|
||||
_realOffsetY = (parseNumber (_originGrid select [count _formatX, count _formatY])) * _stepY + _heightOffset - 1;
|
||||
|
||||
//Calculate MGRS 10digit step - they should both be 1 meter:
|
||||
_stepXat5 = _stepX * 10 ^ ((count _formatX) - 5);
|
||||
@ -66,10 +72,12 @@ _stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5);
|
||||
if (_stepYat5 < 0) then {
|
||||
ACE_LOGWARNING_1("Map Grid Warning (%1) - Northing is reversed.",worldName);
|
||||
};
|
||||
|
||||
if (_stepXat5 != 1) then {
|
||||
ACE_LOGWARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for x.",worldName,_stepXat5);
|
||||
};
|
||||
if ((_stepYat5 != 1) && {_stepYat5 != -1}) then {
|
||||
|
||||
if (_stepYat5 != 1 && {_stepYat5 != -1}) then {
|
||||
ACE_LOGWARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for y.",worldName,_stepXat5);
|
||||
};
|
||||
|
||||
|
@ -2,57 +2,58 @@
|
||||
* Author: VKing, PabstMirror
|
||||
* Gets a 10-digit map grid for the given world position
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* 0: Position (2D Position) <ARRAY>
|
||||
* 1: Return type; false for array of easting and northing, true for single string <Bool>
|
||||
* 1: Return type; false for array of easting and northing, true for single string (default: false) <BOOL>
|
||||
*
|
||||
* Return values:
|
||||
* Return Value:
|
||||
* 0: Easting <String>
|
||||
* 1: Northing <String>
|
||||
*
|
||||
* Example:
|
||||
* [(getPos player)] call ace_common_fnc_getMapGridFromPos;
|
||||
* [getPos player] call ace_common_fnc_getMapGridFromPos
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
// #define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_pos);
|
||||
DEFAULT_PARAM(1,_returnSingleString,false);
|
||||
params ["_pos", ["_returnSingleString", false]];
|
||||
|
||||
private["_count", "_easting", "_nativeGrid", "_northing"];
|
||||
private ["_nativeGrid", "_count", "_easting", "_northing"];
|
||||
|
||||
//Fallback, when map data is weird (letters)
|
||||
if ((count GVAR(mapGridData)) == 0) exitWith {
|
||||
if (GVAR(mapGridData) isEqualTo []) exitWith {
|
||||
_nativeGrid = mapGridPosition _pos;
|
||||
|
||||
if (_returnSingleString) then {
|
||||
_nativeGrid
|
||||
} else {
|
||||
_count = floor ((count _nativeGrid) / 2);
|
||||
[(_nativeGrid select [0, _count]), (_nativeGrid select [_count, _count])]
|
||||
[_nativeGrid select [0, _count], _nativeGrid select [_count, _count]]
|
||||
};
|
||||
};
|
||||
|
||||
EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5);
|
||||
GVAR(mapGridData) params ["_offsetX", "_realOffsetY", "_stepXat5", "_stepYat5"];
|
||||
|
||||
_easting = floor (((_pos select 0) - _offsetX) / _stepXat5);
|
||||
_northing = floor (((_pos select 1) - _realOffsetY) / _stepYat5);
|
||||
|
||||
//Attempt to handle negative east/north (e.g.: moving west of map bounds)
|
||||
if (_easting > 0) then {
|
||||
_easting = str _easting;
|
||||
while {count _easting < 5} do {_easting = "0" + _easting;};
|
||||
while {count _easting < 5} do {_easting = "0" + _easting};
|
||||
} else {
|
||||
_easting = str abs _easting;
|
||||
while {count _easting < 4} do {_easting = "0" + _easting;};
|
||||
while {count _easting < 4} do {_easting = "0" + _easting};
|
||||
_easting = "-" + _easting;
|
||||
};
|
||||
|
||||
if (_northing > 0) then {
|
||||
_northing = str _northing;
|
||||
while {count _northing < 5} do {_northing = "0" + _northing;};
|
||||
while {count _northing < 5} do {_northing = "0" + _northing};
|
||||
} else {
|
||||
_northing = str abs _northing;
|
||||
while {count _northing < 4} do {_northing = "0" + _northing;};
|
||||
while {count _northing < 4} do {_northing = "0" + _northing};
|
||||
_northing = "-" + _northing;
|
||||
};
|
||||
|
||||
@ -60,4 +61,4 @@ if (_returnSingleString) then {
|
||||
_easting + _northing
|
||||
} else {
|
||||
[_easting, _northing]
|
||||
};
|
||||
}; // return
|
||||
|
@ -2,9 +2,9 @@
|
||||
* Author: PabstMirror
|
||||
* Gets position from grid cords
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* 0: Grid Cords <STRING>
|
||||
* 1: Get Center or bottom right <BOOL><OPTIONAL>
|
||||
* 1: Grid center (true), Grid Bottom Right (false) (default: true) <BOOL>
|
||||
*
|
||||
* Return values:
|
||||
* Position <ARRAY>
|
||||
@ -16,24 +16,23 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_inputString);
|
||||
DEFAULT_PARAM(1,_getCenterOfGrid,true);
|
||||
params ["_inputString", ["_getCenterOfGrid", true]];
|
||||
|
||||
private["_countInput", "_countInputHalf", "_xPart", "_xPos", "_yPart", "_yPos"];
|
||||
|
||||
if ((count GVAR(mapGridData)) == 0) exitWith {
|
||||
if (count GVAR(mapGridData) == 0) exitWith {
|
||||
ERROR("Map has bad data, falling back to BIS_fnc_gridToPos");
|
||||
(_this call BIS_fnc_gridToPos) select 0
|
||||
};
|
||||
|
||||
EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5);
|
||||
GVAR(mapGridData) params ["_offsetX", "_realOffsetY", "_stepXat5", "_stepYat5"];
|
||||
|
||||
private ["_countInput", "_countInputHalf", "_xPart", "_yPart", "_xPos", "_yPos"];
|
||||
|
||||
_countInput = count _inputString;
|
||||
_countInputHalf = floor (_countInput / 2);
|
||||
|
||||
//Split string, ignoring middle
|
||||
_xPart = _inputString select [0, _countInputHalf];
|
||||
_yPart = _inputString select [(ceil (_countInput / 2)), _countInputHalf];
|
||||
_yPart = _inputString select [ceil (_countInput / 2), _countInputHalf];
|
||||
|
||||
_xPos = ((parseNumber _xPart) * _stepXat5 * 10 ^ (5 - _countInputHalf)) + _offsetX;
|
||||
_yPos = ((parseNumber _yPart) * _stepYat5 * 10 ^ (5 - _countInputHalf)) + _realOffsetY;
|
||||
@ -43,4 +42,4 @@ if (_getCenterOfGrid) then {
|
||||
_yPos = _yPos + 0.5 * _stepYat5 * 10 ^ (5 - _countInputHalf);
|
||||
};
|
||||
|
||||
[_xPos, _yPos, 0];
|
||||
[_xPos, _yPos, 0]
|
||||
|
@ -1,19 +1,20 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi
|
||||
*
|
||||
* Get the apropriate marker for a group.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Group
|
||||
*
|
||||
* Return Value:
|
||||
* Marker Type (string)
|
||||
* Marker Type <STRING>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_leader","_vehicle","_side"];
|
||||
params ["_group"];
|
||||
|
||||
PARAMS_1(_group);
|
||||
private ["_leader", "_vehicle", "_side"];
|
||||
|
||||
_leader = leader _group;
|
||||
_vehicle = vehicle _leader;
|
||||
@ -21,56 +22,61 @@ _side = side _leader;
|
||||
|
||||
if (_vehicle == _leader) exitWith {
|
||||
if (
|
||||
(getNumber (configFile >> "CfgVehicles" >> (typeOf _leader) >> "detectSkill") > 20) or
|
||||
(getNumber (configFile >> "CfgVehicles" >> (typeOf _leader) >> "camouflage") < 1) or
|
||||
(getText (configFile >> "CfgVehicles" >> (typeOf _leader) >> "textsingular") == "diver")
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _leader >> "detectSkill") > 20 ||
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _leader >> "camouflage") < 1 ||
|
||||
getText (configFile >> "CfgVehicles" >> typeOf _leader >> "textsingular") == "diver"
|
||||
) then {
|
||||
["n_recon", "b_recon", "o_recon"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_recon", "b_recon", "o_recon"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
} else {
|
||||
["n_inf", "b_inf", "o_inf"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_inf", "b_inf", "o_inf"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
};
|
||||
|
||||
if (getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "attendant") == 1) exitWith {
|
||||
["n_med", "b_med", "o_med"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "attendant") == 1) exitWith {
|
||||
["n_med", "b_med", "o_med"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
|
||||
if (
|
||||
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportRepair") > 0) or
|
||||
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportFuel") > 0) or
|
||||
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportAmmo") > 0) or
|
||||
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "ACE_canRepair") > 0) or
|
||||
(getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "ACE_fuelCapacityCargo") > 0)
|
||||
) exitWith {
|
||||
["n_maint", "b_maint", "o_maint"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportRepair") > 0 ||
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportFuel") > 0 ||
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportAmmo") > 0 ||
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "ACE_canRepair") > 0 ||
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "ACE_fuelCapacityCargo") > 0
|
||||
) exitWith {
|
||||
["n_maint", "b_maint", "o_maint"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
|
||||
if (_vehicle isKindOf "Plane") exitWith {
|
||||
["n_plane", "b_plane", "o_plane"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_plane", "b_plane", "o_plane"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
|
||||
if (_vehicle isKindOf "Air") exitWith {
|
||||
["n_air", "b_air", "o_air"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_air", "b_air", "o_air"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
|
||||
if (_vehicle isKindOf "StaticMortar") exitWith {
|
||||
["n_mortar", "b_mortar", "o_mortar"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_mortar", "b_mortar", "o_mortar"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
if (getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "artilleryScanner") == 1) exitWith {
|
||||
["n_art", "b_art", "o_art"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
|
||||
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "artilleryScanner") == 1) exitWith {
|
||||
["n_art", "b_art", "o_art"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
|
||||
if (_vehicle isKindOf "Car") exitWith {
|
||||
["n_motor_inf", "b_motor_inf", "o_motor_inf"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
};
|
||||
if ((_vehicle isKindOf "Tank") and (getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "transportSoldier") > 0)) exitWith {
|
||||
["n_mech_inf", "b_mech_inf", "o_mech_inf"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_motor_inf", "b_motor_inf", "o_motor_inf"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
|
||||
if (_vehicle isKindOf "Tank") exitWith {
|
||||
["n_armor", "b_armor", "o_armor"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportSoldier") > 0) then {
|
||||
["n_mech_inf", "b_mech_inf", "o_mech_inf"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
} else {
|
||||
["n_armor", "b_armor", "o_armor"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
};
|
||||
|
||||
if (_vehicle isKindOf "Ship") exitWith {
|
||||
["n_naval", "b_naval", "o_naval"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_naval", "b_naval", "o_naval"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
};
|
||||
|
||||
// generic marker
|
||||
["n_unknown", "b_unknown", "o_unknown"] select ((["GUER", "WEST", "EAST"] find (str _side)) max 0)
|
||||
["n_unknown", "b_unknown", "o_unknown"] select ((["GUER", "WEST", "EAST"] find str _side) max 0)
|
||||
|
@ -1,18 +1,16 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get a number from the mission.sqm file. Mission has to be saved in the Editor.
|
||||
* On non-existing entries, it might return 0 or the value of an entry with the same name of another calss.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Path of the entry in the mission.sqm (Array)
|
||||
* Arguments:
|
||||
* 0: Path of the entry in the mission.sqm <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* Value of the entry. Note: If the entry does not exist, it might return 0 or an entry with the same name of another class! (Number)
|
||||
* Return Value:
|
||||
* Entry value <NUMBER>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_number";
|
||||
|
||||
_number = _this call FUNC(getStringFromMissionSQM);
|
||||
|
||||
parseNumber _number;
|
||||
parseNumber (_this call FUNC(getStringFromMissionSQM)) // return
|
||||
|
@ -1,26 +1,30 @@
|
||||
/**
|
||||
* fn_getNumberMagazinesIn.sqf
|
||||
* @Descr:
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Count magazines of unit.
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Magazine <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Magazine amount <NUMBER>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_magazine);
|
||||
|
||||
private ["_return"];
|
||||
params ["_unit", "_magazine"];
|
||||
|
||||
private "_return";
|
||||
_return = 0;
|
||||
|
||||
if (_unit isKindOf "CAManBase") then {
|
||||
_return = {_x == _magazine} count magazines _unit;
|
||||
} else {
|
||||
{
|
||||
_return = _return + {_x == _magazine} count magazines _x;
|
||||
} forEach (crew _unit);
|
||||
false
|
||||
} count crew _unit;
|
||||
|
||||
_return = _return + ({_x == _magazine} count getMagazineCargo _unit);
|
||||
};
|
||||
|
@ -14,6 +14,6 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicle"];
|
||||
params ["_vehicle"];
|
||||
|
||||
(_vehicle call BIS_fnc_getPitchBank) + [getDir _vehicle]
|
||||
|
@ -6,16 +6,19 @@
|
||||
* They behave like having an armor value of 0.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A vehicle, not the classname (Object)
|
||||
* 0: Vehicle <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* The light names and selections (Array)
|
||||
* 0: Light Hitpoints <ARRAY>
|
||||
* 1: Selections <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_config", "_hitpoints", "_selections", "_i"];
|
||||
params ["_vehicle"];
|
||||
|
||||
PARAMS_1(_vehicle);
|
||||
private ["_config", "_hitpoints", "_selections"];
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Returns all damageable selections without hitpoints of any vehicle.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A vehicle, not the classname (Object)
|
||||
*
|
||||
* Return Value:
|
||||
* The selections without hitpoints, i.e. reflectors. (Array)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_vehicle"];
|
||||
|
||||
private ["_hitPointsFull", "_allSelectionsWithoutHitpoints"];
|
||||
|
||||
_hitPointsFull = getAllHitPointsDamage _vehicle;
|
||||
|
||||
_allSelectionsWithoutHitpoints = [];
|
||||
|
||||
{
|
||||
if (_x == "") then {
|
||||
_allSelectionsWithoutHitpoints pushBack (_hitPointsFull select 1 select _forEachIndex);
|
||||
};
|
||||
} forEach (_hitPointsFull select 0);
|
||||
|
||||
_allSelectionsWithoutHitpoints
|
@ -3,29 +3,32 @@
|
||||
* Returns the metadata of a setting if it exists
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Name of the setting (String)
|
||||
* 0: Setting Name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Setting Data (Array)
|
||||
* 0: _name
|
||||
* 1: _typeName
|
||||
* 2: _isClientSetable
|
||||
* 3: _localizedName
|
||||
* 4: _localizedDescription
|
||||
* 5: _possibleValues
|
||||
* 6: _isForced
|
||||
* 7: _defaultValue
|
||||
* 0: Name <STRING>
|
||||
* 1: Type Name <STRING>
|
||||
* 2: Is Client Settable <BOOL>
|
||||
* 3: Localized Name <STRING>
|
||||
* 4: Localized Description <STRING>
|
||||
* 5: Possible Values <ARRAY>
|
||||
* 6: Is Forced <BOOL>
|
||||
* 7: Default Value <ANY>
|
||||
* 8: Localized Category <STRING>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_name);
|
||||
params ["_name"];
|
||||
|
||||
private ["_value"];
|
||||
private "_value";
|
||||
_value = [];
|
||||
|
||||
{
|
||||
if ((_x select 0) == _name) exitWith {_value = _x};
|
||||
} forEach GVAR(settings);
|
||||
if (_x select 0 == _name) exitWith {_value = _x};
|
||||
false
|
||||
} count GVAR(settings);
|
||||
|
||||
_value
|
||||
|
@ -1,28 +1,34 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get a string from the mission.sqm file. Mission has to be saved in the Editor.
|
||||
* The string cannot contain the ; character.
|
||||
* If the entry does not exist, it might return an empty string or an entry with the same name of another class!
|
||||
*
|
||||
* Get a string from the mission.sqm file. Mission has to be saved in the Editor. The string cannot contain the ; character.
|
||||
* Arguments:
|
||||
* 0: Path of the entry in the mission.sqm <ARRAY>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Path of the entry in the mission.sqm (Array)
|
||||
* Return Value:
|
||||
* Value of the entry. <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Value of the entry. Note: If the entry does not exist, it might return an empty string or an entry with the same name of another class! (String)
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_path", "_mission", "_a", "_class", "_index", "_array", "_b", "_entry"];
|
||||
private ["_path", "_mission", "_class", "_index", "_array", "_entry"];
|
||||
|
||||
_path = _this;
|
||||
|
||||
if (missionName == "") exitWith {""};
|
||||
|
||||
_mission = toArray toLower loadFile "mission.sqm";
|
||||
_mission resize 65536;
|
||||
|
||||
{
|
||||
if (_x < 33) then {
|
||||
_mission set [_forEachIndex, -1];
|
||||
}
|
||||
} forEach _mission;
|
||||
|
||||
_mission = toString (_mission - [-1]);
|
||||
|
||||
{_path set [_forEachIndex, toLower _x]} forEach _path;
|
||||
@ -33,9 +39,11 @@ for "_a" from 0 to (count _path - 2) do {
|
||||
_index = _mission find _class;
|
||||
|
||||
_array = toArray _mission;
|
||||
|
||||
for "_b" from 0 to (_index + count toArray _class - 1) do {
|
||||
_array set [_b, -1];
|
||||
};
|
||||
|
||||
_array = _array - [-1];
|
||||
|
||||
_mission = toString _array;
|
||||
@ -43,16 +51,20 @@ for "_a" from 0 to (count _path - 2) do {
|
||||
|
||||
_entry = format ["%1=", _path select (count _path - 1)];
|
||||
_index = _mission find _entry;
|
||||
|
||||
if (_index == -1) exitWith {""};
|
||||
|
||||
_array = toArray _mission;
|
||||
|
||||
for "_b" from 0 to (_index + count toArray _entry - 1) do {
|
||||
_array set [_b, -1];
|
||||
};
|
||||
|
||||
_mission = toString (_array - [-1]);
|
||||
|
||||
_index = _mission find ";";
|
||||
|
||||
_mission = toArray _mission;
|
||||
_mission resize _index;
|
||||
format ["%1", toString _mission];
|
||||
|
||||
format ["%1", toString _mission] // return
|
||||
|
@ -1,14 +1,15 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get players viewing direction and slope.
|
||||
*
|
||||
* Get players viewing direction and slope
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Argument:
|
||||
* None.
|
||||
* Return Value:
|
||||
* 0: Azimuth <NUMBER>
|
||||
* 1: Inclination <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* 0: Azimuth (Number)
|
||||
* 1: Inclination or 'slope' (Number)
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,21 +1,22 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the distance to the next object the player is looking at. Used for laser distance measurements.
|
||||
*
|
||||
* Argument:
|
||||
* 0: How accurate will the measurement be? In meters. (Number)
|
||||
* 1: Maximal distance to measure. (Number)
|
||||
* 2: Minimal distance to measure. (optional, Number)
|
||||
* Arguments:
|
||||
* 0: Messurement Accuracy <NUMBER>
|
||||
* 1: Maximal messure distance <NUMBER>
|
||||
* 2: Minimal messure distance (default: nil) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Measured distance in meters. Can return maximal or minimal distance (Number)
|
||||
* Return Value:
|
||||
* Distance in meters <NUMBER>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_position", "_laser", "_line", "_distance", "_iteration"];
|
||||
params ["_interval", "_maxDistance", "_minDistance"];
|
||||
|
||||
PARAMS_3(_interval,_maxDistance,_minDistance);
|
||||
private ["_position", "_laser", "_line", "_distance", "_iteration"];
|
||||
|
||||
_position = ATLToASL positionCameraToWorld [0, 0, 0];
|
||||
_position set [2, (_position select 2) - (getTerrainHeightASL _position min 0)];
|
||||
@ -42,6 +43,6 @@ _distance = _interval * round (_distance / _interval);
|
||||
|
||||
_distance = _distance min _maxDistance;
|
||||
|
||||
if !(isNil "_minDistance") then {_distance = _distance max _minDistance};
|
||||
if (!isNil "_minDistance") then {_distance = _distance max _minDistance};
|
||||
|
||||
_distance
|
||||
|
@ -1,19 +1,20 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the nearest object the player is looking at. Used for laser designator instead of cursorTarget.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Maximal distance to search. (Number)
|
||||
* Arguments:
|
||||
* 0: Maximum search distance <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Nearest object directly in line of sight, if none objNull (Object)
|
||||
* Return Value:
|
||||
* Nearest object in line of sight, objNull if none are found <OBJECT>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_position", "_laser", "_intersects"];
|
||||
params ["_maxDistance"];
|
||||
|
||||
PARAMS_1(_maxDistance);
|
||||
private ["_position", "_laser", "_intersects"];
|
||||
|
||||
_position = ATLToASL positionCameraToWorld [0, 0, 0];
|
||||
_position set [2, (_position select 2) - (getTerrainHeightASL _position min 0)];
|
||||
@ -23,4 +24,6 @@ _laser set [2, (_laser select 2) - (getTerrainHeightASL _laser min 0)];
|
||||
|
||||
_intersects = lineIntersectsObjs [_position, _laser, objNull, objNull, true, 2];
|
||||
|
||||
if (count _intersects == 0) then {objNull} else {_intersects select 0}
|
||||
if (_intersects isEqualTo []) exitWith {objNull};
|
||||
|
||||
_intersects select 0 // return
|
||||
|
@ -1,21 +1,22 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Returns all turned on lights of any vehicle or streetlamp.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A vehicle, not the classname (Object)
|
||||
* 0: Vehicle <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* All burning lights (Array)
|
||||
* All burning lights <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_vehicle);
|
||||
params ["_vehicle"];
|
||||
|
||||
if (!isLightOn _vehicle) exitWith {[]};
|
||||
|
||||
private ["_reflectorsWithSelections", "_lights", "_hitpoints"];
|
||||
private ["_reflectorsWithSelections", "_lights", "_hitpoints", "_turnedOnLights"];
|
||||
|
||||
_reflectorsWithSelections = [[_vehicle], FUNC(getReflectorsWithSelections), uiNamespace, format [QEGVAR(cache,%1_%2), QUOTE(DFUNC(getReflectorsWithSelections)), typeOf _vehicle], 1E11] call FUNC(cachedCall);
|
||||
//_reflectorsWithSelections = [_vehicle] call FUNC(getReflectorsWithSelections);
|
||||
@ -23,13 +24,12 @@ _reflectorsWithSelections = [[_vehicle], FUNC(getReflectorsWithSelections), uiNa
|
||||
_lights = _reflectorsWithSelections select 0;
|
||||
_hitpoints = _reflectorsWithSelections select 1;
|
||||
|
||||
private "_turnedOnLights";
|
||||
_turnedOnLights = [];
|
||||
|
||||
{
|
||||
if (_vehicle getHit _x <= 0.9) then {
|
||||
_turnedOnLights pushBack (_lights select _forEachIndex);
|
||||
};
|
||||
|
||||
} forEach _hitpoints;
|
||||
|
||||
_turnedOnLights
|
||||
|
@ -1,32 +1,34 @@
|
||||
/*
|
||||
Name: FUNC(getUavControlPosition)
|
||||
|
||||
Author: Pabst Mirror
|
||||
|
||||
Description:
|
||||
Gets the seat position of a UAV that the unit is activly controlling.
|
||||
"" - not connected to anything or not activly controling
|
||||
"DRIVER"
|
||||
"GUNNER"
|
||||
|
||||
Parameters:
|
||||
0: OBJECT - Unit
|
||||
|
||||
Returns:
|
||||
STRING - Position in the UAV that is currently being controled by the unit.
|
||||
|
||||
Example:
|
||||
[ACE_Player] call FUNC(getUavControlPosition)
|
||||
*/
|
||||
* Author: PabstMirror
|
||||
* Returns the seat position of a UAV that the unit is activly controling.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Position <STRING>
|
||||
* "" = not connected to anything or activly controling
|
||||
* "DRIVER"
|
||||
* "GUNNER"
|
||||
*
|
||||
* Example:
|
||||
* [ACE_Player] call ace_common_fnc_getUavControlPosition
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private ["_uav", "_positionArray", "_playerIndex"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
_uav = getConnectedUAV _unit;
|
||||
|
||||
if (isNull _uav) exitWith {""};
|
||||
|
||||
_positionArray = UAVControl _uav;
|
||||
_playerIndex = _positionArray find _unit;
|
||||
|
||||
if (_playerIndex == -1) exitWith {""};
|
||||
|
||||
_positionArray select (_playerIndex + 1)
|
||||
|
@ -1,19 +1,20 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the vehicle cargo positions. Codrivers and ffv positions are not listed.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Vehicle type (String)
|
||||
* Arguments:
|
||||
* 0: Vehicle type <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Vehicle cargo positions. (Array)
|
||||
* Return Value:
|
||||
* Vehicle cargo positions <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_config", "_cargo", "_codrivers", "_index"];
|
||||
params ["_vehicle"];
|
||||
|
||||
PARAMS_1(_vehicle);
|
||||
private ["_config", "_cargo", "_codrivers"];
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> _vehicle;
|
||||
|
||||
@ -25,4 +26,5 @@ for "_index" from 0 to (getNumber (_config >> "transportSoldier") - 1) do {
|
||||
_cargo pushBack _index;
|
||||
};
|
||||
};
|
||||
|
||||
_cargo
|
||||
|
@ -1,19 +1,20 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the vehicle codriver positions.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Vehicle type (String)
|
||||
* Arguments:
|
||||
* 0: Vehicle type <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Vehicle codriver positions. (Array)
|
||||
* Return Value:
|
||||
* Vehicle codriver positions <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_config", "_cargo", "_codrivers", "_index"];
|
||||
params ["_vehicle"];
|
||||
|
||||
PARAMS_1(_vehicle);
|
||||
private ["_config", "_cargo", "_codrivers"];
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> _vehicle;
|
||||
|
||||
@ -25,4 +26,5 @@ for "_index" from 0 to (getNumber (_config >> "transportSoldier") - 1) do {
|
||||
_cargo pushBack _index;
|
||||
};
|
||||
};
|
||||
|
||||
_cargo
|
||||
|
@ -1,21 +1,21 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Returns array of crew member objects.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Vehicle (Object)
|
||||
* 1: Slot types. Can contain "driver", "commander", "gunner", "turret", "cargo" and "ffv". Case sensitive (Array)
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
* 1: Slot types filter (default: ["driver", "commander", "gunner", "turret", "cargo", "ffv"]) <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* Crew (Array)
|
||||
* Return Value:
|
||||
* Crew <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_crew"];
|
||||
|
||||
PARAMS_2(_vehicle,_types);
|
||||
params ["_vehicle", ["_types", ["driver", "commander", "gunner", "turret", "cargo", "ffv"]]];
|
||||
|
||||
private "_crew";
|
||||
_crew = [];
|
||||
|
||||
// iterate through all crew members
|
||||
@ -31,6 +31,7 @@ _crew = [];
|
||||
_crew pushBack (_x select 0);
|
||||
};
|
||||
};
|
||||
} forEach fullCrew _vehicle;
|
||||
false
|
||||
} count fullCrew _vehicle;
|
||||
|
||||
_crew
|
||||
|
@ -1,11 +1,15 @@
|
||||
/**
|
||||
* fn_getVersion.sqf
|
||||
* @Descr: Get the version number of the current ACE Build
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Get the version number of the current ACE build.
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return: STRING String containing the version
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* ACE Version <STRING>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
getText (configFile >> "cfgPatches" >> "ACE_main" >> "version");
|
||||
|
||||
getText (configFile >> "CfgPatches" >> "ACE_main" >> "version") // return
|
||||
|
@ -1,20 +1,21 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get local players weapon direction and slope.
|
||||
*
|
||||
* Get players weapon direction and slope
|
||||
* Arguments:
|
||||
* 0: Weapon name <STRING>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Weapon name (String)
|
||||
* Return Value:
|
||||
* 0: Azimuth <NUMBER>
|
||||
* 1: Inclination <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* 0: Azimuth (Number)
|
||||
* 1: Inclination or 'slope' (Number)
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_direction", "_azimuth", "_inclination"];
|
||||
params ["_weapon"];
|
||||
|
||||
PARAMS_1(_weapon);
|
||||
private ["_direction", "_azimuth", "_inclination"];
|
||||
|
||||
_direction = ACE_player weaponDirection _weapon;
|
||||
|
||||
|
@ -1,20 +1,23 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get the index of the weapon.
|
||||
* 0 = primary, 1 = secondary, 2 = handgun, -1 = other
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* Weapon index <NUMBER>
|
||||
* 0 = primary
|
||||
* 1 = secondary
|
||||
* 2 = handgun
|
||||
* -1 = other
|
||||
*
|
||||
* Public: No
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_weapon);
|
||||
params ["_unit", "_weapon"];
|
||||
|
||||
if (_weapon == "") exitWith {-1};
|
||||
|
||||
@ -22,4 +25,4 @@ if (_weapon == "") exitWith {-1};
|
||||
primaryWeapon _unit,
|
||||
secondaryWeapon _unit,
|
||||
handgunWeapon _unit
|
||||
] find _weapon
|
||||
] find _weapon // return
|
||||
|
@ -1,30 +1,34 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get the available firing modes of a weapon. Will ignore the AI helper modes.
|
||||
*
|
||||
* Get the available firing modes of a weapon. Will ignore the ai helper modes.
|
||||
* Arguments:
|
||||
* 0: Weapon <STRING>
|
||||
*
|
||||
* Argument:
|
||||
* 0: A weapon in cfgWeapons (String)
|
||||
* Return Value:
|
||||
* Firing Modes <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* All firing modes (Array)
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_modes"];
|
||||
params ["_weapon"];
|
||||
|
||||
PARAMS_1(_weapon);
|
||||
private ["_config", "_modes"];
|
||||
|
||||
_config = configFile >> "CfgWeapons" >> _weapon;
|
||||
|
||||
_modes = [];
|
||||
|
||||
{
|
||||
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> _x >> "showToPlayer") == 1) then {
|
||||
if (getNumber (_config >> _x >> "showToPlayer") == 1) then {
|
||||
_modes pushBack _x;
|
||||
};
|
||||
|
||||
if (_x == "this") then {
|
||||
_modes pushBack _weapon;
|
||||
};
|
||||
|
||||
} forEach getArray (configfile >> "CfgWeapons" >> _weapon >> "modes");
|
||||
false
|
||||
} count getArray (_config >> "modes");
|
||||
|
||||
_modes
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the muzzles of a weapon.
|
||||
*
|
||||
* Argument:
|
||||
* 0: A weapon in cfgWeapons (String)
|
||||
* Arguments:
|
||||
* 0: Weapon <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* All weapon muzzles (Array)
|
||||
* Return Value:
|
||||
* All weapon muzzles <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_muzzles"];
|
||||
|
||||
PARAMS_1(_weapon);
|
||||
params ["_weapon"];
|
||||
|
||||
private "_muzzles";
|
||||
_muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles");
|
||||
|
||||
if ("this" in _muzzles) then {
|
||||
|
@ -1,46 +1,28 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Return current state of the weapon. Attachments and magazines with ammo.
|
||||
*
|
||||
* Argument:
|
||||
* 0: A unit (Object)
|
||||
* 1: A weapon (String)
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
* 1: weapon <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Weapon info, format: [attachments, muzzles, magazines, ammo] (Array)
|
||||
* Return Value:
|
||||
* 0: Attachements <ARRAY>
|
||||
* 1: Muzzles <ARRAY>
|
||||
* 2: Magazines <ARRAY>
|
||||
* 3: Ammo <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_weapon);
|
||||
params ["_unit", "_weapon"];
|
||||
|
||||
private ["_muzzles", "_weaponInfo"];
|
||||
|
||||
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 ["","","",""];
|
||||
|
||||
};
|
||||
};
|
||||
_weaponInfo = [["","","",""], primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit] select ((["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] find _weapon) max 0);
|
||||
|
||||
// get loaded magazines and ammo
|
||||
private ["_magazines", "_ammo"];
|
||||
@ -51,7 +33,8 @@ _ammo = [];
|
||||
{
|
||||
_magazines pushBack "";
|
||||
_ammo pushBack 0;
|
||||
} forEach _muzzles;
|
||||
false
|
||||
} count _muzzles;
|
||||
|
||||
{
|
||||
if (_x select 2) then {
|
||||
@ -63,7 +46,8 @@ _ammo = [];
|
||||
_ammo set [_index, _x select 1];
|
||||
};
|
||||
};
|
||||
} forEach magazinesAmmoFull _unit;
|
||||
false
|
||||
} count magazinesAmmoFull _unit;
|
||||
|
||||
_weaponInfo append [_muzzles, _magazines, _ammo];
|
||||
|
||||
|
@ -1,19 +1,24 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Check what kind of weapon the given class name is.
|
||||
*
|
||||
* Check what kind of weapon the given class name is. (primary, secondary or handgun)
|
||||
* Arguments:
|
||||
* 0: Weapons <STRING>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Class name of the weapon (String)
|
||||
* Return Value:
|
||||
* Slot index <NUMBER>
|
||||
* 1 = primary
|
||||
* 2 = secondary
|
||||
* 3 = handgun
|
||||
* -1 = other
|
||||
*
|
||||
* Return value:
|
||||
* Slot index of the given class name, 1: primary, 2: secondary, 3: handgun, else: -1 (Number)
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_type", "_index"];
|
||||
params ["_weapon"];
|
||||
|
||||
PARAMS_1(_weapon);
|
||||
private ["_type", "_index"];
|
||||
|
||||
_type = [getNumber (configFile >> "CfgWeapons" >> _weapon >> "type")] call FUNC(binarizeNumber);
|
||||
|
||||
@ -23,9 +28,4 @@ while {!(_type select _index) && {_index < 16}} do {
|
||||
_index = _index + 1;
|
||||
};
|
||||
|
||||
switch (_index) do {
|
||||
case 0 : {1};
|
||||
case 1 : {3};
|
||||
case 2 : {2};
|
||||
default {-1};
|
||||
}
|
||||
[-1, 1, 3, 2] select (([0, 1, 2] find _index) + 1) // return
|
||||
|
Loading…
Reference in New Issue
Block a user