Jump to content
kibaBG

Detect player around marker

Recommended Posts

Hi, I try to make a script which will use markers to detect player and spawn enemies (not sure this is possible?). The goal is to evade placing 70 triggers on the map.
I tried with this
 

if (player inArea [[(getMarkerPos "mrk1")]250,250,45,false]) then {hint "Tralala";};

But it gives me error "Array expected Boolean". But where is the error? Thanks for any help. 

Share this post


Link to post
Share on other sites

You are missing a comma after your position array and the array needs two or three elements:

if (player inArea [[(getMarkerPos "mrk1" select 0), (getMarkerPos "mrk1" select 1)], 250, 250, 45, false]) then  
{ 
 hint "Tralala"; 
};

or simply:

if (player inArea "mrk1") then 
{
	hint "Tralala";
};

since there is no reason to define an area that is already defined by the marker itself.

  • Like 1

Share this post


Link to post
Share on other sites

If you place 70 triggers, why do you need markers? And how/when are you checking your condition?

  • Like 1

Share this post


Link to post
Share on other sites
Just now, pierremgi said:

If you place 70 triggers, why do you need markers? And how/when are you checking your condition?

 

He's trying to (avoid) placing triggers.

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, Harzach said:

 

He's trying to (avoid) placing triggers.

Ah, not an evasion but an avoidance. 🙂

But triggers are fine for detecting a presence in areas (repeatedly checking condition). Markers aren't.

  • Like 1

Share this post


Link to post
Share on other sites

@pierremgi Yes, I am trying to avoid/evade (🤣) triggers because I try to make sandbox scenario with a lot of areas to capture and 70+ triggers may hit the performance.
@Harzach I tested your code to spawn a group of enemies but nothing spawned ...
 

if (player inArea [[(getMarkerPos "mrk54a" select 0), (getMarkerPos "mrk54a" select 1)], 250, 250, 45, false]) then  
{ 
_pos = [(getMarkerPos "mrk54a"), 1, 250, 3, 0, 0.5, 0] call BIS_fnc_findSafePos; 
private _group = createGroup [east, true];
_group = [_pos, east,[    
"LOP_TKA_Infantry_TL",    
"LOP_TKA_Infantry_AT",    
"LOP_TKA_Infantry_Rifleman_3",    
"LOP_TKA_Infantry_MG",    
"LOP_TKA_Infantry_GL",    
"LOP_TKA_Infantry_AT",    
"LOP_TKA_Infantry_AA",
"LOP_TKA_Infantry_MG",
"LOP_TKA_Infantry_Marksman"     
]] call BIS_fnc_spawnGroup;        
_group setCombatMode "RED";    
_group setSpeedMode "FULL";   
_group setFormation "LINE";   
_group deleteGroupWhenEmpty true;    
 {   
 _x setSkill ["general",1];   
 _x setSkill ["courage",1];    
 _x setSkill ["aimingAccuracy", 0.30];    
 _x setSkill ["aimingShake", 0.50];    
 _x setSkill ["aimingSpeed", 0.50];    
 _x setSkill ["reloadSpeed", 0.50];    
} forEach (units _huntGroup); 
[_group,(getMarkerPos),20] call BIS_fnc_taskPatrol; 
};

its initialized by []execVM "patrol.sqf";  from initServer.sqf

Share this post


Link to post
Share on other sites

You can't spawn something with a simple condition like:  if then code because you didn't create a loop. You have to check this condition regularly, perhaps every 2 seconds, more or less.

The reason why triggers are much more performant for that. I'm using my own module (advanced patrol) for placing triggers and spawning patrols inside their areas. I can have 50+ areas, the fact is you can set the trigger interval. You can also, recommended, use the dynamic simulation in attributes performance menu of the editor.

If you start to script for MP session, there will be extra difficulties (for example: player doesn't exist on dedicated, so your code is wrong, this way also).

 

  • Like 1

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

×