Merge pull request #3631 from acemod/customTaggingTextureSupport

Add support for custom textures in tagging
This commit is contained in:
jonpas 2016-04-17 11:28:14 +00:00
commit 10cadb535f
10 changed files with 95 additions and 167 deletions

View File

@ -3,58 +3,32 @@ class CfgVehicles {
class CAManBase: Man {
class ACE_SelfActions {
class ACE_Equipment {
class ACE_tagWallBlack {
displayName = CSTRING(tagWallBlack);
class ACE_TagBlack {
displayName = CSTRING(TagBlack);
condition = QUOTE(('ACE_SpraypaintBlack' in items ACE_player) && {[] call FUNC(checkTaggable)});
statement = QUOTE([ARR_2(ACE_player,'black')] call FUNC(tagWall));
statement = QUOTE([ARR_2(ACE_player,'black' call FUNC(getTexture))] call FUNC(tag));
showDisabled = 0;
priority = 3;
icon = QUOTE(PATHTOF(UI\icons\iconTaggingBlack.paa));
};
class ACE_tagWallRed: ACE_tagWallBlack {
displayName = CSTRING(tagWallRed);
class ACE_TagRed: ACE_TagBlack {
displayName = CSTRING(TagRed);
condition = QUOTE(('ACE_SpraypaintRed' in items ACE_player) && {[] call FUNC(checkTaggable)});
statement = QUOTE([ARR_2(ACE_player,'red')] call FUNC(tagWall));
statement = QUOTE([ARR_2(ACE_player,'red' call FUNC(getTexture))] call FUNC(tag));
icon = QUOTE(PATHTOF(UI\icons\iconTaggingRed.paa));
};
class ACE_tagWallGreen: ACE_tagWallBlack {
displayName = CSTRING(tagWallGreen);
class ACE_TagGreen: ACE_TagBlack {
displayName = CSTRING(TagGreen);
condition = QUOTE(('ACE_SpraypaintGreen' in items ACE_player) && {[] call FUNC(checkTaggable)});
statement = QUOTE([ARR_2(ACE_player,'green')] call FUNC(tagWall));
statement = QUOTE([ARR_2(ACE_player,'green' call FUNC(getTexture))] call FUNC(tag));
icon = QUOTE(PATHTOF(UI\icons\iconTaggingGreen.paa));
};
class ACE_tagWallBlue: ACE_tagWallBlack {
displayName = CSTRING(tagWallBlue);
class ACE_TagBlue: ACE_TagBlack {
displayName = CSTRING(TagBlue);
condition = QUOTE(('ACE_SpraypaintBlue' in items ACE_player) && {[] call FUNC(checkTaggable)});
statement = QUOTE([ARR_2(ACE_player,'blue')] call FUNC(tagWall));
statement = QUOTE([ARR_2(ACE_player,'blue' call FUNC(getTexture))] call FUNC(tag));
icon = QUOTE(PATHTOF(UI\icons\iconTaggingBlue.paa));
};
/*class ACE_tagGroundBlack {
displayName = CSTRING(tagGroundBlack);
condition = QUOTE('ACE_SpraypaintBlack' in items ACE_player);
statement = QUOTE([ARR_2(ACE_player, 'black')] call FUNC(tagGround));
showDisabled = 0;
priority = 3;
icon = QUOTE(PATHTOF(UI\icons\iconTaggingBlack.paa));
};
class ACE_tagGroundRed: ACE_tagGroundBlack {
displayName = CSTRING(tagGroundRed);
condition = QUOTE('ACE_SpraypaintRed' in items ACE_player);
statement = QUOTE([ARR_2(ACE_player, 'red')] call FUNC(tagGround));
icon = QUOTE(PATHTOF(UI\icons\iconTaggingRed.paa));
};
class ACE_tagGroundGreen: ACE_tagGroundBlack {
displayName = CSTRING(tagGroundGreen);
condition = QUOTE('ACE_SpraypaintGreen' in items ACE_player);
statement = QUOTE([ARR_2(ACE_player, 'green')] call FUNC(tagGround));
icon = QUOTE(PATHTOF(UI\icons\iconTaggingGreen.paa));
};
class ACE_tagGroundBlue: ACE_tagGroundBlack {
displayName = CSTRING(tagGroundBlue);
condition = QUOTE('ACE_SpraypaintBlue' in items ACE_player);
statement = QUOTE([ARR_2(ACE_player, 'blue')] call FUNC(tagGround));
icon = QUOTE(PATHTOF(UI\icons\iconTaggingBlue.paa));
};*/
};
};
};
@ -64,26 +38,26 @@ class CfgVehicles {
author = "jokoho48";
scope = 2;
scopeCurator = 2;
displayName = CSTRING(spraypaintBlack);
displayName = CSTRING(SpraypaintBlack);
vehicleClass = "Items";
class TransportItems {
MACRO_ADDITEM(ACE_SpraypaintBlack,1);
};
};
class ACE_Item_SpraypaintRed: ACE_Item_SpraypaintBlack {
displayName = CSTRING(spraypaintRed);
displayName = CSTRING(SpraypaintRed);
class TransportItems {
MACRO_ADDITEM(ACE_SpraypaintRed,1);
};
};
class ACE_Item_SpraypaintGreen: ACE_Item_SpraypaintBlack {
displayName = CSTRING(spraypaintGreen);
displayName = CSTRING(SpraypaintGreen);
class TransportItems {
MACRO_ADDITEM(ACE_SpraypaintGreen,1);
};
};
class ACE_Item_SpraypaintBlue: ACE_Item_SpraypaintBlack {
displayName = CSTRING(spraypaintBlue);
displayName = CSTRING(SpraypaintBlue);
class TransportItems {
MACRO_ADDITEM(ACE_SpraypaintBlue,1);
};
@ -98,4 +72,4 @@ class CfgVehicles {
MACRO_ADDITEM(ACE_SpraypaintGreen,5);
};
};
};
};

View File

@ -1,7 +1,5 @@
PREP(checkTaggable);
PREP(createTag);
PREP(tagDirection);
PREP(tagGround);
PREP(tagWall);
PREP(getTexture);
PREP(tag);
PREP(tagTestingThread);

View File

@ -1,5 +1,5 @@
/*
* Author: BaerMitUmlaut and esteldunedain
* Author: BaerMitUmlaut, esteldunedain
* Checks if there is a taggable surface within 2.5m in front of the player.
*
* Arguments:

View File

@ -1,41 +1,42 @@
/*
* Author: BaerMitUmlaut and esteldunedain
* Author: BaerMitUmlaut, esteldunedain
* Creates a tag and handle its destruction. Only execute on the server.
*
* Arguments:
* 0: Position ASL <ARRAY>
* 1: Vector dir and up <ARRAY>
* 2: Colour of the tag (valid colours are black, red, green and blue) <STRING>
* 3: Object it should be tied too <OBJECT>
* 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>
*
* Return Value:
* None
* Tag created <BOOL>
*
* Example:
* [positionASL, vectorDirAndUp, "black", object] call ace_tagging_fnc_createTag
* [positionASL, vectorDirAndUp, "z\ace\addons\tagging\UI\tags\black\0.paa", object] call ace_tagging_fnc_createTag
*
* Public: No
*/
#include "script_component.hpp"
params ["_tagPosASL", "_vectorDirAndUp", "_color", "_object", "_unit"];
TRACE_5("createTag:", _tagPosASL, _vectorDirAndUp, _color, _object, _unit);
params ["_tagPosASL", "_vectorDirAndUp", "_texture", "_object", "_unit"];
TRACE_5("createTag:",_tagPosASL,_vectorDirAndUp,_texture,_object,_unit);
if !((toLower _color) in ["black", "red", "green", "blue"]) exitWith {
ACE_LOGERROR_1("%1 is not a valid tag color.", _color);
if (_texture == "") exitWith {
ACE_LOGERROR_1("%1 is not a valid tag texture.",_texture);
false
};
private _tag = "UserTexture1m_F" createVehicle [0,0,0];
_tag setObjectTextureGlobal [0, '\z\ace\addons\tagging\UI\tags\' + _color + '\' + str (floor (random 3)) + '.paa'];
_tag setObjectTextureGlobal [0, _texture];
_tag setPosASL _tagPosASL;
_tag setVectorDirAndUp _vectorDirAndUp;
// Throw a global event for mision makers
["tagCreated", [_tag, _color, _object, _unit]] call EFUNC(common,globalEvent);
["tagCreated", [_tag, _texture, _object, _unit]] call EFUNC(common,globalEvent);
if (isNull _object) exitWith {};
if (isNull _object) exitWith {true};
// If the tag is applied to an object, handle its destruction
_object setVariable [QGVAR(testVar), true];
@ -73,3 +74,5 @@ GVAR(tagsToTest) pushBack [_tag, _tagPosASL, _vectorDirAndUp];
if (!GVAR(testingThread)) then {
call FUNC(tagTestingThread);
};
true

View File

@ -0,0 +1,26 @@
/*
* Author: BaerMitUmlaut, esteldunedain, Jonpas
* Puts together a full path to the given tag color texture. Internal ACE3 textures only.
*
* Arguments:
* 0: The colour of the tag (valid colours are black, red, green and blue) <STRING>
*
* Return Value:
* Texture (full path), "" if not found <STRING>
*
* Example:
* texture = ["blue"] call ace_tagging_fnc_getTexture
*
* Public: No
*/
#include "script_component.hpp"
params ["_color"];
if !((toLower _color) in ["black", "red", "green", "blue"]) exitWith {
ACE_LOGERROR_1("%1 is not a valid tag colour.",_color);
""
};
QUOTE(PATHTOF(UI)) + "\tags\" + _color + "\" + str (floor (random 3)) + ".paa"

View File

@ -1,25 +1,35 @@
/*
* Author: BaerMitUmlaut and esteldunedain
* If possible, create a tag on the first surface between Start and End positions
* Author: BaerMitUmlaut, esteldunedain
* Creates a tag on a wall that is on the closest surface within 2m on front of the unit.
*
* Arguments:
* 0: Unit
* 1: Start position ASL <ARRAY>
* 2: End position ASL <ARRAY>
* 3: The colour of the tag (valid colours are black, red, green and blue) <STRING>
* 0: Unit <OBJECT>
* 1: The colour of the tag (valid colours are black, red, green and blue or full path to custom texture) <STRING>
*
* Return Value:
* Sucess <BOOLEAN>
* Sucess <BOOL>
*
* Example:
* [startPosASL, directiom "blue"] call ace_tagging_fnc_tagDirection
* success = [player, "z\ace\addons\tagging\UI\tags\black\0.paa"] call ace_tagging_fnc_tag
*
* Public: No
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit", "_startPosASL", "_endPosASL", "_color"];
params [
["_unit", objNull, [objNull]],
["_texture", "", [""]]
];
if (isNull _unit || {_texture == ""}) exitWith {
ACE_LOGERROR_2("Tag parameters invalid. Unit: %1, Texture: %2",_unit,_texture);
};
private _startPosASL = eyePos _unit;
private _cameraPosASL = AGLToASL positionCameraToWorld [0, 0, 0];
private _cameraDir = (AGLToASL positionCameraToWorld [0, 0, 1]) vectorDiff _cameraPosASL;
private _endPosASL = _startPosASL vectorAdd (_cameraDir vectorMultiply 2.5);
// Check for intersections below the unit
private _intersections = lineIntersectsSurfaces [_startPosASL, _endPosASL, _unit, objNull, true, 1, "GEOM", "FIRE"];
@ -79,8 +89,6 @@ _fnc_isOk = {
true
};
#define TAG_SIZE 0.6
if ( !([ 0.5*TAG_SIZE, 0.5*TAG_SIZE] call _fnc_isOk) ||
{!([ 0.5*TAG_SIZE,-0.5*TAG_SIZE] call _fnc_isOk) ||
{!([-0.5*TAG_SIZE, 0.5*TAG_SIZE] call _fnc_isOk) ||
@ -102,6 +110,6 @@ _unit playActionNow "PutDown";
// Tell the server to create the tag and handle its destruction
["createTag", _this] call EFUNC(common,serverEvent);
}, [_touchingPoint vectorAdd (_surfaceNormal vectorMultiply 0.06), _vectorDirAndUp, _color, _object, _unit], 0.6] call EFUNC(common,waitAndExecute);
}, [_touchingPoint vectorAdd (_surfaceNormal vectorMultiply 0.06), _vectorDirAndUp, _texture, _object, _unit], 0.6] call EFUNC(common,waitAndExecute);
true

View File

@ -1,25 +0,0 @@
/*
* Author: BaerMitUmlaut and esteldunedain
* Creates a tag on the ground beneath the unit
*
* Arguments:
* 0: Unit <OBJECT>
* 1: The colour of the tag (valid colours are black, red, green and blue) <STRING>
*
* Return Value:
* None
*
* Example:
* [player, "blue"] call ace_tagging_fnc_tagGround
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_color"];
private _startPosASL = getPosASL _unit;
private _endPosASL = _startPosASL vectorAdd [0, 0, -2] vectorAdd eyeDirection _unit;
[_unit, _startPosASL, _endPosASL, _color] call FUNC(tagDirection);

View File

@ -1,27 +0,0 @@
/*
* Author: BaerMitUmlaut and esteldunedain
* Creates a tag on a wall that is on the closest surface within 2m on front of the unit.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: The colour of the tag (valid colours are black, red, green and blue) <STRING>
*
* Return Value:
* None
*
* Example:
* [player, "blue"] call ace_tagging_fnc_tagWall
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_color"];
private _startPosASL = eyePos _unit;
private _cameraPosASL = AGLToASL positionCameraToWorld [0, 0, 0];
private _cameraDir = (AGLToASL positionCameraToWorld [0, 0, 1]) vectorDiff _cameraPosASL;
private _endPosASL = _startPosASL vectorAdd (_cameraDir vectorMultiply 2.5);
[_unit, _startPosASL, _endPosASL, _color] call FUNC(tagDirection);

View File

@ -15,3 +15,6 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define TAG_SIZE 0.6

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Tagging">
<Key ID="STR_ACE_tagging_tagWallBlack">
<Key ID="STR_ACE_Tagging_TagBlack">
<English>Tag black</English>
<German>Schwarz markieren</German>
<Spanish>Marcar en negro</Spanish>
@ -9,7 +9,7 @@
<French>Tag noir</French>
<Italian>Marca nero</Italian>
</Key>
<Key ID="STR_ACE_tagging_tagWallRed">
<Key ID="STR_ACE_Tagging_TagRed">
<English>Tag red</English>
<German>Rot markieren</German>
<Spanish>Marcar en rojo</Spanish>
@ -17,7 +17,7 @@
<French>Tag rouge</French>
<Italian>Marca rosso</Italian>
</Key>
<Key ID="STR_ACE_tagging_tagWallGreen">
<Key ID="STR_ACE_Tagging_TagGreen">
<English>Tag green</English>
<German>Grün markieren</German>
<Spanish>Marcar en verde</Spanish>
@ -25,7 +25,7 @@
<French>Tag vert</French>
<Italian>Marca verde</Italian>
</Key>
<Key ID="STR_ACE_tagging_tagWallBLue">
<Key ID="STR_ACE_Tagging_TagBlue">
<English>Tag blue</English>
<German>Blau markieren</German>
<Spanish>Marcar en azul</Spanish>
@ -33,39 +33,7 @@
<French>Tag bleu</French>
<Italian>Marca blu</Italian>
</Key>
<Key ID="STR_ACE_tagging_tagGroundBlack">
<English>Tag ground black</English>
<German>Boden schwarz markieren</German>
<Polish>Oznakuj ziemię na czarno</Polish>
<Spanish>Marcar suelo en negro</Spanish>
<French>Tag fond noir</French>
<Italian>Segna nero a terra</Italian>
</Key>
<Key ID="STR_ACE_tagging_tagGroundRed">
<English>Tag ground red</English>
<German>Boden rot markieren</German>
<Polish>Oznakuj ziemię na czerwono</Polish>
<Spanish>Marcar suelo en rojo</Spanish>
<French>Tag fond rouge</French>
<Italian>Segna rosso a terra</Italian>
</Key>
<Key ID="STR_ACE_tagging_tagGroundGreen">
<English>Tag ground green</English>
<German>Boden grün markieren</German>
<Polish>Oznakuj ziemię na zielono</Polish>
<Spanish>Marcar suelo en verde</Spanish>
<French>Tag fond vert</French>
<Italian>Segna verde a terra</Italian>
</Key>
<Key ID="STR_ACE_tagging_tagGroundBlue">
<English>Tag ground blue</English>
<German>Boden blau markieren</German>
<Polish>Oznakuj ziemię na niebiesko</Polish>
<Spanish>Marcar suelo en azul</Spanish>
<French>Tag font bleu</French>
<Italian>Segna blu a terra</Italian>
</Key>
<Key ID="STR_ACE_tagging_spraypaintBlack">
<Key ID="STR_ACE_Tagging_SpraypaintBlack">
<English>Black spray paint</English>
<German>Schwarze Sprühfarbe</German>
<Spanish>Pintura negra</Spanish>
@ -73,7 +41,7 @@
<French>Peinture pulvérisée noire</French>
<Italian>Bomboletta spray nera</Italian>
</Key>
<Key ID="STR_ACE_tagging_spraypaintRed">
<Key ID="STR_ACE_Tagging_SpraypaintRed">
<English>Red spray paint</English>
<German>Rote Sprühfarbe</German>
<Spanish>Pintura roja</Spanish>
@ -81,7 +49,7 @@
<French>Peinture pulvérisée rouge</French>
<Italian>Bomboletta spray rossa</Italian>
</Key>
<Key ID="STR_ACE_tagging_spraypaintGreen">
<Key ID="STR_ACE_Tagging_SpraypaintGreen">
<English>Green spray paint</English>
<German>Grüne Sprühfarbe</German>
<Spanish>Pintura verde</Spanish>
@ -89,7 +57,7 @@
<French>Peinture pulvérisée verte</French>
<Italian>Bomboletta spray verde</Italian>
</Key>
<Key ID="STR_ACE_tagging_spraypaintBlue">
<Key ID="STR_ACE_Tagging_SpraypaintBlue">
<English>Blue spray paint</English>
<German>Blaue Sprühfarbe</German>
<Spanish>Pintura azul</Spanish>
@ -97,7 +65,7 @@
<French>Peinture pulvérisée bleue</French>
<Italian>Bomboletta spray blu</Italian>
</Key>
<Key ID="STR_ACE_tagging_descSpraypaint">
<Key ID="STR_ACE_Tagging_descSpraypaint">
<English>A can of spray paint for tagging walls.</English>
<German>Eine Farbsprühdose um Wände zu markieren.</German>
<Spanish>Lata de pintura en aerosol para marcar.</Spanish>
@ -106,4 +74,4 @@
<Italian>Una bomboletta di spay per contrassegnare i muri.</Italian>
</Key>
</Package>
</Project>
</Project>