-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add remove trench and continue digging trench actions #3612
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d6e9890
Add remove trench and continue digging trench actions
SzwedzikPL 203c059
move placement data to config, setTrenchPlacement fnc, cleanup
SzwedzikPL 10d2047
Remove grass behind the trench
SzwedzikPL 9b1b4a4
better polish translation
SzwedzikPL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
27 changes: 27 additions & 0 deletions
27
addons/trenches/functions/fnc_canContinueDiggingTrench.sqf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Author: SzwedzikPL | ||
* Checks if a unit can continue digging a trench | ||
* | ||
* Arguments: | ||
* 0: trench <OBJECT> | ||
* 1: unit <OBJECT> | ||
* | ||
* Return Value: | ||
* Can continue <BOOL> | ||
* | ||
* Example: | ||
* [TrenchObj, ACE_player] call ace_trenches_fnc_canContinueDiggingTrench | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_trench", "_unit"]; | ||
|
||
if !("ACE_EntrenchingTool" in items _unit) exitWith {false}; | ||
if ((_trench getVariable [QGVAR(progress), 0]) >= 1) exitWith {false}; | ||
|
||
// Prevent removing/digging trench by more than one person | ||
if (_trench getVariable [QGVAR(digging), false]) exitWith {false}; | ||
|
||
true |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Author: SzwedzikPL | ||
* Checks if a unit can remove a trench | ||
* | ||
* Arguments: | ||
* 0: trench <OBJECT> | ||
* 1: unit <OBJECT> | ||
* | ||
* Return Value: | ||
* Can remove <BOOL> | ||
* | ||
* Example: | ||
* [TrenchObj, ACE_player] call ace_trenches_fnc_canRemoveTrench | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_trench", "_unit"]; | ||
|
||
if !("ACE_EntrenchingTool" in items _unit) exitWith {false}; | ||
|
||
// Prevent removing/digging trench by more than one person | ||
if (_trench getVariable [QGVAR(digging), false]) exitWith {false}; | ||
|
||
true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support, esteldunedain | ||
* Continue process of digging trench. | ||
* | ||
* Arguments: | ||
* 0: trench <OBJECT> | ||
* 1: unit <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [TrenchObj, ACE_player] call ace_trenches_fnc_continueDiggingTrench | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_trench", "_unit"]; | ||
TRACE_2("continueDiggingTrench",_trench,_unit); | ||
|
||
private _actualProgress = _trench getVariable [QGVAR(progress), 0]; | ||
if(_actualProgress == 1) exitWith {}; | ||
|
||
// Mark trench as being worked on | ||
_trench setVariable [QGVAR(digging), true, true]; | ||
|
||
private _digTime = getNumber (configFile >> "CfgVehicles" >> (typeof _trench) >> QGVAR(diggingDuration)); | ||
private _digTimeLeft = _digTime * (1 - _actualProgress); | ||
|
||
private _placeData = _trench getVariable [QGVAR(placeData), [[], []]]; | ||
_placeData params ["_basePos", "_vecDirAndUp"]; | ||
|
||
private _trenchId = _unit getVariable [QGVAR(isDiggingId), -1]; | ||
if(_trenchId < 0) then { | ||
_trenchId = GVAR(trenchId); | ||
_unit setVariable [QGVAR(isDiggingId), _trenchId, true]; | ||
GVAR(trenchId) = GVAR(trenchId) + 1; | ||
}; | ||
|
||
// Create progress bar | ||
private _fnc_onFinish = { | ||
(_this select 0) params ["_unit", "_trench"]; | ||
_unit setVariable [QGVAR(isDiggingId), -1, true]; | ||
_trench setVariable [QGVAR(digging), false, true]; | ||
|
||
// Save progress global | ||
private _progress = _trench getVariable [QGVAR(progress), 0]; | ||
_trench setVariable [QGVAR(progress), _progress, true]; | ||
|
||
// Reset animation | ||
[_unit, "", 1] call EFUNC(common,doAnimation); | ||
}; | ||
private _fnc_onFailure = { | ||
(_this select 0) params ["_unit", "_trench"]; | ||
_unit setVariable [QGVAR(isDiggingId), -1, true]; | ||
_trench setVariable [QGVAR(digging), false, true]; | ||
|
||
// Save progress global | ||
private _progress = _trench getVariable [QGVAR(progress), 0]; | ||
_trench setVariable [QGVAR(progress), _progress, true]; | ||
|
||
// Reset animation | ||
[_unit, "", 1] call EFUNC(common,doAnimation); | ||
}; | ||
[(_digTimeLeft + 0.5), [_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(DiggingTrench)] call EFUNC(common,progressBar); | ||
|
||
if(_actualProgress == 0) then { | ||
[_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 1.0], _vecDirAndUp, _actualProgress] call FUNC(setTrenchPlacement); | ||
|
||
//Remove grass | ||
{ | ||
private _trenchGrassCutter = createVehicle ["Land_ClutterCutter_medium_F", [0, 0, 0], [], 0, "NONE"]; | ||
private _cutterPos = AGLToASL (_trench modelToWorld _x); | ||
_cutterPos set [2, getTerrainHeightASL _cutterPos]; | ||
_trenchGrassCutter setPosASL _cutterPos; | ||
deleteVehicle _trenchGrassCutter; | ||
} foreach getArray (configFile >> "CfgVehicles" >> (typeof _trench) >> QGVAR(grassCuttingPoints)); | ||
}; | ||
|
||
private _progressLeft = (_actualProgress * 10) + 1; | ||
private ["_i"]; | ||
for "_i" from _progressLeft to 10 do { | ||
private _vectorDiffZ = 1 - (_i / 10); | ||
private _delay = _digTime * ((_i / 10) - _actualProgress); | ||
private _progress = _i / 10; | ||
[DFUNC(setTrenchPlacement), [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, _vectorDiffZ], _vecDirAndUp, _progress], _delay] call EFUNC(common,waitAndExecute); | ||
}; | ||
|
||
// Play animation | ||
[_unit, "AinvPknlMstpSnonWnonDnon_medic4"] call EFUNC(common,doAnimation); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defining the data here when the rest of the placement data is hard-coded in
preInit
is a bit inconsistent. Of course using the config is better, so we should probably migrate the rest of the data here eventually.Ideally we could organize the data so more trench types could be added in config by third parties.