Jump to content
Sign in to follow this  
Freghar

Drawing trigger-like area for a logic unit/module

Recommended Posts

Hello, I'm making a logic unit / editor module which performs some action (disabling street lights, etc.) in a user-configurable radius and would like to visualize the radius in with a trigger-like cylinder / circle on a map.

There are modules which do something similar, ie. ModuleCuratorAddCameraArea_F (Zeus -> Add Camera Area) and they seem to do it using some combination of (undocumented?):

class ModuleCuratorAddCameraArea_F : Module_F {
...
	canSetArea = 1;

	class AttributeValues {
		size3[] = {250, 250, -1};
	};

	class ModuleDescription : ModuleDescription {
		...

		class LocationArea_F {
			description = "";
			duplicate = 1;
			sync[] = {"TriggerArea"};
		};

		class TriggerArea : EmptyDetector {
			position = 1;
			area = 1;
			description = "$STR_A3_CfgVehicles_ModuleCuratorAddCameraArea_F_ModuleDescription_TriggerArea";
		};
	};
};
However even if I managed to get it working using this method and if "size3[]" is indeed the cylinder size, I have no idea how to change it during "runtime" (outside config, in Eden workspace).

I've also looked into triggers, but they are not CfgVehicles (and CfgDetectors defines only one), so I assume the drawing functionality for them is done internally by the engine.

Any ideas how to achieve the visualization?

Thanks!

Share this post


Link to post
Share on other sites

Alright, it seems that "size3[]" is an alias (?) for sizeA, sizeB and (?) sizeC in AttributeValues. It also seems there was "size2[]", from CfgNonAIVehicles:

	class EmptyDetectorAreaR50: EmptyDetector
	{
		displayName = $STR_3DEN_CfgVehicles_EmptyDetectorAreaR50;
		class AttributeValues
		{
			size2[] = {50,50}; //--- Obsolete, remove
			size3[] = {50,50,-1};
		};
	};
Triggers also seem to be defined in the in Cfg3DEN and the visual magic is presumably done via "class Draw" for both 2D and 3D (cfg3DEN_Trigger.hpp). They also use (undocumented) "ShapeTrigger" control which, when used on a custom CfgVehicle object, after adjusting condition, throws:

22:23:33 Error in expression <(_this controlsGroupCtrl 100) lbsetcursel _value;>
22:23:33   Error position: <lbsetcursel _value;>
22:23:33   Error lbsetcursel: Type Bool, expected Number
when the attributes window is opened for that vehicle, probably from some other 3DEN-related code.

As mentioned in first post, it's really just the "canSetArea" setting, which automatically adds the 2D area dimensions to the position attributes (kinda like "EditAB" control). Retrieving this value from an executed function seems a bit tricky, all the BIS functions use essentially

_logicArea = _logic getvariable "objectArea";
but there's no place setting it. Trying "canSetArea" on my custom vehicle, naming it in the editor, and trying getVariable on it ingame returns nil, so it doesn't seem like some automatic variable, even though no game sqf code seems to set it explicitly.

Share this post


Link to post
Share on other sites

Alright, it seems that "size3[]" is an alias (?) for sizeA, sizeB and (?) sizeC in AttributeValues.

That turns out to be incorrect, SizeA / SizeB does nothing to the default area, despite presumably working for triggers. Using "size3[]" works though.

 

Trying "canSetArea" on my custom vehicle, naming it in the editor, and trying getVariable on it ingame returns nil

Not really, just my bad code. There indeed is a magical variable named "objectArea" set by god knows what which seems to have the the same format as triggerArea (scripting command).

So getting this to work with just elipsoids is pretty simple - set "canSetArea" to 1, optionally set defaults in "size3[]" and check in expression for the "objectArea" variable.

class CfgVehicles {
    class Logic;
    class testlogic : Logic {
        scope = 2;
        displayName = "Test Logic";
        canSetArea = 1;
        class AttributeValues {
            size3[] = {12, 34, -1};
        };
    };
};
22:23:33 Error in expression <(_this controlsGroupCtrl 100) lbsetcursel _value;>
22:23:33   Error position: <lbsetcursel _value;>
22:23:33   Error lbsetcursel: Type Bool, expected Number
While the trigger code never needed to specify a default, I apparently had to and with it, this "works" (doesn't throw an error). "ShapeTrigger" is a custom control defined in 3den.pbo, UI/Attributes/ShapeTrigger.hpp, and expects a number, so

class CfgVehicles {
    class Logic;
    class testlogic : Logic {
        scope = 2;
        displayName = "Test Logic";
        canSetArea = 1;
        class AttributeValues {
            size3[] = {12, 34, -1};
            //IsRectangle = 0;
        };
        class Attributes {
            class Shape {
                //data = "IsRectangle";
                property = "IsRectangle";
                control = "ShapeTrigger";
                displayName = "Shape";
                condition = "logicModule";
                tooltip = "something";
                typeName = "NUMBER";
                defaultValue = "0";
            };
        };
    };
};
The weird thing is that some of the BIS code defines "data" where "property" should presumably be, and "value" (instead of defaultValue?), in 3den.pbo, cfg3DEN_Trigger.hpp. If I use "data", the attribute doesn't show up in the UI.

Regardless, this doesn't work - even if I set3DENAttribute ["IsRectangle", true] manually from the debug console, it (get3DENAttribute) still retuns false, so the attribute seems read-only (?). When set in the config (in AttributeValues), it works correctly, but again cannot be overwritten.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×