Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Materials for tagging #6704

Merged
merged 3 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
18 changes: 14 additions & 4 deletions addons/tagging/functions/fnc_addTagActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,34 @@ 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"];

(
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];
},
{
(_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
13 changes: 12 additions & 1 deletion addons/tagging/functions/fnc_quickTag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 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