Skip to content

Commit

Permalink
fixed set mulit Gvar & added more maps
Browse files Browse the repository at this point in the history
  • Loading branch information
AdlerSalbei committed Aug 23, 2019
1 parent 40e1b1b commit 147d140
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 35 deletions.
42 changes: 42 additions & 0 deletions addons/trenches/CfgWorldTexture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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[] = {};
};
};
1 change: 1 addition & 0 deletions addons/trenches/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PREP(canRemoveCamouflage);
PREP(canRemoveTrench);
PREP(continueDiggingTrench);
PREP(deleteCamouflage);
PREP(handleDiggerToGVAR);
PREP(handleDiggingServer);
PREP(handleInteractMenuOpened);
PREP(handleKilled);
Expand Down
3 changes: 2 additions & 1 deletion addons/trenches/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
4 changes: 2 additions & 2 deletions addons/trenches/functions/fnc_addDigger.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 1 addition & 7 deletions addons/trenches/functions/fnc_canPlaceCamouflage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
10 changes: 5 additions & 5 deletions addons/trenches/functions/fnc_continueDiggingTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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
Expand All @@ -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];
Expand Down Expand Up @@ -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 {
Expand All @@ -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;

Expand Down
37 changes: 37 additions & 0 deletions addons/trenches/functions/fnc_handleDiggerToGVAR.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "script_component.hpp"
/*
* Author: Salbei
* Add or remove a unit to the GVAR
*
* Arguments:
* 0: Trench <OBJECT>
* 1: Unit <OBJECT>
* 2: State <BOOLEAN>
* 3: RemoveAll <BOOLEAN>
*
* 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];
};
2 changes: 1 addition & 1 deletion addons/trenches/functions/fnc_handleDiggingServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions addons/trenches/functions/fnc_initTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
2 changes: 1 addition & 1 deletion addons/trenches/functions/fnc_initTrench3DEN.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 4 additions & 9 deletions addons/trenches/functions/fnc_placeCamouflage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion addons/trenches/functions/fnc_placeConfirm.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down
2 changes: 1 addition & 1 deletion addons/trenches/functions/fnc_placeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions addons/trenches/functions/fnc_removeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
};

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

Expand Down

0 comments on commit 147d140

Please sign in to comment.