From 147d140306775bc3cb96573b406539260d12ace7 Mon Sep 17 00:00:00 2001 From: Salbei Date: Fri, 23 Aug 2019 18:09:34 +0200 Subject: [PATCH] fixed set mulit Gvar & added more maps --- addons/trenches/CfgWorldTexture.hpp | 42 +++++++++++++++++++ addons/trenches/XEH_PREP.hpp | 1 + addons/trenches/XEH_postInit.sqf | 3 +- addons/trenches/functions/fnc_addDigger.sqf | 4 +- .../functions/fnc_canPlaceCamouflage.sqf | 8 +--- .../functions/fnc_continueDiggingTrench.sqf | 10 ++--- .../functions/fnc_handleDiggerToGVAR.sqf | 37 ++++++++++++++++ .../functions/fnc_handleDiggingServer.sqf | 2 +- addons/trenches/functions/fnc_initTrench.sqf | 6 +-- .../trenches/functions/fnc_initTrench3DEN.sqf | 2 +- .../functions/fnc_placeCamouflage.sqf | 13 ++---- .../trenches/functions/fnc_placeConfirm.sqf | 2 +- addons/trenches/functions/fnc_placeTrench.sqf | 2 +- .../trenches/functions/fnc_removeTrench.sqf | 9 ++-- 14 files changed, 106 insertions(+), 35 deletions(-) create mode 100644 addons/trenches/functions/fnc_handleDiggerToGVAR.sqf diff --git a/addons/trenches/CfgWorldTexture.hpp b/addons/trenches/CfgWorldTexture.hpp index f09a36e9207..94a7e93b4ad 100644 --- a/addons/trenches/CfgWorldTexture.hpp +++ b/addons/trenches/CfgWorldTexture.hpp @@ -51,6 +51,13 @@ class CfgWorldTexture: CfgWorlds { camouflageObjects[] = {"ca\plants2\clutter\c_weed3.p3d"}; }; + //Cham + class tem_cham { + surfaceTextureBasePath = "tem\tem_cham\data"; + suffix = "co.paa"; + camouflageObjects[] = {}; + }; + //Chernarus class Chernarus { surfaceTextureBasePath = "ca\CHERNARUS\data"; @@ -394,4 +401,39 @@ class CfgWorldTexture: CfgWorlds { suffix = "co.paa"; camouflageObjects[] = {}; }; + + //Chernarus Redux + class chernarusredux { + surfaceTextureBasePath = "CHR\chernarusredux_data\data"; + suffix = "_co.paa"; + camouflageObjects[] = {}; + }; + + //Weferlingen Summer + class gm_weferlingen_summer { + surfaceTextureBasePath = "gm\gm_worlds\gm_weferlingen_summer\data"; + suffix = "co.paa"; + camouflageObjects[] = {}; + }; + + //Weferlingen Winter + class gm_weferlingen_winter { + surfaceTextureBasePath = "gm\gm_worlds\gm_weferlingen_winter\data"; + suffix = "co.paa"; + camouflageObjects[] = {}; + }; + + //Weferlingen Winter + class vinjesvigen { + surfaceTextureBasePath = "gm\gm_worlds\gm_weferlingen_winter\data"; + suffix = "co.paa"; + camouflageObjects[] = {}; + }; + + //Vinjesvingenc + class tem_vinjesvingenc { + surfaceTextureBasePath = "tem\tem_vinjesvingenc\data"; + suffix = "co.paa"; + camouflageObjects[] = {}; + }; }; diff --git a/addons/trenches/XEH_PREP.hpp b/addons/trenches/XEH_PREP.hpp index 40384f42cce..ccbef3fa8aa 100644 --- a/addons/trenches/XEH_PREP.hpp +++ b/addons/trenches/XEH_PREP.hpp @@ -9,6 +9,7 @@ PREP(canRemoveCamouflage); PREP(canRemoveTrench); PREP(continueDiggingTrench); PREP(deleteCamouflage); +PREP(handleDiggerToGVAR); PREP(handleDiggingServer); PREP(handleInteractMenuOpened); PREP(handleKilled); diff --git a/addons/trenches/XEH_postInit.sqf b/addons/trenches/XEH_postInit.sqf index df1c9bf8687..1f1455b42d4 100644 --- a/addons/trenches/XEH_postInit.sqf +++ b/addons/trenches/XEH_postInit.sqf @@ -3,7 +3,8 @@ if (isServer) then { // Cancel dig on hard disconnection. Function is identical to killed addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleKilled)}]; - [QGVAR(handleDiggingServer), {_this call FUNC(handleDiggingServer)}] call CBA_fnc_addEventHandler; + [QGVAR(addDigger), {_this call FUNC(handleDiggingServer)}] call CBA_fnc_addEventHandler; + [QGVAR(handleDiggingServer), {_this call FUNC(addDiggerToGVAR)}] call CBA_fnc_addEventHandler; }; if (!hasInterface) exitWith {}; diff --git a/addons/trenches/functions/fnc_addDigger.sqf b/addons/trenches/functions/fnc_addDigger.sqf index 93d115b7d7a..fb3d1ee336f 100644 --- a/addons/trenches/functions/fnc_addDigger.sqf +++ b/addons/trenches/functions/fnc_addDigger.sqf @@ -26,7 +26,7 @@ if ( [_trench, _unit] call FUNC(continueDiggingTrench); }; -_trench setVariable [QGVAR(diggingPlayers), _diggingPlayers pushBackUnique ACE_player, true]; +[QGVAR(addDigger), [_trench, _unit]] call CBA_fnc_serverEvent; private _finishCondition = {false}; private _digTime = 0; @@ -67,7 +67,7 @@ private _fnc_onFinish = { private _fnc_onFailure = { (_this select 0) params ["_unit", "_trench"]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers),[]] - [_unit], true]; + [QGVAR(addDigger), [_trench, _unit, false]] call CBA_fnc_serverEvent; // Reset animation [_unit, "", 1] call EFUNC(common,doAnimation); diff --git a/addons/trenches/functions/fnc_canPlaceCamouflage.sqf b/addons/trenches/functions/fnc_canPlaceCamouflage.sqf index bd0bfd04eec..07606b8f54a 100644 --- a/addons/trenches/functions/fnc_canPlaceCamouflage.sqf +++ b/addons/trenches/functions/fnc_canPlaceCamouflage.sqf @@ -19,13 +19,7 @@ params ["_trench", "_unit"]; private _statusNumber = _trench getVariable [QGVAR(trenchCamouflageStatus), 0]; -private _statusString = ""; - -if (_statusNumber < 10) then { - _statusString = ("CamouflagePositions0" + str(_statusNumber +1)); -} else { - _statusString = ("CamouflagePositions" + str(_statusNumber +1)); -}; +private _statusString = "CamouflagePositions" + str(_statusNumber +1); if !(GVAR(allowCamouflage)) exitWith {false}; if (GVAR(camouflageRequireEntrenchmentTool) && {!("ACE_EntrenchingTool" in items _unit)}) exitWith {false}; diff --git a/addons/trenches/functions/fnc_continueDiggingTrench.sqf b/addons/trenches/functions/fnc_continueDiggingTrench.sqf index a5280165462..e75b47fc24f 100644 --- a/addons/trenches/functions/fnc_continueDiggingTrench.sqf +++ b/addons/trenches/functions/fnc_continueDiggingTrench.sqf @@ -33,7 +33,7 @@ if (_diggerCount > 0) then { [_trench, _unit] call FUNC(addDigger); }; } else { - _trench setVariable [QGVAR(diggingPlayers), [ACE_player],true]; + [QGVAR(addDigger), [_trench, _unit, true]] call CBA_fnc_serverEvent; }; private _digTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(diggingDuration)), 20]; @@ -51,7 +51,7 @@ private _fnc_onFinish = { (_this select 0) params ["_unit", "_trench"]; _trench setVariable [QGVAR(digging), false, true]; _trench setVariable [QGVAR(diggingType), nil, true]; - _trench setVariable [QGVAR(diggingPlayers), [], true]; + [QGVAR(addDigger), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; // Save progress global @@ -65,7 +65,7 @@ private _fnc_onFailure = { (_this select 0) params ["_unit", "_trench"]; _trench setVariable [QGVAR(digging), false, true]; _trench setVariable [QGVAR(diggingType), nil, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers),[]] - [_unit], true]; + [QGVAR(addDigger), [_trench, _unit, false]] call CBA_fnc_serverEvent;; // Save progress global private _progress = _trench getVariable [QGVAR(progress), 0]; @@ -109,7 +109,7 @@ if (_actualProgress == 0) then { ) exitWith { [_handle] call CBA_fnc_removePerFrameHandler; _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers),[]] - [_unit], true]; + [QGVAR(addDigger), [_trench, _unit, false]] call CBA_fnc_serverEvent; }; if (_actualProgress >= 1) exitWith { @@ -130,7 +130,7 @@ if (_actualProgress == 0) then { if (GVAR(stopBuildingAtFatigueMax) && {EGVAR(advanced_fatigue,anReserve) <= 0}) exitWith { [_handle] call CBA_fnc_removePerFrameHandler; _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; + [QGVAR(addDigger), [_trench, _unit, false]] call CBA_fnc_serverEvent; }; }, 1, [_trench, _unit, _digTime, _vecDirAndUp]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/trenches/functions/fnc_handleDiggerToGVAR.sqf b/addons/trenches/functions/fnc_handleDiggerToGVAR.sqf new file mode 100644 index 00000000000..36d15f8b565 --- /dev/null +++ b/addons/trenches/functions/fnc_handleDiggerToGVAR.sqf @@ -0,0 +1,37 @@ +#include "script_component.hpp" +/* + * Author: Salbei + * Add or remove a unit to the GVAR + * + * Arguments: + * 0: Trench + * 1: Unit + * 2: State + * 3: RemoveAll + * + * Return Value: + * None + * + * Example: + * [TrenchObj, ACE_player, true, false] call ace_trenches_fnc_handleDiggerToGVAR + * + * Public: No + */ + +params ["_trench", "_unit", "_state", ["_removeAll", false]]; + +if (_removeAll) exitWith { + _trench setVariable [QGVAR(diggingPlayers), [], true]; +}; + +if (_state) then { + private _diggingPlayers = _trench getVariable [QGVAR(diggingPlayers), []]; + private _return = _diggingPlayers pushBackUnique _unit; + if (_return > -1) then { + _trench setVariable [QGVAR(diggingPlayers), _diggingPlayers, true]; + }; +} else { + private _diggingPlayers = _trench getVariable [QGVAR(diggingPlayers), []]; + _diggingPlayers - [_unit]; + _trench setVariable [QGVAR(diggingPlayers), _diggingPlayers, true]; +}; diff --git a/addons/trenches/functions/fnc_handleDiggingServer.sqf b/addons/trenches/functions/fnc_handleDiggingServer.sqf index dc9655cdeac..228886aa3aa 100644 --- a/addons/trenches/functions/fnc_handleDiggingServer.sqf +++ b/addons/trenches/functions/fnc_handleDiggingServer.sqf @@ -34,7 +34,7 @@ if (_initiator) then { _diggingPlayers = _diggingPlayers - [objNull]; if !(_diggingPlayers isEqualTo (_trench getVariable [QGVAR(diggingPlayers), []])) then { - _trench setVariable [QGVAR(diggingPlayers), [_diggingPlayers], true]; + [QGVAR(addDigger), [_trench, _unit, true]] call CBA_fnc_serverEvent; }; if ( diff --git a/addons/trenches/functions/fnc_initTrench.sqf b/addons/trenches/functions/fnc_initTrench.sqf index 9651da8ee60..d22edf823cf 100644 --- a/addons/trenches/functions/fnc_initTrench.sqf +++ b/addons/trenches/functions/fnc_initTrench.sqf @@ -29,8 +29,8 @@ if (is3DEN) exitWith { if (local _object) then { // Has to be delayed to ensure MP compatibility (vehicle spawned in same frame as texture is applied) [{ - private _obj = if (_this isEqualType []) then {_this select 0} else {_this}; + params ["_obj"]; private _texture = [_obj] call FUNC(getSurfaceTexturePath); - _obj setObjectTextureGlobal [0, _texture]; - }, _this] call CBA_fnc_execNextFrame; + _object setObjectTextureGlobal [0, _texture]; + }, _object] call CBA_fnc_execNextFrame; }; diff --git a/addons/trenches/functions/fnc_initTrench3DEN.sqf b/addons/trenches/functions/fnc_initTrench3DEN.sqf index 2a2586b894c..b30fe474d2a 100644 --- a/addons/trenches/functions/fnc_initTrench3DEN.sqf +++ b/addons/trenches/functions/fnc_initTrench3DEN.sqf @@ -43,7 +43,7 @@ private _initTrench = { if (isNull _object) then { { if (IS_TRENCH(_x)) then { - [_x] call _initTrench; + _x call _initTrench; }; } forEach (all3DENEntities select 0); } else { diff --git a/addons/trenches/functions/fnc_placeCamouflage.sqf b/addons/trenches/functions/fnc_placeCamouflage.sqf index 4fb31e559d7..07954cd3643 100644 --- a/addons/trenches/functions/fnc_placeCamouflage.sqf +++ b/addons/trenches/functions/fnc_placeCamouflage.sqf @@ -28,29 +28,24 @@ private _fnc_onFinish = { private _camouflageObjects = getArray (configFile >> "CfgWorldTexture" >> worldName >> "camouflageObjects"); private _statusNumber = _trench getVariable [QGVAR(trenchCamouflageStatus), 0]; - private _statusString = ""; _statusNumber = _statusNumber +1; - - if (_statusNumber <10) then { - _statusString = ("0" + str(_statusNumber)); - } else { - _statusString = str(_statusNumber); - }; + private _statusString = str _statusNumber; private _placedObjects = []; private _camouflageObjectsArray = _trench getVariable [QGVAR(camouflageObjects), []]; { private _object = createSimpleObject [selectRandom _camouflageObjects, [0,0,0]]; - _object attachTo [_trench, getArray(_x)]; + _object attachTo [_trench, getArray _x]; if (is3DEN) then { - _object setVariable [QGVAR(positionData), getArray(_x),true]; + _object setVariable [QGVAR(positionData), getArray _x,true]; }; _placedObjects pushBack _object; } forEach (configProperties [configFile >> "CfgVehicles" >> (typeof _trench) >> ("CamouflagePositions" + _statusString)]); + // pushFront reverse _camouflageObjectsArray; _camouflageObjectsArray pushBack _placedObjects; reverse _camouflageObjectsArray; diff --git a/addons/trenches/functions/fnc_placeConfirm.sqf b/addons/trenches/functions/fnc_placeConfirm.sqf index 8882d65246c..b3cde2a9277 100644 --- a/addons/trenches/functions/fnc_placeConfirm.sqf +++ b/addons/trenches/functions/fnc_placeConfirm.sqf @@ -40,7 +40,7 @@ private _vecDirAndUp = [vectorDir GVAR(trench), vectorUp GVAR(trench)]; private _pos = getPosWorld GVAR(trench); deleteVehicle GVAR(trench); -private _trench = createVehicle [_trenchClass, _pos, [], 0, "CAN_COLLIDE"]; +private _trench = createVehicle [_trenchClass, [0,0,0], [], 0, "CAN_COLLIDE"]; _trench setPosWorld _pos; _trench setVectorDirAndUp _vecDirAndUp; _trench setObjectTextureGlobal [0, [_trench] call FUNC(getSurfaceTexturePath)]; diff --git a/addons/trenches/functions/fnc_placeTrench.sqf b/addons/trenches/functions/fnc_placeTrench.sqf index 6906c6863cb..24f9338e9e5 100644 --- a/addons/trenches/functions/fnc_placeTrench.sqf +++ b/addons/trenches/functions/fnc_placeTrench.sqf @@ -90,7 +90,7 @@ GVAR(digPFH) = [{ _trench setVectorDirAndUp [_v1, _v3]; if (surfaceType position _trench != GVAR(currentSurface)) then { - GVAR(currentSurface) = surfaceType (position _trench); + GVAR(currentSurface) = surfaceType (getPosASL _trench); _trench setObjectTextureGlobal [0, [_trench] call FUNC(getSurfaceTexturePath)]; }; }, 0, [_unit, _trench]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/trenches/functions/fnc_removeTrench.sqf b/addons/trenches/functions/fnc_removeTrench.sqf index 11364d4f529..6a1fb7d1728 100644 --- a/addons/trenches/functions/fnc_removeTrench.sqf +++ b/addons/trenches/functions/fnc_removeTrench.sqf @@ -33,7 +33,7 @@ if (_diggerCount > 0) then { [_trench, _unit] call FUNC(addDigger); }; } else { - _trench setVariable [QGVAR(diggingPlayers), [ACE_player], true]; + [QGVAR(addDigger), [_trench, _unit, true]] call CBA_fnc_serverEvent; }; private _removeTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(removalDuration)), 20]; @@ -63,6 +63,7 @@ private _fnc_onFailure = { (_this select 0) params ["_unit", "_trench"]; _trench setVariable [QGVAR(digging), false, true]; _trench setVariable [QGVAR(diggingType), nil, true]; + [QGVAR(addDigger), [_trench, _unit, false]] call CBA_fnc_serverEvent; // Save progress global private _progress = _trench getVariable [QGVAR(progress), 0]; @@ -91,7 +92,7 @@ private _fnc_condition = { if (_actualProgress <= 0) exitWith { [_handle] call CBA_fnc_removePerFrameHandler; _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), [], true]; + [QGVAR(addDigger), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; deleteVehicle _trench; }; @@ -101,7 +102,7 @@ private _fnc_condition = { ) exitWith { [_handle] call CBA_fnc_removePerFrameHandler; _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; + [QGVAR(addDigger), [_trench, _unit, false]] call CBA_fnc_serverEvent; }; private _pos = getPosWorld _trench; @@ -118,7 +119,7 @@ private _fnc_condition = { if (GVAR(stopBuildingAtFatigueMax) && {EGVAR(advanced_fatigue,anReserve) <= 0}) exitWith { [_handle] call CBA_fnc_removePerFrameHandler; _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; + [QGVAR(addDigger), [_trench, _unit, false]] call CBA_fnc_serverEvent; }; },1,[_trench, _unit, _removeTime, _vecDirAndUp]] call CBA_fnc_addPerFrameHandler;