mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Tagging - Add support for mission Tags (#7710)
* [Tagging] Added ability to specify custom model * Update Tagging Framework doc * [Tagging] Added parsing tags from missionConfig * Update Tagging Framework doc * Apply suggestions from code review Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Forgot passing a variable to WAE Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
553bba8ece
commit
c1b906c29d
@ -5,6 +5,7 @@ PREP(checkTaggable);
|
||||
PREP(compileConfigTags);
|
||||
PREP(createTag);
|
||||
PREP(moduleInit);
|
||||
PREP(parseConfigTag);
|
||||
PREP(quickTag);
|
||||
PREP(tag);
|
||||
PREP(tagTestingThread);
|
||||
|
@ -10,6 +10,7 @@
|
||||
* 3: Textures Paths <ARRAY>
|
||||
* 4: Icon Path <STRING> (default: "")
|
||||
* 5: Material Paths <ARRAY> (optional)
|
||||
* 6: Tag Model <STRING> (optional)
|
||||
*
|
||||
* Return Value:
|
||||
* Sucessfully Added Tag <BOOL>
|
||||
@ -26,7 +27,8 @@ params [
|
||||
["_requiredItem", "", [""]],
|
||||
["_textures", [], [[]]],
|
||||
["_icon", "", [""]],
|
||||
["_materials", [], [[]]]
|
||||
["_materials", [], [[]]],
|
||||
["_tagModel", "UserTexture1m_F", [""]]
|
||||
];
|
||||
|
||||
// Verify
|
||||
@ -52,4 +54,4 @@ if (_textures isEqualTo []) exitWith {
|
||||
_identifier = [_identifier] call CBA_fnc_removeWhitespace;
|
||||
|
||||
// Add
|
||||
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon, _materials]] call CBA_fnc_globalEventJIP;
|
||||
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon, _materials, _tagModel]] call CBA_fnc_globalEventJIP;
|
||||
|
@ -10,6 +10,7 @@
|
||||
* 3: Textures Paths <ARRAY>
|
||||
* 4: Icon Path <STRING> (default: "")
|
||||
* 5: Material Paths <ARRAY>
|
||||
* 6: Tag Model <STRING> (optional)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
|
@ -16,40 +16,25 @@
|
||||
*/
|
||||
|
||||
{
|
||||
private _failure = false;
|
||||
private _class = configName _x;
|
||||
private _result = [_x, false] call FUNC(parseConfigTag);
|
||||
|
||||
private _displayName = getText (_x >> "displayName");
|
||||
if (_displayName == "") then {
|
||||
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing displayName",_class);
|
||||
_failure = true;
|
||||
};
|
||||
if !(_result isEqualTo []) then {
|
||||
_result params ["_tagInfo", "_requiredItem"];
|
||||
|
||||
private _requiredItem = getText (_x >> "requiredItem");
|
||||
if (_requiredItem == "") then {
|
||||
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class);
|
||||
_failure = true;
|
||||
} else {
|
||||
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then {
|
||||
ERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem);
|
||||
_failure = true;
|
||||
} else {
|
||||
_requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // convert to config case
|
||||
};
|
||||
};
|
||||
|
||||
private _textures = getArray (_x >> "textures");
|
||||
if (_textures isEqualTo []) then {
|
||||
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing textures",_class);
|
||||
_failure = true;
|
||||
};
|
||||
|
||||
private _materials = getArray (_x >> "materials");
|
||||
|
||||
private _icon = getText (_x >> "icon");
|
||||
|
||||
if (!_failure) then {
|
||||
GVAR(cachedTags) pushBack [_class, _displayName, _requiredItem, _textures, _icon, _materials];
|
||||
GVAR(cachedTags) pushBack _tagInfo;
|
||||
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
|
||||
};
|
||||
} forEach ("true" configClasses (configFile >> "ACE_Tags"));
|
||||
|
||||
{
|
||||
private _class = configName _x;
|
||||
private _result = [_x, true] call FUNC(parseConfigTag);
|
||||
|
||||
if !(_result isEqualTo []) then {
|
||||
_result params ["_tagInfo", "_requiredItem"];
|
||||
|
||||
GVAR(cachedTags) pushBack _tagInfo;
|
||||
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
|
||||
};
|
||||
} forEach ("true" configClasses (missionConfigFile >> "ACE_Tags"));
|
||||
|
@ -20,7 +20,7 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_tagPosASL", "_vectorDirAndUp", "_texture", "_object", "_unit", ["_material","",[""]]];
|
||||
params ["_tagPosASL", "_vectorDirAndUp", "_texture", "_object", "_unit", ["_material","",[""]], ["_tagModel", "UserTexture1m_F", [""]]];
|
||||
TRACE_5("createTag:",_tagPosASL,_vectorDirAndUp,_texture,_object,_unit);
|
||||
|
||||
if (_texture == "") exitWith {
|
||||
@ -28,7 +28,7 @@ if (_texture == "") exitWith {
|
||||
false
|
||||
};
|
||||
|
||||
private _tag = createSimpleObject ["UserTexture1m_F", _tagPosASL];
|
||||
private _tag = createSimpleObject [_tagModel, _tagPosASL];
|
||||
_tag setObjectTextureGlobal [0, _texture];
|
||||
if (_material != "") then { _tag setObjectMaterialGlobal [0, _material] };
|
||||
_tag setVectorDirAndUp _vectorDirAndUp;
|
||||
|
91
addons/tagging/functions/fnc_parseConfigTag.sqf
Normal file
91
addons/tagging/functions/fnc_parseConfigTag.sqf
Normal file
@ -0,0 +1,91 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Jonpas, Dedmen
|
||||
* Parses tags from ACE_Tags config.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The config class <CONFIG>
|
||||
* 1: Is Mission <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* Tag Information <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [_x, false] call ace_tagging_fnc_parseConfigTag
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#define GET_MOD_OR_MISSION_PATH(thing) \
|
||||
if (thing select [0,1] != "@") then { \
|
||||
getMissionPath thing; \
|
||||
} else { \
|
||||
thing select [1]; \
|
||||
}
|
||||
|
||||
params ["_cfg", ["_isMission", false, [false]]];
|
||||
|
||||
|
||||
private _failure = false;
|
||||
private _class = configName _cfg;
|
||||
|
||||
private _displayName = getText (_cfg >> "displayName");
|
||||
if (_displayName == "") then {
|
||||
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing displayName",_class);
|
||||
_failure = true;
|
||||
};
|
||||
|
||||
private _requiredItem = getText (_cfg >> "requiredItem");
|
||||
if (_requiredItem == "") then {
|
||||
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class);
|
||||
_failure = true;
|
||||
} else {
|
||||
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then {
|
||||
ERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem);
|
||||
_failure = true;
|
||||
} else {
|
||||
_requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // convert to config case
|
||||
};
|
||||
};
|
||||
|
||||
private _textures = getArray (_cfg >> "textures");
|
||||
if (_textures isEqualTo []) then {
|
||||
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing textures",_class);
|
||||
_failure = true;
|
||||
};
|
||||
|
||||
private _materials = getArray (_cfg >> "materials");
|
||||
|
||||
private _icon = getText (_cfg >> "icon");
|
||||
|
||||
private _tagModel = getText (_cfg >> "tagModel");
|
||||
if (_tagModel == "") then {
|
||||
_tagModel = "UserTexture1m_F";
|
||||
};
|
||||
|
||||
// Need to parse mission vs mod path for mission config
|
||||
if (_isMission) then {
|
||||
_materials = _materials apply {
|
||||
GET_MOD_OR_MISSION_PATH(_x);
|
||||
};
|
||||
|
||||
_textures = _textures apply {
|
||||
GET_MOD_OR_MISSION_PATH(_x);
|
||||
};
|
||||
|
||||
// Only if path to model, either has subfolders or atleast a .p3d
|
||||
if ("\" in _tagModel || {"." in _tagModel}) then {
|
||||
_tagModel = GET_MOD_OR_MISSION_PATH(_tagModel);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
if (_failure) then {
|
||||
[]
|
||||
} else {
|
||||
[
|
||||
[_class, _displayName, _requiredItem, _textures, _icon, _materials, _tagModel],
|
||||
_requiredItem
|
||||
]
|
||||
}
|
@ -49,7 +49,7 @@ if (GVAR(quickTag) == 3) then {
|
||||
// Tag
|
||||
if !(_possibleTags isEqualTo []) then {
|
||||
private _availableTags = _possibleTags select {(_x select 2) in (_unit call EFUNC(common,uniqueItems))};
|
||||
(selectRandom _availableTags) params ["", "", "", "_textures", "", "_materials"];
|
||||
(selectRandom _availableTags) params ["", "", "", "_textures", "", "_materials", "_tagModel"];
|
||||
|
||||
(
|
||||
if (count _textures == count _materials) then {
|
||||
@ -60,5 +60,5 @@ if !(_possibleTags isEqualTo []) then {
|
||||
}
|
||||
) params ["_randomTexture", "_randomMaterial"];
|
||||
|
||||
[_unit, _randomTexture, _randomMaterial] call FUNC(tag);
|
||||
[_unit, _randomTexture, _randomMaterial, _tagModel] call FUNC(tag);
|
||||
};
|
||||
|
@ -7,6 +7,7 @@
|
||||
* 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)
|
||||
* 3: Tag Model <STRING> (optional)
|
||||
*
|
||||
* Return Value:
|
||||
* Sucess <BOOL>
|
||||
@ -20,7 +21,8 @@
|
||||
params [
|
||||
["_unit", objNull, [objNull]],
|
||||
["_texture", "", [""]],
|
||||
["_material", "", [""]]
|
||||
["_material", "", [""]],
|
||||
["_tagModel", "UserTexture1m_F", [""]]
|
||||
];
|
||||
|
||||
if (isNull _unit || {_texture == ""}) exitWith {
|
||||
@ -112,6 +114,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, _material], 0.6] call CBA_fnc_waitAndExecute;
|
||||
}, [_touchingPoint vectorAdd (_surfaceNormal vectorMultiply 0.06), _vectorDirAndUp, _texture, _object, _unit, _material, _tagModel], 0.6] call CBA_fnc_waitAndExecute;
|
||||
|
||||
true
|
||||
|
@ -27,7 +27,9 @@ class ACE_Tags {
|
||||
displayName = "My Tag"; // Name of your tag being displayed in the interaction menu
|
||||
requiredItem = "ACE_SpraypaintBlack"; // Required item to have in the inventory to be able to spray your tag (eg. `"ACE_SpraypaintBlack"`, `"ACE_SpraypaintRed"`, `"ACE_SpraypaintGreen"`, `"ACE_SpraypaintBlue"` or any custom item from `CfgWeapons`)
|
||||
textures[] = {"path\to\texture1.paa", "path\to\texture2.paa"}; // List of texture variations (one is randomly selected when tagging)
|
||||
materials[] = {"path\to\material.rvmat"}; // Optional: List of material variations (one is randomly selected). Keep empty if you don't need a custom material.
|
||||
icon = "path\to\icon.paa"; // Icon being displayed in the interaction menu
|
||||
tagModel = "UserTexture1m_F"; // Optional: The 3D Model that will be spawned with the texture on it, can either be CfgVehicles classname or P3D file path.
|
||||
};
|
||||
};
|
||||
```
|
||||
@ -46,6 +48,8 @@ class ACE_Tags {
|
||||
2 | Required Item | String | Required
|
||||
3 | Textures | Array | Required
|
||||
4 | Icon | String | Optional (default: `""` - Default white point)
|
||||
5 | Material Paths | Array | Optional (default: `[]] - No custom material)
|
||||
6 | Tag Model | String | Optional (default: `"UserTexture1m_F"` - 1x1m texture surface)
|
||||
**R** | Successfully Added Tag | Boolean | Return value
|
||||
|
||||
#### 2.1.1 Example
|
||||
@ -59,3 +63,24 @@ class ACE_Tags {
|
||||
2 | `"ACE_SpraypaintRed"` | Required item to have in the inventory to be able to spray your tag
|
||||
3 | `["tagTexture1.paa", "tagTexture2.paa"]` | List of texture variants (one is randomly selected when tagging)
|
||||
4 | `"icon.paa"` | Icon being displayed in the interaction menu
|
||||
|
||||
|
||||
### 2.2 Tags in description.ext
|
||||
|
||||
Tags can also be configured in description.ext like shown above.
|
||||
File Paths will be relative to your mission, if you want to define Tags inside description.ext but use Addon paths for `Texture`/`Material`/`TagModel` you need to prefix the path with `@`.
|
||||
|
||||
This is how above config would look when using Addon paths from description.ext:
|
||||
|
||||
```cpp
|
||||
class ACE_Tags {
|
||||
class yourTagClass {
|
||||
displayName = "My Tag"; // Name of your tag being displayed in the interaction menu
|
||||
requiredItem = "ACE_SpraypaintBlack"; // Required item to have in the inventory to be able to spray your tag (eg. `"ACE_SpraypaintBlack"`, `"ACE_SpraypaintRed"`, `"ACE_SpraypaintGreen"`, `"ACE_SpraypaintBlue"` or any custom item from `CfgWeapons`)
|
||||
textures[] = {"@path\to\texture1.paa", "@path\to\texture2.paa"}; // List of texture variations (one is randomly selected when tagging)
|
||||
materials[] = {"@path\to\material.rvmat"}; // Optional: List of material variations (one is randomly selected). Keep empty if you don't need a custom material.
|
||||
icon = "@path\to\icon.paa"; // Icon being displayed in the interaction menu
|
||||
tagModel = "UserTexture1m_F"; // Optional: The 3D Model that will be spawned with the texture on it, can either be CfgVehicles classname or P3D file path.
|
||||
};
|
||||
};
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user