diff --git a/addons/fortify/XEH_postInit.sqf b/addons/fortify/XEH_postInit.sqf index e46942d779..1e9670481d 100644 --- a/addons/fortify/XEH_postInit.sqf +++ b/addons/fortify/XEH_postInit.sqf @@ -72,3 +72,32 @@ GVAR(objectRotationZ) = 0; [_object, 0, ["ACE_MainActions"], _removeAction] call EFUNC(interact_menu,addActionToObject); }; }] call CBA_fnc_addEventHandler; + +// Place object event handler +[QGVAR(deployFinished), { + params ["_args", "_elapsedTime", "_totalTime", "_errorCode"]; + _args params ["_unit", "_side", "_typeOf", "_posASL", "_vectorDir", "_vectorUp"]; + + private _newObject = _typeOf createVehicle _posASL; + _newObject setPosASL _posASL; + _newObject setVectorDirAndUp [_vectorDir, _vectorUp]; + + // Server will use this event to run the jip compatible QGVAR(addActionToObject) event and create the related map marker + [QXGVAR(objectPlaced), [_unit, _side, _newObject]] call CBA_fnc_globalEvent; + + if (cba_events_control) then { + // Re-run if ctrl key held + [_unit, _unit, [_side, _typeOf, [GVAR(objectRotationX), GVAR(objectRotationY), GVAR(objectRotationZ)]]] call FUNC(deployObject); + }; + + // Reset animation + [_unit, "", 1] call EFUNC(common,doAnimation); +}] call CBA_fnc_addEventHandler; + +[QGVAR(deployCanceled), { + params ["_args", "_elapsedTime", "_totalTime", "_errorCode"]; + _args params ["_unit", "_side", "_typeOf", "_posASL", "_vectorDir", "_vectorUp"]; + + // Reset animation + [_unit, "", 1] call EFUNC(common,doAnimation); +}] call CBA_fnc_addEventHandler; diff --git a/addons/fortify/functions/fnc_deployConfirm.sqf b/addons/fortify/functions/fnc_deployConfirm.sqf index e8d027f1fa..7ac43e2b1f 100644 --- a/addons/fortify/functions/fnc_deployConfirm.sqf +++ b/addons/fortify/functions/fnc_deployConfirm.sqf @@ -30,14 +30,29 @@ private _vectorDir = vectorDir _object; deleteVehicle _object; -private _newObject = _typeOf createVehicle _posASL; -_newObject setPosASL _posASL; -_newObject setVectorDirAndUp [_vectorDir, _vectorUp]; +// Create progress bar to place object +private _totalTime = _cost * GVAR(timeCostCoefficient) + GVAR(timeMin); // time = Ax + b -// Server will use this event to run the jip compatible QGVAR(addActionToObject) event and create the related map marker. -[QXGVAR(objectPlaced), [_unit, _side, _newObject]] call CBA_fnc_globalEvent; +private _perframeCheck = { + params ["_args", "_elapsedTime", "_totalTime", "_errorCode"]; + _args params ["_unit", "_side", "_typeOf", "_posASL", "_vectorDir", "_vectorUp"]; -if (cba_events_control) then { - // Re-run if ctrl key held - [_unit, _unit, [_side, _typeOf, [GVAR(objectRotationX), GVAR(objectRotationY), GVAR(objectRotationZ)]]] call FUNC(deployObject); + // Animation loop (required for longer constructions) + if (animationState _unit isNotEqualTo "AinvPknlMstpSnonWnonDnon_medic4") then { + // Perform animation + [_unit, "AinvPknlMstpSnonWnonDnon_medic4"] call EFUNC(common,doAnimation); + }; + + // Return true always + true }; + +[ + _totalTime, + [_unit, _side, _typeOf, _posASL, _vectorDir, _vectorUp], + QGVAR(deployFinished), + QGVAR(deployCanceled), + LLSTRING(progressBarTitle), + _perframeCheck +] call EFUNC(common,progressBar); + diff --git a/addons/fortify/initSettings.sqf b/addons/fortify/initSettings.sqf index 0772bf9bdc..8602cc016e 100644 --- a/addons/fortify/initSettings.sqf +++ b/addons/fortify/initSettings.sqf @@ -10,6 +10,22 @@ ] ] call CBA_fnc_addSetting; +[ + QGVAR(timeCostCoefficient), + "SLIDER", + [LLSTRING(settingHint_timeCostCoefficient), LLSTRING(settingHintDesc_timeCostCoefficient)], + LLSTRING(settingsCategory), + [0, 10, 1, 2] // Min, Max, Default, Trailing Decimals, is Percentage +] call CBA_fnc_addSetting; + +[ + QGVAR(timeMin), + "SLIDER", + [LLSTRING(settingHint_timeMin), LLSTRING(settingHintDesc_timeMin)], + LLSTRING(settingsCategory), + [0, 25, 1.5, 2] // Min, Max, Default, Trailing Decimals, is Percentage +] call CBA_fnc_addSetting; + [ QGVAR(markObjectsOnMap), "LIST", diff --git a/addons/fortify/stringtable.xml b/addons/fortify/stringtable.xml index f0dd063d7b..48e69198c3 100644 --- a/addons/fortify/stringtable.xml +++ b/addons/fortify/stringtable.xml @@ -157,6 +157,21 @@ Показывать всегда Her Zaman Göster + + Time-Cost Coefficient + + + Coefficient used to determine time to build structure.<br/>A in Ax + b where x is cost of object + + + Minimum Build Time + + + Minimum time to build any structure.<br/>b in Ax + b where x is cost of object + + + Building + Create map markers diff --git a/docs/wiki/feature/fortify.md b/docs/wiki/feature/fortify.md index 9320a9f36c..b145e483e0 100644 --- a/docs/wiki/feature/fortify.md +++ b/docs/wiki/feature/fortify.md @@ -15,7 +15,7 @@ redirect_from: "/wiki/featurex/fortify.html" ## 1. Overview -Enable players to place down fortifications. Budget enables mission makers / admin to restrict the amount of resources available. +Enable players to place down fortifications. Budget enables mission makers / admin to restrict the amount of resources available and how long it will take to construct the fortifications. ## 2. Usage diff --git a/docs/wiki/framework/fortify-framework.md b/docs/wiki/framework/fortify-framework.md index 987319270c..b76e806667 100644 --- a/docs/wiki/framework/fortify-framework.md +++ b/docs/wiki/framework/fortify-framework.md @@ -92,3 +92,5 @@ Event Name | Passed Parameter(s) | Locality | Description `acex_fortify_objectPlaced` | [player, side, objectPlaced] | Global | Foritfy object placed `acex_fortify_objectDeleted` | [player, side, objectDeleted] | Global | Foritfy object deleted `acex_fortify_onDeployStart` | [player, object, cost] | Local | Player starts placing object +`ace_fortify_deployFinished` | [player, side, configName, posASL, vectorDir, vectorUp] | Local | Player successfully finishes building object +`ace_fortify_deployCanceled` | [player, side, configName, posASL, vectorDir, vectorUp] | Local | Player cancels building object