ACE3/addons/interaction/functions/fnc_replaceTerrainObject.sqf
Dystopian 0c58d8b20b
Interaction - Add interaction with terrain objects (#8103)
* Add interaction with terrain objects

* Optimize with new commands

* Handle z-position under ground

* Add warning for setting

* Add parentheses to condition

Co-authored-by: jonpas <jonpas33@gmail.com>

* Add comments

* Add parentheses to condition

Co-authored-by: jonpas <jonpas33@gmail.com>

* Add parentheses to condition

Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>

* Add replacement configs to dragging

This reverts commit afc5abe6cd.

* Fix validator error and optimize condition

Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2021-10-12 14:36:33 -05:00

38 lines
908 B
Plaintext

#include "script_component.hpp"
/*
* Author: Dystopian
* Replaces terrain object with created one.
* Run on server only.
*
* Arguments:
* 0: Terrain object <OBJECT>
* 1: New object class <STRING>
*
* Return Value:
* None
*
* Example:
* [cursorObject, "Land_Bucket_F"] call ace_interaction_fnc_replaceTerrainObject
*
* Public: No
*/
params ["_terrainObject", "_class"];
TRACE_2("",_terrainObject,_class);
if (isObjectHidden _terrainObject) exitWith {};
private _position = getPosATL _terrainObject;
if (_position select 2 < 0) then {
_position set [2, 0];
};
private _vectorDirAndUp = [vectorDir _terrainObject, vectorUp _terrainObject];
hideObjectGlobal _terrainObject;
// prevent new object clipping with old one
_terrainObject setDamage [1, false];
private _newObject = createVehicle [_class, [0,0,0]];
_newObject setVectorDirAndUp _vectorDirAndUp;
_newObject setPosATL _position;