2015-03-16 18:25:29 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
|
|
|
* Fixes position of an object. E.g. moves object above ground and adjusts to terrain slope. Requires local object.
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-09-20 14:56:35 +00:00
|
|
|
* Object <OBJECT>
|
2015-03-16 18:25:29 +00:00
|
|
|
*
|
2015-09-20 14:56:35 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-03-16 18:25:29 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
// setVectorUp requires local object
|
|
|
|
if (!local _this) exitWith {};
|
|
|
|
|
2016-03-02 00:49:41 +00:00
|
|
|
if ((getText (configFile >> "CfgVehicles" >> (typeOf _this) >> "simulation")) == "house") then {
|
|
|
|
//Houses don't have gravity/physics, so make sure they are not floating
|
|
|
|
private _posAbove = (getPos _this) select 2;
|
|
|
|
TRACE_2("house",_this,_posAbove);
|
|
|
|
if (_posAbove > 0.1) then {
|
|
|
|
private _newPosASL = (getPosASL _this) vectorDiff [0,0,_posAbove];
|
|
|
|
_this setPosASL _newPosASL;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _position = getPos _this;
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// don't place the object below the ground
|
2015-03-18 12:36:22 +00:00
|
|
|
if (_position select 2 < -0.1) then {
|
|
|
|
_position set [2, -0.1];
|
2015-03-16 18:25:29 +00:00
|
|
|
_this setPos _position;
|
|
|
|
};
|
|
|
|
|
|
|
|
// adjust position to sloped terrain, if placed on ground
|
|
|
|
if (getPosATL _this select 2 == _position select 2) then {
|
|
|
|
_this setVectorUp surfaceNormal _position;
|
|
|
|
};
|