Fortify - Add Progress Bar (#8585)

* Fortify - Add Progress Bar

* Misc Fixes

* Add animation loop

* Adjust default values to make larger objects take longer to build

* Fix merge conflict additional

Co-authored-by: jonpas <jonpas33@gmail.com>
This commit is contained in:
mjc4wilton 2021-11-08 13:01:39 -05:00 committed by GitHub
parent 62ed899ecc
commit 422c47aae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 9 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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",

View File

@ -157,6 +157,21 @@
<Russian>Показывать всегда</Russian>
<Turkish>Her Zaman Göster</Turkish>
</Key>
<Key ID="STR_ACE_Fortify_settingHint_timeCostCoefficient">
<English>Time-Cost Coefficient</English>
</Key>
<Key ID="STR_ACE_Fortify_settingHintDesc_timeCostCoefficient">
<English>Coefficient used to determine time to build structure.&lt;br/&gt;A in Ax + b where x is cost of object</English>
</Key>
<Key ID="STR_ACE_Fortify_settingHint_timeMin">
<English>Minimum Build Time</English>
</Key>
<Key ID="STR_ACE_Fortify_settingHintDesc_timeMin">
<English>Minimum time to build any structure.&lt;br/&gt;b in Ax + b where x is cost of object</English>
</Key>
<Key ID="STR_ACE_Fortify_progressBarTitle">
<English>Building</English>
</Key>
<Key ID="STR_ACE_Fortify_markObjectsOnMap">
<English>Create map markers</English>
</Key>

View File

@ -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

View File

@ -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