-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> * Add comments * Add parentheses to condition Co-authored-by: jonpas <[email protected]> * Add parentheses to condition Co-authored-by: mharis001 <[email protected]> * Add replacement configs to dragging This reverts commit afc5abe. * Fix validator error and optimize condition Co-authored-by: jonpas <[email protected]> Co-authored-by: mharis001 <[email protected]> Co-authored-by: PabstMirror <[email protected]>
- Loading branch information
1 parent
63d7419
commit 0c58d8b
Showing
10 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,6 @@ PREP(openDoor); | |
PREP(canPush); | ||
PREP(push); | ||
|
||
// misc | ||
PREP(canFlip); | ||
PREP(replaceTerrainObject); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
#include "script_component.hpp" | ||
|
||
#include "XEH_PREP.hpp" | ||
|
||
if (!hasInterface) exitWith {}; | ||
|
||
private _replaceTerrainClasses = QUOTE( | ||
getNumber (_x >> QQGVAR(replaceTerrainObject)) > 0 | ||
&& {getNumber (_x >> 'scope') == 2} | ||
) configClasses (configFile >> "CfgVehicles"); | ||
|
||
private _cacheReplaceTerrainModels = createHashMap; | ||
{ | ||
private _model = toLower getText (_x >> "model"); | ||
if (_model select [0, 1] == "\") then { | ||
_model = _model select [1]; | ||
}; | ||
if ((_model select [count _model - 4]) != ".p3d") then { | ||
_model = _model + ".p3d" | ||
}; | ||
if (_model in _cacheReplaceTerrainModels) then {continue}; | ||
_cacheReplaceTerrainModels set [_model, configName _x]; | ||
} forEach _replaceTerrainClasses; | ||
|
||
uiNamespace setVariable [QGVAR(cacheReplaceTerrainModels), compileFinal str _cacheReplaceTerrainModels]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters