mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
49 lines
1.7 KiB
Plaintext
49 lines
1.7 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: commy2, Jonpas
|
|
* Fixes position of an object. E.g. moves object above ground and adjusts to terrain slope. Requires local object.
|
|
*
|
|
* Arguments:
|
|
* Object <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* bob call ace_common_fnc_fixPosition
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
// setVectorUp requires local object
|
|
if (!local _this) exitWith {};
|
|
|
|
// Objects with disabled simulation and objects with simulation type "house" don't have gravity/physics, so make sure they are not floating
|
|
private _hasGravity = simulationEnabled _this && {getText (configFile >> "CfgVehicles" >> typeOf _this >> "simulation") != "house"};
|
|
|
|
if (!_hasGravity) then {
|
|
private _positionASL = getPosASL _this;
|
|
// find height of top surface under object
|
|
private _surfaces = lineIntersectsSurfaces [_positionASL, ATLToASL [_positionASL select 0, _positionASL select 1, -1], _this];
|
|
if (_surfaces isEqualTo []) exitWith {};
|
|
private _surfaceHeight = _surfaces select 0 select 0 select 2;
|
|
TRACE_2("house",_this,_surfaceHeight);
|
|
if (_positionASL select 2 > _surfaceHeight + 0.1) then {
|
|
_this setPosASL [_positionASL select 0, _positionASL select 1, _surfaceHeight];
|
|
};
|
|
};
|
|
|
|
private _position = getPosATL _this;
|
|
|
|
// Don't place the object below the ground
|
|
if (_position select 2 < -0.1) then {
|
|
_position set [2, -0.1];
|
|
_this setPosATL _position;
|
|
};
|
|
|
|
// Adjust position to sloped terrain, if placed on ground
|
|
// Object without gravity/physics may have negative height when placed on slope, but those objects are definitely on the ground
|
|
if (!_hasGravity || {getPosATL _this select 2 == _position select 2}) then {
|
|
_this setVectorUp surfaceNormal _position;
|
|
};
|