Last active
October 21, 2023 16:34
-
-
Save commy2/628b47610cb5d8ed27a57edf30df6604 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// init.sqf | |
#define TEXT_REPAIR "Repair Sensor" | |
#define ICON_REPAIR "\a3\ui_f\data\igui\cfg\simpletasks\types\repair_ca.paa" | |
#define REPAIR_TIME 5 | |
private _toolkit = configName (configFile >> "CfgWeapons" >> "ToolKit"); | |
["Mission_Repaired", { | |
params ["_unit", "_target", "_toolkit", "_canRepair"]; | |
hint "REPAIR DONE"; | |
}] call CBA_fnc_addEventHandler; | |
if (isServer) then { | |
["Mission_RepairedServer", { | |
params ["_unit", "_target", "_toolkit", "_canRepair"]; | |
if ([_unit, _target, _toolkit] call _canRepair) then { | |
_unit removeItem _toolkit; // AG EG according to wiki | |
_target setVariable ["Mission_Repaired", true, true]; | |
//hint "REPAIR DONE"; | |
["Mission_Repaired", _this] call CBA_fnc_globalEvent; | |
}; | |
}] call CBA_fnc_addEventHandler; | |
}; | |
private _canRepair = { | |
params ["_unit", "_target", "_toolkit"]; | |
//systemChat str [_unit, _toolkit]; | |
_unit getUnitTrait "engineer" | |
and _toolkit in items _unit | |
and isNil {_target getVariable "Mission_Repaired"} | |
}; | |
private _onRepairProgress = { | |
params ["_args"]; | |
_args params ["_unit", "_target", "_toolkit", "_canRepair"]; | |
[_unit, _target, _toolkit] call _canRepair // return | |
}; | |
private _onRepairComplete = { | |
params ["_args"]; | |
["Mission_RepairedServer", _args] call CBA_fnc_serverEvent; | |
}; | |
private _onRepairFailure = { | |
//hint "REPAIR FAIL"; | |
}; | |
private _actionArgs = [_toolkit, _canRepair, _onRepairProgress, _onRepairComplete, _onRepairFailure]; | |
private _actionRepairCondition = { | |
params ["_target", "_unit", "_args"]; | |
_args params ["_toolkit", "_canRepair"]; | |
[_unit, _target, _toolkit] call _canRepair // return | |
}; | |
private _actionRepairStatement = { | |
[{ | |
params ["_target", "_unit", "_args"]; | |
_args params ["_toolkit", "_canRepair", "_onRepairProgress", "_onRepairComplete", "_onRepairFailure"]; | |
[TEXT_REPAIR, REPAIR_TIME, _onRepairProgress, _onRepairComplete, _onRepairFailure, [_unit, _target, _toolkit, _canRepair]] call CBA_fnc_progressBar; | |
}, _this] call CBA_fnc_execNextFrame; | |
}; | |
private _actionRepair = ["MISSION_Repair", TEXT_REPAIR, ICON_REPAIR, _actionRepairStatement, _actionRepairCondition, nil, _actionArgs] call ace_interact_menu_fnc_createAction; | |
["Land_PortableWeatherStation_01_olive_F", 0, ["ACE_MainActions"], _actionRepair] call ace_interact_menu_fnc_addActionToClass; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment