mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Custom Materials for tagging (#6704)
* Allow custom materials for tags * Fix quickTag * More betterer
This commit is contained in:
parent
b3e0135e32
commit
ba18d5f748
@ -9,6 +9,7 @@
|
||||
* 2: Required Item <STRING>
|
||||
* 3: Textures Paths <ARRAY>
|
||||
* 4: Icon Path <STRING> (default: "")
|
||||
* 5: Material Paths <ARRAY> (optional)
|
||||
*
|
||||
* Return Value:
|
||||
* Sucessfully Added Tag <BOOL>
|
||||
@ -24,7 +25,8 @@ params [
|
||||
["_displayName", "", [""]],
|
||||
["_requiredItem", "", [""]],
|
||||
["_textures", [], [[]]],
|
||||
["_icon", "", [""]]
|
||||
["_icon", "", [""]],
|
||||
["_materials", [], [[]]]
|
||||
];
|
||||
|
||||
// Verify
|
||||
@ -50,4 +52,4 @@ if (_textures isEqualTo []) exitWith {
|
||||
_identifier = [_identifier] call CBA_fnc_removeWhitespace;
|
||||
|
||||
// Add
|
||||
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon]] call CBA_fnc_globalEventJIP;
|
||||
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon, _materials]] call CBA_fnc_globalEventJIP;
|
||||
|
@ -19,7 +19,7 @@ params ["_unit"];
|
||||
|
||||
private _actions = [];
|
||||
{
|
||||
_x params ["_class", "_displayName", "_requiredItem", "_textures", "_icon"];
|
||||
_x params ["_class", "_displayName", "_requiredItem", "_textures", "_icon", "_materials"];
|
||||
|
||||
_actions pushBack [
|
||||
[
|
||||
@ -27,8 +27,18 @@ private _actions = [];
|
||||
_displayName,
|
||||
_icon,
|
||||
{
|
||||
(_this select 2) params ["_unit", "_class", "_textures"];
|
||||
[_unit, selectRandom _textures] call FUNC(tag);
|
||||
(_this select 2) params ["_unit", "_class", "_textures", "", "_materials"];
|
||||
|
||||
(
|
||||
if (count _textures == count _materials) then {
|
||||
private _textureIndex = floor random count _textures;
|
||||
[_textures select _textureIndex, _materials select _textureIndex]
|
||||
} else {
|
||||
[selectRandom _textures, selectRandom _materials]
|
||||
}
|
||||
) params ["_randomTexture", "_randomMaterial"];
|
||||
|
||||
[_unit, _randomTexture, _randomMaterial] call FUNC(tag);
|
||||
_unit setVariable [QGVAR(lastUsedTag), _class];
|
||||
},
|
||||
{
|
||||
@ -36,7 +46,7 @@ private _actions = [];
|
||||
_requiredItem in (_unit call EFUNC(common,uniqueItems))
|
||||
},
|
||||
{},
|
||||
[_unit, _class, _textures, _requiredItem]
|
||||
[_unit, _class, _textures, _requiredItem, _materials]
|
||||
] call EFUNC(interact_menu,createAction),
|
||||
[],
|
||||
_unit
|
||||
|
@ -9,6 +9,7 @@
|
||||
* 2: Required Item <STRING>
|
||||
* 3: Textures Paths <ARRAY>
|
||||
* 4: Icon Path <STRING> (default: "")
|
||||
* 5: Material Paths <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
|
@ -44,10 +44,12 @@
|
||||
_failure = true;
|
||||
};
|
||||
|
||||
private _materials = getArray (_x >> "materials");
|
||||
|
||||
private _icon = getText (_x >> "icon");
|
||||
|
||||
if (!_failure) then {
|
||||
GVAR(cachedTags) pushBack [_class, _displayName, _requiredItem, _textures, _icon];
|
||||
GVAR(cachedTags) pushBack [_class, _displayName, _requiredItem, _textures, _icon, _materials];
|
||||
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
|
||||
};
|
||||
} forEach ("true" configClasses (configFile >> "ACE_Tags"));
|
||||
|
@ -9,6 +9,7 @@
|
||||
* 2: Colour of the tag (valid colours are black, red, green and blue or full path to custom texture) <STRING>
|
||||
* 3: Object it should be tied to <OBJECT>
|
||||
* 4: Unit that created the tag <OBJECT>
|
||||
* 5: Material of the tag <STRING> (Optional)
|
||||
*
|
||||
* Return Value:
|
||||
* Tag created <BOOL>
|
||||
@ -19,7 +20,7 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_tagPosASL", "_vectorDirAndUp", "_texture", "_object", "_unit"];
|
||||
params ["_tagPosASL", "_vectorDirAndUp", "_texture", "_object", "_unit", ["_material","",[""]]];
|
||||
TRACE_5("createTag:",_tagPosASL,_vectorDirAndUp,_texture,_object,_unit);
|
||||
|
||||
if (_texture == "") exitWith {
|
||||
@ -29,9 +30,10 @@ if (_texture == "") exitWith {
|
||||
|
||||
private _tag = createSimpleObject ["UserTexture1m_F", _tagPosASL];
|
||||
_tag setObjectTextureGlobal [0, _texture];
|
||||
if (_material != "") then { _tag setObjectMaterialGlobal [0, _material] };
|
||||
_tag setVectorDirAndUp _vectorDirAndUp;
|
||||
|
||||
// Throw a global event for mision makers
|
||||
// Throw a global event for mission makers
|
||||
["ace_tagCreated", [_tag, _texture, _object, _unit]] call CBA_fnc_globalEvent;
|
||||
|
||||
if (isNull _object) exitWith {true};
|
||||
|
@ -49,5 +49,16 @@ if (GVAR(quickTag) == 3) then {
|
||||
// Tag
|
||||
if !(_possibleTags isEqualTo []) then {
|
||||
private _availableTags = _possibleTags select {(_x select 2) in (_unit call EFUNC(common,uniqueItems))};
|
||||
[_unit, selectRandom ((selectRandom _availableTags) select 3)] call FUNC(tag);
|
||||
(selectRandom _availableTags) params ["", "", "", "_textures", "", "_materials"];
|
||||
|
||||
(
|
||||
if (count _textures == count _materials) then {
|
||||
private _textureIndex = floor random count _textures;
|
||||
[_textures select _textureIndex, _materials select _textureIndex]
|
||||
} else {
|
||||
[selectRandom _textures, selectRandom _materials]
|
||||
}
|
||||
) params ["_randomTexture", "_randomMaterial"];
|
||||
|
||||
[_unit, _randomTexture, _randomMaterial] call FUNC(tag);
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: The colour of the tag (valid colours are black, red, green and blue or full path to custom texture) <STRING>
|
||||
* 2: Material of the tag <STRING> (Optional)
|
||||
*
|
||||
* Return Value:
|
||||
* Sucess <BOOL>
|
||||
@ -18,7 +19,8 @@
|
||||
|
||||
params [
|
||||
["_unit", objNull, [objNull]],
|
||||
["_texture", "", [""]]
|
||||
["_texture", "", [""]],
|
||||
["_material", "", [""]]
|
||||
];
|
||||
|
||||
if (isNull _unit || {_texture == ""}) exitWith {
|
||||
@ -110,6 +112,6 @@ private _vectorDirAndUp = [_surfaceNormal vectorMultiply -1, _v3];
|
||||
|
||||
// Tell the server to create the tag and handle its destruction
|
||||
[QGVAR(createTag), _this] call CBA_fnc_serverEvent;
|
||||
}, [_touchingPoint vectorAdd (_surfaceNormal vectorMultiply 0.06), _vectorDirAndUp, _texture, _object, _unit], 0.6] call CBA_fnc_waitAndExecute;
|
||||
}, [_touchingPoint vectorAdd (_surfaceNormal vectorMultiply 0.06), _vectorDirAndUp, _texture, _object, _unit, _material], 0.6] call CBA_fnc_waitAndExecute;
|
||||
|
||||
true
|
||||
|
Loading…
Reference in New Issue
Block a user