From 8143cdc1da3bfec53d3f6017df14204cd2c89a73 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 4 Oct 2023 13:19:10 -0500 Subject: [PATCH] Medical AI - Add setting to replace gear for AI (#9458) --- .../medical_ai/functions/fnc_healingLogic.sqf | 2 +- addons/medical_ai/functions/fnc_itemCheck.sqf | 2 +- addons/medical_ai/initSettings.sqf | 20 ++++++++++++++++--- addons/medical_ai/stringtable.xml | 11 ++++++---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/addons/medical_ai/functions/fnc_healingLogic.sqf b/addons/medical_ai/functions/fnc_healingLogic.sqf index c9c5fdd483..fa35b49284 100644 --- a/addons/medical_ai/functions/fnc_healingLogic.sqf +++ b/addons/medical_ai/functions/fnc_healingLogic.sqf @@ -24,7 +24,7 @@ if (_finishTime > 0) exitWith { if (CBA_missionTime >= _finishTime) then { TRACE_5("treatment finished",_finishTime,_treatmentTarget,_treatmentEvent,_treatmentArgs,_treatmentItem); _healer setVariable [QGVAR(currentTreatment), nil]; - if ((GVAR(requireItems)) && {_treatmentItem != ""}) then { + if ((GVAR(requireItems) > 0) && {_treatmentItem != ""}) then { ([_healer, _treatmentItem] call FUNC(itemCheck)) params ["_itemOk", "_itemClassname", "_treatmentClass"]; if (!_itemOk) exitWith { _treatmentEvent = "#fail"; }; // no item after delay _healer removeItem _itemClassname; diff --git a/addons/medical_ai/functions/fnc_itemCheck.sqf b/addons/medical_ai/functions/fnc_itemCheck.sqf index e93af9953c..6d91594ce4 100644 --- a/addons/medical_ai/functions/fnc_itemCheck.sqf +++ b/addons/medical_ai/functions/fnc_itemCheck.sqf @@ -18,7 +18,7 @@ * Public: No */ -if (!GVAR(requireItems)) exitWith { [true] }; +if (GVAR(requireItems) == 0) exitWith { [true] }; params ["_healer", "_treatementType"]; diff --git a/addons/medical_ai/initSettings.sqf b/addons/medical_ai/initSettings.sqf index 4a5bc5d691..a2b06519a4 100644 --- a/addons/medical_ai/initSettings.sqf +++ b/addons/medical_ai/initSettings.sqf @@ -15,11 +15,25 @@ private _categoryArray = [ELSTRING(medical,Category), "STR_TEAM_SWITCH_AI"]; ] call CBA_fnc_addSetting; [ - QGVAR(requireItems), "CHECKBOX", + QGVAR(requireItems), "LIST", [LSTRING(requireItems_title), LSTRING(requireItems_desc)], _categoryArray, - false, + [ + [0, 1, 2], + [LELSTRING(Common,Disabled), LELSTRING(Common,Enabled), format ["%1 - %2", LELSTRING(Common,Enabled), LLSTRING(requireItems_autoReplaceItems)]], + 0 + ], true, // isGlobal - {}, + { + if (GVAR(requireItems) != 2) exitWith {}; + ["CAManBase", "initPost", { + [{ + params ["_unit"]; + if ((!local _unit) || {!alive _unit} || {isPlayer _unit}) exitWith {}; + TRACE_2("replacing medical items on AI",_unit,typeOf _unit); + [_unit] call EFUNC(common,replaceRegisteredItems); + }, _this] call CBA_fnc_execNextFrame; // need to delay a frame before modifying items in a backpack + }, nil, [IGNORE_BASE_UAVPILOTS], true] call CBA_fnc_addClassEventHandler; + }, true // Needs mission restart ] call CBA_fnc_addSetting; diff --git a/addons/medical_ai/stringtable.xml b/addons/medical_ai/stringtable.xml index dade2bc136..0ae751dec7 100644 --- a/addons/medical_ai/stringtable.xml +++ b/addons/medical_ai/stringtable.xml @@ -55,10 +55,13 @@ 아이템 필요 - AI will only perform medical treatment if they have the necessary items in their inventory.\nRequires custom AI loadouts! - AI będzie wykonywać zabiegi medyczne tylko wtedy, gdy ma w ekwipunku niezbędne przedmioty. \nWymaga niestandardowego wyposażenia AI! - Die KI führt nur dann medizinische Behandlungen durch, wenn sie die erforderlichen Gegenstände in ihrem Inventar hat.\nErfordert benutzerdefinierte KI-Ausrüstungen! - 소지품에 필요한 아이템이 있을 경우에만 인공지능이 치료를 진행합니다.\n커스텀한 인공지능 로드아웃이 필요합니다! + AI will only perform medical treatment if they have the necessary items in their inventory. + AI będzie wykonywać zabiegi medyczne tylko wtedy, gdy ma w ekwipunku niezbędne przedmioty. + Die KI führt nur dann medizinische Behandlungen durch, wenn sie die erforderlichen Gegenstände in ihrem Inventar hat. + 소지품에 필요한 아이템이 있을 경우에만 인공지능이 치료를 진행합니다. + + + Auto Convert Items for AI