Skip to content

Commit

Permalink
Common - Add ability to check for skill levels for isMedic and isEngi…
Browse files Browse the repository at this point in the history
…neer (#10500)

* Allow checking specific medic/engineer levels

* Fix isEngineer value of true being considered 2

* Update function header
  • Loading branch information
DartRuffian authored Nov 15, 2024
1 parent 9204e8d commit 539ffb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions addons/common/functions/fnc_isEngineer.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "..\script_component.hpp"
/*
* Author: marc_book, edited by commy2
* Author: marc_book, commy2, DartRuffian
* Checks if a unit is an engineer.
*
* Arguments:
* 0: unit to be checked <OBJECT>
* 0: Unit to be checked <OBJECT>
* 1: Engineer level <NUMBER> (default: 1)
* - Only relevant if ace_repair is loaded
*
* Return Value:
* is the unit an engineer <BOOL>
Expand All @@ -15,10 +17,11 @@
* Public: Yes
*/

params ["_unit"];
params ["_unit", ["_engineerN", 1]];

private _isEngineer = _unit getVariable ["ACE_isEngineer", _unit getUnitTrait "engineer"];
//Handle ace_repair modules setting this to a number
if (_isEngineer isEqualType 0) then {_isEngineer = _isEngineer > 0};

_isEngineer
// Convert boolean to number
_isEngineer = [0, 1, 2] select _isEngineer;

_isEngineer >= _engineerN
8 changes: 5 additions & 3 deletions addons/common/functions/fnc_isMedic.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "..\script_component.hpp"
/*
* Author: kymckay
* Author: kymckay, DartRuffian
* Check if a unit is a medic
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Medic level <NUMBER> (default: 1)
* - Only relevant if ace_medical is loaded
*
* Return Value:
* Unit is medic <BOOL>
Expand All @@ -15,8 +17,8 @@
* Public: Yes
*/

params ["_unit"];
params ["_unit", ["_medicN", 1]];

private _isMedic = _unit getVariable [QEGVAR(medical,medicClass), getNumber (configOf _unit >> "attendant")];

_isMedic > 0
_isMedic >= _medicN

0 comments on commit 539ffb5

Please sign in to comment.