mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #3612 from SzwedzikPL/trenchestweaks
Add remove trench and continue digging trench actions
This commit is contained in:
commit
f34d890e7a
@ -1,3 +1,26 @@
|
||||
class CBA_Extended_EventHandlers;
|
||||
|
||||
#define ACE_TRENCHES_ACTIONS class ACE_Actions { \
|
||||
class ACE_MainActions { \
|
||||
displayName = ECSTRING(interaction,MainAction); \
|
||||
selection = ""; \
|
||||
distance = 3; \
|
||||
condition = QUOTE(true); \
|
||||
class ACE_ContinueDiggingTrench { \
|
||||
displayName = CSTRING(ContinueDiggingTrench); \
|
||||
condition = QUOTE([ARR_2(_target,_player)] call FUNC(canContinueDiggingTrench)); \
|
||||
statement = QUOTE([ARR_2(_target,_player)] call FUNC(continueDiggingTrench);); \
|
||||
priority = -1; \
|
||||
}; \
|
||||
class ACE_RemoveTrench { \
|
||||
displayName = CSTRING(RemoveEnvelope); \
|
||||
condition = QUOTE([ARR_2(_target,_player)] call FUNC(canRemoveTrench)); \
|
||||
statement = QUOTE([ARR_2(_target,_player)] call FUNC(removeTrench);); \
|
||||
priority = -1; \
|
||||
}; \
|
||||
}; \
|
||||
}
|
||||
|
||||
class CfgVehicles {
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
@ -5,9 +28,9 @@ class CfgVehicles {
|
||||
class ACE_Equipment {
|
||||
class GVAR(digEnvelopeSmall) {
|
||||
displayName = CSTRING(DigEnvelopeSmall);
|
||||
condition = QUOTE([ARR_2(_this select 0,'ace_trenches_trenchSmall')] call FUNC(canDigTrench));
|
||||
condition = QUOTE(_player call FUNC(canDigTrench));
|
||||
//wait a frame to handle "Do When releasing action menu key" option
|
||||
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ace_trenches_trenchSmall')])] call EFUNC(common,execNextFrame));
|
||||
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ACE_envelope_small')])] call EFUNC(common,execNextFrame));
|
||||
exceptions[] = {};
|
||||
showDisabled = 0;
|
||||
priority = 4;
|
||||
@ -15,9 +38,9 @@ class CfgVehicles {
|
||||
};
|
||||
class GVAR(digEnvelopeBig) {
|
||||
displayName = CSTRING(DigEnvelopeBig);
|
||||
condition = QUOTE([ARR_2(_this select 0,'ace_trenches_trenchBig')] call FUNC(canDigTrench));
|
||||
condition = QUOTE(_player call FUNC(canDigTrench));
|
||||
//wait a frame to handle "Do When releasing action menu key" option
|
||||
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ace_trenches_trenchBig')])] call EFUNC(common,execNextFrame));
|
||||
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ACE_envelope_big')])] call EFUNC(common,execNextFrame));
|
||||
exceptions[] = {};
|
||||
showDisabled = 0;
|
||||
priority = 4;
|
||||
@ -34,6 +57,15 @@ class CfgVehicles {
|
||||
descriptionShort = CSTRING(EnevlopeSmallDescription);
|
||||
model = QUOTE(PATHTOEF(apl,ace_envelope_small4.p3d));
|
||||
scope = 2;
|
||||
GVAR(diggingDuration) = 20;
|
||||
GVAR(removalDuration) = 12;
|
||||
GVAR(noGeoClass) = "ACE_envelope_small_NoGeo";
|
||||
GVAR(placementData)[] = {2,3,0.35};
|
||||
GVAR(grassCuttingPoints)[] = {{0,-0.5,0}};
|
||||
ACE_TRENCHES_ACTIONS;
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
};
|
||||
};
|
||||
class ACE_envelope_big: BagFence_base_F {
|
||||
author = ECSTRING(common,ACETeam);
|
||||
@ -41,9 +73,17 @@ class CfgVehicles {
|
||||
descriptionShort = CSTRING(EnevlopeBigDescription);
|
||||
model = QUOTE(PATHTOEF(apl,ace_envelope_big4.p3d));
|
||||
scope = 2;
|
||||
GVAR(diggingDuration) = 25;
|
||||
GVAR(removalDuration) = 15;
|
||||
GVAR(noGeoClass) = "ACE_envelope_big_NoGeo";
|
||||
GVAR(placementData)[] = {6,1.1,0.20};
|
||||
GVAR(grassCuttingPoints)[] = {{-1.5,-1,0},{1.5,-1,0}};
|
||||
ACE_TRENCHES_ACTIONS;
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class ACE_envelope_small_NoGeo: ACE_envelope_small {
|
||||
scope = 1;
|
||||
//@todo: replace by a no geo model
|
||||
|
@ -1,5 +1,8 @@
|
||||
|
||||
PREP(canContinueDiggingTrench);
|
||||
PREP(canDigTrench);
|
||||
PREP(canRemoveTrench);
|
||||
PREP(continueDiggingTrench);
|
||||
PREP(handleInteractMenuOpened);
|
||||
PREP(handleKilled);
|
||||
PREP(handlePlayerChanged);
|
||||
@ -9,3 +12,5 @@ PREP(handleUnconscious);
|
||||
PREP(placeCancel);
|
||||
PREP(placeConfirm);
|
||||
PREP(placeTrench);
|
||||
PREP(removeTrench);
|
||||
PREP(setTrenchPlacement);
|
||||
|
@ -4,10 +4,4 @@ ADDON = false;
|
||||
|
||||
#include "XEH_PREP.hpp"
|
||||
|
||||
// Trench types
|
||||
// Name of the object, name of th dummy no geo object, dx, dy
|
||||
GVAR(trenchSmall) = ["ACE_envelope_small", "ACE_envelope_small_NoGeo", 2, 3, 0.35];
|
||||
GVAR(trenchBig) = ["ACE_envelope_big", "ACE_envelope_big_NoGeo", 6, 1.1, 0.20];
|
||||
GVAR(trenchType) = GVAR(trenchSmall);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -11,6 +11,7 @@ class CfgPatches {
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgWeapons.hpp"
|
||||
|
27
addons/trenches/functions/fnc_canContinueDiggingTrench.sqf
Normal file
27
addons/trenches/functions/fnc_canContinueDiggingTrench.sqf
Normal file
@ -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
|
@ -4,7 +4,6 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Trench type <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Can dig <BOOL>
|
||||
@ -18,17 +17,15 @@
|
||||
|
||||
#define SURFACE_BLACKLIST ["water", "concrete", "tarmac", "wood", "metal", "roof_tin", "roof_tiles", "wood_int", "concrete_int", "tiles_int", "metal_int", "stony", "rock", "int_concrete", "int_tiles", "int_wood", "tiling", "wavymetal", "int_metal"]
|
||||
|
||||
params ["_unit","_trenchTypeName"];
|
||||
params ["_unit"];
|
||||
|
||||
if !("ACE_EntrenchingTool" in items _unit) exitWith {false};
|
||||
|
||||
// Can't dig trench if above ground level
|
||||
if ((getPosATL _unit) select 2 > 0.05) exitWith {false};
|
||||
|
||||
private ["_surfaceClass", "_surfaceType"];
|
||||
|
||||
_surfaceClass = (surfaceType getPosASL _unit) select [1];
|
||||
_surfaceType = getText (configFile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron");
|
||||
private _surfaceClass = (surfaceType getPosASL _unit) select [1];
|
||||
private _surfaceType = getText (configFile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron");
|
||||
TRACE_1("",_surfaceType);
|
||||
|
||||
!(_surfaceType in SURFACE_BLACKLIST)
|
||||
|
26
addons/trenches/functions/fnc_canRemoveTrench.sqf
Normal file
26
addons/trenches/functions/fnc_canRemoveTrench.sqf
Normal file
@ -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
|
91
addons/trenches/functions/fnc_continueDiggingTrench.sqf
Normal file
91
addons/trenches/functions/fnc_continueDiggingTrench.sqf
Normal file
@ -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);
|
@ -36,9 +36,9 @@ params ["_unit"];
|
||||
if (isNull GVAR(trench)) exitWith {};
|
||||
|
||||
deleteVehicle GVAR(trench);
|
||||
private _trench = createVehicle [GVAR(trenchType) select 0, [0, 0, 0], [], 0, "NONE"];
|
||||
private _trench = createVehicle [GVAR(trenchClass), [0, 0, 0], [], 0, "NONE"];
|
||||
|
||||
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
|
||||
GVAR(trenchPlacementData) params ["_dx", "_dy", "_offset"];
|
||||
private _basePos = GVAR(trenchPos);
|
||||
private _angle = (GVAR(digDirection) + getDir _unit);
|
||||
|
||||
@ -66,49 +66,8 @@ for [{_ix = -_dx/2},{_ix <= _dx/2},{_ix = _ix + _dx/3}] do {
|
||||
};
|
||||
_basePos set [2, (_basePos select 2) + _minzoffset + _offset];
|
||||
private _vecDirAndUp = [_v1, _v3];
|
||||
|
||||
GVAR(trench) = objNull;
|
||||
|
||||
// Mark the unit as digging
|
||||
private _trenchId = GVAR(trenchId);
|
||||
_unit setVariable [QGVAR(isDiggingId), _trenchId, true];
|
||||
GVAR(trenchId) = GVAR(trenchId) + 1;
|
||||
_trench setVariable [QGVAR(placeData), [_basePos, _vecDirAndUp], true];
|
||||
|
||||
// Create progress bar
|
||||
private _fnc_onFinish = {
|
||||
(_this select 0) params ["_unit"];
|
||||
_unit setVariable [QGVAR(isDiggingId), -1, true];
|
||||
};
|
||||
private _fnc_onFailure = {
|
||||
(_this select 0) params ["_unit"];
|
||||
_unit setVariable [QGVAR(isDiggingId), -1, true];
|
||||
};
|
||||
[12.5, [_unit], _fnc_onFinish, _fnc_onFailure, localize LSTRING(DiggingTrench)] call EFUNC(common,progressBar);
|
||||
|
||||
// Schedule progressive raising of the trench
|
||||
private _fnc_setPlacing = {
|
||||
params ["_unit", "_trench", "_trenchId", "_pos", "_vecDirAndUp"];
|
||||
|
||||
// If the progress bar was cancelled, cancel elevation
|
||||
// We use an uid to avoid any chance of an older trench being raised when a new one is built
|
||||
if (_unit getVariable [QGVAR(isDiggingId), -1] != _trenchId) exitWith {};
|
||||
|
||||
_trench setPosASL _pos;
|
||||
_trench setVectorDirAndUp _vecDirAndUp;
|
||||
};
|
||||
|
||||
// For loops are for wimps
|
||||
[_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 1.0], _vecDirAndUp] call _fnc_setPlacing;
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.9], _vecDirAndUp], 3.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.8], _vecDirAndUp], 4.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.7], _vecDirAndUp], 5.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.6], _vecDirAndUp], 6.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.5], _vecDirAndUp], 7.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.4], _vecDirAndUp], 8.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.3], _vecDirAndUp], 9.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.2], _vecDirAndUp],10.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.1], _vecDirAndUp],11.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.0], _vecDirAndUp],12.0] call EFUNC(common,waitAndExecute);
|
||||
|
||||
// Play animation
|
||||
[_unit, "AinvPknlMstpSnonWnonDnon_medic4"] call EFUNC(common,doAnimation);
|
||||
[_trench, _unit] call FUNC(continueDiggingTrench);
|
||||
|
@ -4,29 +4,34 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
* 1: Trench type <STRING>
|
||||
* 1: Trench class <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player] call ace_trenches_fnc_placeTrench
|
||||
* [ACE_player, "ACE_envelope_small"] call ace_trenches_fnc_placeTrench
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit","_trenchTypeName"];
|
||||
params ["_unit", "_trenchClass"];
|
||||
|
||||
GVAR(trenchType) = missionNamespace getVariable _trenchTypeName;
|
||||
//Load trench data
|
||||
private _noGeoModel = getText (configFile >> "CfgVehicles" >> _trenchClass >> QGVAR(noGeoClass));
|
||||
if(_noGeoModel == "") then {_noGeoModel = _trenchClass;};
|
||||
|
||||
GVAR(trenchClass) = _trenchClass;
|
||||
GVAR(trenchPlacementData) = getArray (configFile >> "CfgVehicles" >> _trenchClass >> QGVAR(placementData));
|
||||
TRACE_1("",GVAR(trenchPlacementData));
|
||||
|
||||
TRACE_2("",_trenchTypeName,GVAR(trenchType));
|
||||
// prevent the placing unit from running
|
||||
[_unit, "forceWalk", "ACE_Trenches", true] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// create the trench
|
||||
private "_trench";
|
||||
_trench = createVehicle [GVAR(trenchType) select 1, [0, 0, 0], [], 0, "NONE"];
|
||||
_trench = createVehicle [_noGeoModel, [0, 0, 0], [], 0, "NONE"];
|
||||
|
||||
GVAR(trench) = _trench;
|
||||
|
||||
@ -38,7 +43,6 @@ GVAR(digDirection) = 0;
|
||||
// pfh that runs while the dig is in progress
|
||||
GVAR(digPFH) = [{
|
||||
(_this select 0) params ["_unit", "_trench"];
|
||||
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
|
||||
|
||||
// Cancel if the helper object is gone
|
||||
if (isNull _trench) exitWith {
|
||||
@ -46,12 +50,12 @@ GVAR(digPFH) = [{
|
||||
};
|
||||
|
||||
// Cancel if the place is no longer suitable
|
||||
if !([_unit, GVAR(trenchType)] call FUNC(canDigTrench)) exitWith {
|
||||
if !([_unit] call FUNC(canDigTrench)) exitWith {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
||||
|
||||
// Update trench position
|
||||
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
|
||||
GVAR(trenchPlacementData) params ["_dx", "_dy", "_offset"];
|
||||
private _basePos = eyePos _unit vectorAdd ([sin getDir _unit, +cos getDir _unit, 0] vectorMultiply 1.0);
|
||||
|
||||
private _angle = (GVAR(digDirection) + getDir _unit);
|
||||
|
77
addons/trenches/functions/fnc_removeTrench.sqf
Normal file
77
addons/trenches/functions/fnc_removeTrench.sqf
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support and esteldunedain
|
||||
* Removes trench
|
||||
*
|
||||
* Arguments:
|
||||
* 0: trench <OBJECT>
|
||||
* 1: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [TrenchObj, ACE_player] call ace_trenches_fnc_removeTrench
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_trench", "_unit"];
|
||||
TRACE_2("removeTrench",_trench,_unit);
|
||||
|
||||
private _actualProgress = _trench getVariable [QGVAR(progress), 0];
|
||||
if(_actualProgress == 0) exitWith {};
|
||||
|
||||
// Mark trench as being worked on
|
||||
_trench setVariable [QGVAR(digging), true, true];
|
||||
|
||||
private _removeTime = getNumber (configFile >> "CfgVehicles" >> (typeof _trench) >> QGVAR(removalDuration));
|
||||
private _removeTimeLeft = _removeTime * _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];
|
||||
|
||||
// Remove trench
|
||||
deleteVehicle _trench;
|
||||
|
||||
// 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);
|
||||
};
|
||||
[(_removeTimeLeft + 0.5), [_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(RemovingTrench)] call EFUNC(common,progressBar);
|
||||
|
||||
private _progressLeft = ((1 - _actualProgress) * 10) + 1;
|
||||
private ["_i"];
|
||||
for "_i" from _progressLeft to 10 do {
|
||||
private _vectorDiffZ = _i / 10;
|
||||
private _delay = _removeTime * ((_i / 10) - (1 - _actualProgress));
|
||||
private _progress = 1 - (_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);
|
33
addons/trenches/functions/fnc_setTrenchPlacement.sqf
Normal file
33
addons/trenches/functions/fnc_setTrenchPlacement.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support and esteldunedain
|
||||
* Sets trench placement
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
* 1: trench <OBJECT>
|
||||
* 2: trench id <NUMBER>
|
||||
* 3: position ASL <ARRAY>
|
||||
* 4: vector dir and up <ARRAY>
|
||||
* 5: progress <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player, TrenchObj, 2, [0,0,0], [[0,0,0],[0,0,0]], 0.5] call ace_trenches_fnc_setTrenchPlacement
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_trench", "_trenchId", "_pos", "_vecDirAndUp", "_progress"];
|
||||
|
||||
// If the progress bar was cancelled, cancel elevation
|
||||
// We use an uid to avoid any chance of an older trench being raised when a new one is built
|
||||
if (_unit getVariable [QGVAR(isDiggingId), -1] != _trenchId) exitWith {};
|
||||
|
||||
_trench setPosASL _pos;
|
||||
_trench setVectorDirAndUp _vecDirAndUp;
|
||||
|
||||
// Save progress local
|
||||
_trench setVariable [QGVAR(progress), _progress];
|
@ -1,6 +1,11 @@
|
||||
#define COMPONENT trenches
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define DISABLE_COMPILE_CACHE
|
||||
// #define CBA_DEBUG_SYNCHRONOUS
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_TRENCHES
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
@ -104,11 +104,23 @@
|
||||
<Key ID="STR_ACE_Trenches_DiggingTrench">
|
||||
<English>Digging Trench</English>
|
||||
<German>Grabe Schützengraben</German>
|
||||
<Polish>Kopanie okopu</Polish>
|
||||
<Polish>Kopanie wnęki</Polish>
|
||||
<Italian>Sto Scavando la Trincea</Italian>
|
||||
<Spanish>Cavando trinchera</Spanish>
|
||||
<French>Creuse la tranchée</French>
|
||||
<Czech>Vykopat zákop</Czech>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_ContinueDiggingTrench">
|
||||
<English>Continue Digging Trench</English>
|
||||
<Polish>Wzów kopanie wnęki</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_RemoveEnvelope">
|
||||
<English>Remove Trench</English>
|
||||
<Polish>Usuń wnękę</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_RemovingTrench">
|
||||
<English>Removing Trench</English>
|
||||
<Polish>Usuwanie wnęki</Polish>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user