mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
move placement data to config, setTrenchPlacement fnc, cleanup
This commit is contained in:
parent
d6e9890b1b
commit
203c059cc1
@ -4,20 +4,18 @@ class CBA_Extended_EventHandlers;
|
||||
class ACE_MainActions { \
|
||||
displayName = ECSTRING(interaction,MainAction); \
|
||||
selection = ""; \
|
||||
distance = 10; \
|
||||
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);); \
|
||||
showDisabled = 0; \
|
||||
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);); \
|
||||
showDisabled = 0; \
|
||||
priority = -1; \
|
||||
}; \
|
||||
}; \
|
||||
@ -30,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;
|
||||
@ -40,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;
|
||||
@ -61,6 +59,8 @@ class CfgVehicles {
|
||||
scope = 2;
|
||||
GVAR(diggingDuration) = 20;
|
||||
GVAR(removalDuration) = 12;
|
||||
GVAR(noGeoClass) = "ACE_envelope_small_NoGeo";
|
||||
GVAR(placementData)[] = {2,3,0.35};
|
||||
ACE_TRENCHES_ACTIONS;
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
@ -74,6 +74,8 @@ class CfgVehicles {
|
||||
scope = 2;
|
||||
GVAR(diggingDuration) = 25;
|
||||
GVAR(removalDuration) = 15;
|
||||
GVAR(noGeoClass) = "ACE_envelope_big_NoGeo";
|
||||
GVAR(placementData)[] = {6,1.1,0.20};
|
||||
ACE_TRENCHES_ACTIONS;
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
|
@ -1,5 +1,8 @@
|
||||
|
||||
PREP(canContinueDiggingTrench);
|
||||
PREP(canDigTrench);
|
||||
PREP(canRemoveTrench);
|
||||
PREP(continueDiggingTrench);
|
||||
PREP(handleInteractMenuOpened);
|
||||
PREP(handleKilled);
|
||||
PREP(handlePlayerChanged);
|
||||
@ -9,7 +12,5 @@ PREP(handleUnconscious);
|
||||
PREP(placeCancel);
|
||||
PREP(placeConfirm);
|
||||
PREP(placeTrench);
|
||||
PREP(canContinueDiggingTrench);
|
||||
PREP(canRemoveTrench);
|
||||
PREP(continueDiggingTrench);
|
||||
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;
|
||||
|
@ -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)
|
||||
|
@ -65,23 +65,8 @@ private _fnc_onFailure = {
|
||||
};
|
||||
[(_digTimeLeft + 0.5), [_unit, _trench], _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", "_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];
|
||||
};
|
||||
|
||||
if(_actualProgress == 0) then {
|
||||
[_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 1.0], _vecDirAndUp, _actualProgress] call _fnc_setPlacing;
|
||||
[_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 1.0], _vecDirAndUp, _actualProgress] call FUNC(setTrenchPlacement);
|
||||
};
|
||||
|
||||
private _progressLeft = (_actualProgress * 10) + 1;
|
||||
@ -90,7 +75,7 @@ for "_i" from _progressLeft to 10 do {
|
||||
private _vectorDiffZ = 1 - (_i / 10);
|
||||
private _delay = _digTime * ((_i / 10) - _actualProgress);
|
||||
private _progress = _i / 10;
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, _vectorDiffZ], _vecDirAndUp, _progress], _delay] call EFUNC(common,waitAndExecute);
|
||||
[DFUNC(setTrenchPlacement), [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, _vectorDiffZ], _vecDirAndUp, _progress], _delay] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
||||
// Play animation
|
||||
|
@ -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);
|
||||
|
||||
|
@ -4,29 +4,34 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
* 1: Trench type <STRING>
|
||||
* 1: Trench class <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player, "ace_trenches_trenchBig"] 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);
|
||||
|
@ -63,21 +63,6 @@ private _fnc_onFailure = {
|
||||
};
|
||||
[(_removeTimeLeft + 0.5), [_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(RemovingTrench)] call EFUNC(common,progressBar);
|
||||
|
||||
// Schedule progressive raising of the trench
|
||||
private _fnc_setPlacing = {
|
||||
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];
|
||||
};
|
||||
|
||||
private _progressLeft = ((1 - _actualProgress) * 10) + 1;
|
||||
private ["_i"];
|
||||
for "_i" from _progressLeft to 10 do {
|
||||
@ -85,7 +70,7 @@ for "_i" from _progressLeft to 10 do {
|
||||
private _delay = _removeTime * ((_i / 10) - (1 - _actualProgress));
|
||||
private _progress = 1 - (_i / 10);
|
||||
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, _vectorDiffZ], _vecDirAndUp, _progress], _delay] call EFUNC(common,waitAndExecute);
|
||||
[DFUNC(setTrenchPlacement), [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, _vectorDiffZ], _vecDirAndUp, _progress], _delay] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
||||
// Play animation
|
||||
|
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];
|
Loading…
Reference in New Issue
Block a user