Skip to content

Commit

Permalink
Improved placement & and fixed init issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AdlerSalbei committed Dec 17, 2018
1 parent ccdbfd7 commit 9b0591b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions addons/trenches/CfgWorldTexture.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class CfgWorlds {};
class CfgWorldTexture: CfgWorlds {
//Altis
class Altis {
Expand Down
4 changes: 4 additions & 0 deletions addons/trenches/functions/fnc_getSurfaceTexturePath.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ params [
["_object", objnull, [objNull]]
];

diag_log format ["ACE_TRENCHES Object: %1", _object];

if (isNull _object) exitWith {};
if !((isNil QGVAR(automaticFileSetup)) && (isText (configFile >> "CfgWorldTexture" >> worldName >> "surfaceTextureBasePath"))) exitWith {DEFAULT_TEXTURE};

Expand Down Expand Up @@ -58,4 +60,6 @@ private _result = if !(isNil QGVAR(automaticFileSetup)) then {
[_surfaceType, _basePath, getText(configFile >> "CfgWorldTexture" >> worldName >> "suffix")] call _getTexturePath;
};

diag_log format ["ACE_TRENCHES Result: %1", _result];

_result
7 changes: 4 additions & 3 deletions addons/trenches/functions/fnc_initTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +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 _texture = [_this select 0] call FUNC(getSurfaceTexturePath);
(_this select 0) setObjectTextureGlobal [0, _texture];
}, [_this]] call CBA_fnc_execNextFrame;
private _obj = if (_this isEqualType []) then {_this select 0} else {_this};
private _texture = [_obj] call FUNC(getSurfaceTexturePath);
_obj setObjectTextureGlobal [0, _texture];
}, _this] call CBA_fnc_execNextFrame;
};
9 changes: 6 additions & 3 deletions addons/trenches/functions/fnc_placeConfirm.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ if (isNull GVAR(trench)) exitWith {};

private _trenchClass = typeOf GVAR(trench);
private _vecDirAndUp = [vectorDir GVAR(trench), vectorUp GVAR(trench)];
private _pos = getPosWorld GVAR(trench);
diag_log format ["ACE_TRENCHES Old Pos: %1", _pos];
deleteVehicle GVAR(trench);

GVAR(trenchPos) set [2, -0.2];
private _trench = createVehicle [_trenchClass, GVAR(trenchPos), [], 0, "CAN_COLLIDE"];
diag_log format ["ACE_TRENCHES New Pos: %1", _pos];
private _trench = createVehicle [_trenchClass, _pos, [], 0, "CAN_COLLIDE"];
_trench setObjectTextureGlobal [0,[_trench] call FUNC(getSurfaceTexturePath)];
_trench setPosWorld GVAR(trenchPos);
_trench setPosWorld _pos;

private _boundingBox = boundingBoxReal _trench;
_boundingBox params ["_lbfc", "_rtbc"]; //_lbfc(Left Bottom Front Corner) _rtbc (Right Top Back Corner)
Expand All @@ -52,6 +54,7 @@ _rtbc params ["", "", "_rtbcZ"];
private _boundingBoxOffset = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> _trenchClass >> QGVAR(boundingBoxOffset)),0];
private _posDiff = abs _lbfcZ + abs _rtbcZ - _boundingBoxOffset;
private _newPos = _trench modelToWorldWorld [0,0, -_posDiff];
diag_log format ["ACE_TRENCHES Underearth Pos: %1", _pos];
_trench setPosWorld _newPos;

_trench setVariable [QGVAR(diggingSteps), _posDiff/1000,true];
Expand Down
4 changes: 2 additions & 2 deletions addons/trenches/functions/fnc_placeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ GVAR(digPFH) = [{
#endif
};
};
_basePos set [2, (_basePos select 2) + _minzoffset + _offset];
// _basePos set [2, (_basePos select 2) + _minzoffset + _offset];
_basePos set [2, (_basePos select 2) + _minzoffset];
TRACE_2("",_minzoffset,_offset);
_trench setPosASL _basePos;
_trench setVectorDirAndUp [_v1, _v3];
GVAR(trenchPos) = _basePos;

if (surfaceType position _trench != GVAR(currentSurface)) then {
GVAR(currentSurface) = surfaceType (position _trench);
Expand Down

0 comments on commit 9b0591b

Please sign in to comment.