mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
ef099861a3
commit
9fa6eb0651
@ -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,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]
|
||||
|
@ -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,36 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
{
|
||||
// this unit is in a ffv position. check if we search for ffv.
|
||||
if (_x select 4) then {
|
||||
if ("ffv" in _types) then {
|
||||
_crew pushBack (_x select 0);
|
||||
// this unit is in a ffv position. check if we search for ffv.
|
||||
if (_x select 4) then {
|
||||
if ("ffv" in _types) then {
|
||||
_crew pushBack (_x select 0);
|
||||
};
|
||||
} else {
|
||||
// otherwise check if we search for that type. toLower, because fullCrew returns "driver" vs. "Turret".
|
||||
if (toLower (_x select 1) in _types) then {
|
||||
_crew pushBack (_x select 0);
|
||||
};
|
||||
};
|
||||
} else {
|
||||
// otherwise check if we search for that type. toLower, because fullCrew returns "driver" vs. "Turret".
|
||||
if (toLower (_x select 1) in _types) then {
|
||||
_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