Jump to content
Sign in to follow this  
BomosBoy

Set addAction for a specific area / Map Marker

Recommended Posts

Is it possible to have an action menu for a specific area? For example if you place a marker or a trigger with a radius etc. I have an industrial complex with a radius of 200m and all players within that area should have an addAction. I tried Markers but they have no init field and i need one because i dont want to change that addaction code in an editor every time. Also i tried trigger but there not working (dont know why).

Share this post


Link to post
Share on other sites

You can totally do that from the addAction condition.

_unit addAction ["Do something", {hint "Did something"}, nil, 0, true, true, "", "alive _target AND _target distance getmarkerpos 'myfactorymarker' <= 200"]

Cheers

Share this post


Link to post
Share on other sites

 addAction condition.

 

Even easier using inArea.  Works for triggers too, without needing any ANYBODY/PRESENT nonsense.

_unit addAction ["Do something", {hint "You did something bad! Shame on you!"}, nil, 0, false, true, "", "(alive _target) AND (_target inArea 'myfactorymarker')"];

Share this post


Link to post
Share on other sites

You can totally do that from the addAction condition.

 

This is not good, considering condition runs every frame all the time

 

 

Even easier using inArea.  

 

Equally as bad if not worse for the same reason.

 

The simplest solution is to have trigger the size of the area attached to the player. When player enters, add action onAct, when player leaves, remove action onDeact.

Share this post


Link to post
Share on other sites

You can totally do that from the addAction condition.

_unit addAction ["Do something", {hint "Did something"}, nil, 0, true, true, "", "alive _target AND _target distance getmarkerpos 'myfactorymarker' <= 200"]

Cheers

And

 

 

Even easier using inArea.  Works for triggers too, without needing any ANYBODY/PRESENT nonsense.

_unit addAction ["Do something", {hint "You did something bad! Shame on you!"}, nil, 0, false, true, "", "(alive _target) AND (_target inArea 'myfactorymarker')"];

is no solution for me because i have multiple different areas. I cant have addAction for every area . Thats too much. The industrial complex is only a example. I have buildings with hostages, landing zones, ... All should have an addAction for a specific area.

The whole thing should run in multiplayer too. So attach triggers for every player is not an option.

 

One more question: why are the addActions from amra 3 vehicles are different then the addAction iam using? If i use addAction i only see it if its in front of me and when iam aiming in that direction. The vehicles instead have an action menu when iam standing close to them. Iam not aiming at them or looking at the direction. Looks like there working with the distance (dont know)

Share this post


Link to post
Share on other sites

is no solution for me because i have multiple different areas. I cant have addAction for every area . Thats too much. The industrial complex is only a example. I have buildings with hostages, landing zones, ... All should have an addAction for a specific area.

 

So check an array of locations?  If you have 50 players all checking 40 zones each frame it'll ruin your day, but if you're making a reasonable mission it shouldn't be bad. or...

 

 

 

The whole thing should run in multiplayer too. So attach triggers for every player is not an option.

 

Why can't you attach triggers to every player? These wouldn't be editor placed triggers, but a few lines of code in a function that creates one for the player.

 

 

 

One more question: why are the addActions from amra 3 vehicles are different then the addAction iam using? If i use addAction i only see it if its in front of me and when iam aiming in that direction. The vehicles instead have an action menu when iam standing close to them. Iam not aiming at them or looking at the direction. Looks like there working with the distance (dont know)

 

The first false there does that.  It's the "showWindow" option.  By default it's true and you see the action on screen in text when you're 15m away from the object, like the vehicles you talked about.  Set to false it doesn't advertise it's existence like that.  The problem is if it's attached to you then you see it always (well, maybe not in a vehicle) and it's super annoying.  If it's on an object though, go ahead and set it to true.

Share this post


Link to post
Share on other sites

The whole thing should run in multiplayer too. So attach triggers for every player is not an option.

 

How is this not an option? Please explain.

Share this post


Link to post
Share on other sites

So check an array of locations?  If you have 50 players all checking 40 zones each frame it'll ruin your day, but if you're making a reasonable mission it shouldn't be bad. or...

 

 

Why can't you attach triggers to every player? These wouldn't be editor placed triggers, but a few lines of code in a function that creates one for the player.

 

 

The first false there does that.  It's the "showWindow" option.  By default it's true and you see the action on screen in text when you're 15m away from the object, like the vehicles you talked about.  Set to false it doesn't advertise it's existence like that.  The problem is if it's attached to you then you see it always (well, maybe not in a vehicle) and it's super annoying.  If it's on an object though, go ahead and set it to true.

 

1. checking so much zones is not even the problem. Like i written before i dont want to change code everytime. I just want to change an init code in the editor (like placing a new addAction to another area) but thats it. It should run by itself.

Thats why i though that you can simply add an action menu to the map markers but that isnt the case :/

2. I have no problem with triggers but like i wrote i dont want (so much) code.

Iam searching for an elegant way to solve this. Not a "hardcoded" style.

 

Is it possible to place an object / structure and set collision to false and invisible? I tried hideObject but that hides all including the addAction.

I only want to place or copy a trigger / structure whatever and change some lines in the initfield and then i should run without adding variables, arrays, ...

Share this post


Link to post
Share on other sites

Put down your objects and/or markers where you want the zones to be.  Add the object or marker names to your bom_zoneArray array.  Enjoy.

bom_zoneArray = [zone1, zone2, zone3, "marker_0", "marker_1"];

bom_fnc_addTriggerZone = {
	params [["_objPos", "", ["", objNull]], ["_area", 5], ["_zonePos", []]];

	if (_objPos isEqualType "") then {
		_zonePos = getMarkerPos _objPos;
		_area = (getMarkerSize _objPos) select 0;
	} else {
		_zonePos = getPos _objPos;
	};

	_trg = createTrigger ["EmptyDetector", _zonePos];
	_trg setTriggerActivation ["VEHICLE", "PRESENT", true];
	_trg setTriggerArea [_area, _area, 0, false, _area];
	_trg triggerAttachVehicle [player];
	_trg setTriggerStatements ["this", "[player, thisTrigger] call bom_fnc_addZoneAction", "[player, thisTrigger, true] call bom_fnc_addZoneAction"]
};

bom_fnc_addZoneAction = {
	params ["_unit", "_trigger", ["_remove", false]];
	_triggerAction = format["bom_%1", (str _trigger + str _unit)];

	if (_remove) exitWith {
		_unit removeAction (_trigger getVariable _triggerAction);
	};
	
	_action = _unit addAction["Zone Action", {hint "I'm doing an action!"}];
	_trigger setVariable [_triggerAction, _action];
};

{
	[_x, 20] call bom_fnc_addTriggerZone;
} forEach bom_zoneArray;

Marker zones area default to the marker x size.  Triggers default to 5, but are set to 20 in this example.

Share this post


Link to post
Share on other sites

is no solution for me because i have multiple different areas. I cant have addAction for every area . Thats too much. The industrial complex is only a example. I have buildings with hostages, landing zones, ... All should have an addAction for a specific area.

The whole thing should run in multiplayer too. So attach triggers for every player is not an option.

 

That's all valuable information to put in the OP.

 

What KK posted is the most efficient solution for MP and multiple areas with multiple players.

 

Cheers

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  

×