mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
0c58d8b20b
* 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>
60 lines
2.3 KiB
Plaintext
60 lines
2.3 KiB
Plaintext
// execVM "z\ace\addons\interaction\dev\initReplaceTerrainCursorObject.sqf";
|
|
// use "J" key to replace terrain cursorObject and add dragging actions to it
|
|
|
|
#include "\z\ace\addons\interaction\script_component.hpp"
|
|
|
|
DFUNC(replaceTerrainModelsAdd) = {
|
|
params ["_model", ["_class", ""]];
|
|
if (_model isEqualType objNull) then {
|
|
_model = getModelInfo _model select 1;
|
|
};
|
|
if (_model isEqualTo "") exitWith {systemChat "fail model"; false};
|
|
|
|
private _savedClass = GVAR(replaceTerrainModels) get _model;
|
|
if (!isNil "_savedClass") exitWith {systemChat ("was " + _savedClass); true};
|
|
|
|
private _parent = "";
|
|
if (_class isEqualTo "") then {
|
|
private _configClasses = QUOTE(getNumber (_x >> 'scope') == 2 && {!(configName _x isKindOf 'AllVehicles')}) configClasses (configFile >> "CfgVehicles");
|
|
{
|
|
private _xmodel = toLower getText (_x >> "model");
|
|
if (_xmodel select [0, 1] == "\") then {
|
|
_xmodel = _xmodel select [1];
|
|
};
|
|
if ((_xmodel select [count _xmodel - 4]) != ".p3d") then {
|
|
_xmodel = _xmodel + ".p3d"
|
|
};
|
|
if (_model == _xmodel) then {
|
|
_class = configName _x;
|
|
_parent = configName inheritsFrom _x;
|
|
break;
|
|
};
|
|
} forEach _configClasses;
|
|
};
|
|
if (_class isEqualTo "") exitWith {systemChat "fail class"; false};
|
|
GVAR(replaceTerrainModels) set [_model, _class];
|
|
QEGVAR(interact_menu,renderNearbyActions) call CBA_fnc_localEvent;
|
|
systemChat ("found " + _class);
|
|
diag_log format ["replaceTerrain: class %1: %2", _class, _parent];
|
|
true
|
|
};
|
|
|
|
// DIK_J
|
|
[0x24, [false, false, false], {
|
|
if (
|
|
cursorObject call FUNC(replaceTerrainModelsAdd)
|
|
&& {["ace_dragging"] call EFUNC(common,isModLoaded)}
|
|
) then {
|
|
// wait while server replaces object, then init dragging on all clients
|
|
[{
|
|
if (typeOf cursorObject == "") exitwith {};
|
|
[cursorObject, {
|
|
if !hasInterface exitWith {};
|
|
[_this, true] call EFUNC(dragging,setDraggable);
|
|
[_this, true] call EFUNC(dragging,setCarryable);
|
|
}] remoteExec ["call", 0];
|
|
}, [], 1] call CBA_fnc_waitAndExecute;
|
|
};
|
|
true
|
|
}, nil, nil, false] call CBA_fnc_addKeyHandler;
|