Skip to content

Commit

Permalink
Allow custom materials for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dedmen committed Nov 25, 2018
1 parent a89dfcc commit a05c783
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
6 changes: 4 additions & 2 deletions addons/tagging/functions/fnc_addCustomTag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -24,7 +25,8 @@ params [
["_displayName", "", [""]],
["_requiredItem", "", [""]],
["_textures", [], [[]]],
["_icon", "", [""]]
["_icon", "", [""]],
["_materials", [], [[]]]
];

// Verify
Expand All @@ -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;
15 changes: 11 additions & 4 deletions addons/tagging/functions/fnc_addTagActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,31 @@ params ["_unit"];

private _actions = [];
{
_x params ["_class", "_displayName", "_requiredItem", "_textures", "_icon"];
_x params ["_class", "_displayName", "_requiredItem", "_textures", "_icon", "_materials"];

_actions pushBack [
[
format ["ACE_ConfigTag_%1", _class],
_displayName,
_icon,
{
(_this select 2) params ["_unit", "_class", "_textures"];
[_unit, selectRandom _textures] call FUNC(tag);
(_this select 2) params ["_unit", "_class", "_textures", "", "_materials"];
private _randomTexture = selectRandom _textures;
private _randomMaterial = if (count _textures == count _materials) then {
_materials select (_textures find _randomTexture)
} else {
selectRandom _materials
};

[_unit, _randomTexture, _randomMaterial] call FUNC(tag);
_unit setVariable [QGVAR(lastUsedTag), _class];
},
{
(_this select 2) params ["_unit", "", "", "_requiredItem"];
_requiredItem in (_unit call EFUNC(common,uniqueItems))
},
{},
[_unit, _class, _textures, _requiredItem]
[_unit, _class, _textures, _requiredItem, _materials]
] call EFUNC(interact_menu,createAction),
[],
_unit
Expand Down
1 change: 1 addition & 0 deletions addons/tagging/functions/fnc_applyCustomTag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* 2: Required Item <STRING>
* 3: Textures Paths <ARRAY>
* 4: Icon Path <STRING> (default: "")
* 5: Material Paths <ARRAY>
*
* Return Value:
* None
Expand Down
4 changes: 3 additions & 1 deletion addons/tagging/functions/fnc_compileConfigTags.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
6 changes: 4 additions & 2 deletions addons/tagging/functions/fnc_createTag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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 {
Expand All @@ -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};
Expand Down
6 changes: 4 additions & 2 deletions addons/tagging/functions/fnc_tag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -18,7 +19,8 @@

params [
["_unit", objNull, [objNull]],
["_texture", "", [""]]
["_texture", "", [""]],
["_material", "", [""]]
];

if (isNull _unit || {_texture == ""}) exitWith {
Expand Down Expand Up @@ -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

0 comments on commit a05c783

Please sign in to comment.