Jump to content
Sign in to follow this  
hogmason

checking if east ai near marker

Recommended Posts

ok so I need to check to see if 1 or more east ai units are near a mkr.

The way I tried is


_town = _this select 0;
_east_units = {alive _x && side _x == EAST} count allUnits;


   if (({(_x distance _town) <200} count _east_units) > 0) then
{



};

but obviously its not working as its returning a number not an object so how can I achieve this

Share this post


Link to post
Share on other sites

I use this it might help ?


private ["_side","_pos","_radius","_units","_unit","_count"];

_side = _this select 0;
_pos = _this select 1;
_radius = _this select 2;
_count = 0;

_units = nearestObjects [_pos, ["Car","Tank","Air","Man"], _radius];

{
_unit = _x;
if(_unit isKindOf "Man" && side _unit == _side) then{
	if(alive _unit) then{_count = _count + 1};
}
else{
	if(canMove _unit && side _unit == _side) then{_count = _count + 1};
};
} foreach _units;

_count

Edited by psvialli

Share this post


Link to post
Share on other sites

thanks mate, I cant believe the iskindof command slipt my mind

---------- Post added at 21:09 ---------- Previous post was at 20:54 ----------

so I went with


_town = _this select 0;
_units = nearestObjects [_town, ["Car","Tank","Air","Man"], 200];
{
//_unit = _x;
if(_x isKindOf "Man" && side _x == east) then
{

if (_x distance _town <200) then
   {
_town setMarkerColor west_near;
};

};

} foreach _units;



but im getting a error 0 elements provide 3 expected pointing to

_units = nearestObjects [_town, ["Car","Tank","Air","Man"], 200];

Share this post


Link to post
Share on other sites

_town = _this select 0; this is a invisible h

done by



town_object = {
               _positions = _this select 0;
               _obj = createVehicle ["HeliHEmpty", _positions, [], 0, "NONE"];
               [_obj ] spawn Town_monitor;

};



{
   _pos = position _x;
   m = createMarker [format ["mrk%1",random 100000],_pos];
   m setMarkerShape "ELLIPSE";
   m setMarkerSize [250,250];
   m setMarkerBrush "Solid";
   m setMarkerAlpha 0.7;
   m setMarkerColor "ColorRed";
[m] spawn town_object;


Town_monitor ---- in wich im stuck


_town = _this select 0;

while {true} do
{
//////////////
_units = nearestObjects [_town, ["Car","Tank","Air","Man"], 200];
{
   if(_x isKindOf "Man" && side _x == east) then
   {

    if (_x distance _town <200) then
       {
        _town setMarkerColor west_near;
    };

   };

} foreach _units;

////////////////

sleep 10
};


Share this post


Link to post
Share on other sites

Did you try to use the helipad for town_monitor? Right now you're using the marker created and not the actual object to check for nearestObjects.

Share this post


Link to post
Share on other sites

It's terribly mixed up - you are not passing it the correct info when spawning the new script;

[m] spawn town_object;

here you are passing a marker reference string and then using it as a poistion?:

_positions = _this select 0; you should replace m with _pos for example?

_town setMarkerColor west_near;

This will not work because _town is an object, m is the marker?

You can't check the distance between something and a marker directly as the distance command doesn't work with markers, possibly why you are using the H - BUT you can use the markers position:

if (_x distance (getMarkerPos "m") < 200) then {};

Share this post


Link to post
Share on other sites

Thread title changed. I'm absolutely sure the 3 more characters to write "marker" instead of "mkr" wouldn't have killed you and people don't have to guess what the heck a mkr is...

Share this post


Link to post
Share on other sites

_town = _this select 0;

if ({ side _x == EAST AND _x distance _town < 200 } count allUnits > 0) then {
 //One or more East units are close to town
};

Although, if _town is a marker reference then you need it's position instead:

_town = _this select 0;
_position = getMarkerPos _town;

Edited by neokika

Share this post


Link to post
Share on other sites

why don't you create a trigger in the script that covers the area you want to check and set its Activation to "East","Present",true/false?

Share this post


Link to post
Share on other sites

I too am looking to check the distance between a unit named DUDE and a marker. Everything works fine until the conditional at which point it throws an error and says that I am missing a '{'. Doesn't look like it to me so something else must be going on. Any thoughts?

private ["_this", "_rWP", "_wps", "_wpPos", "_wpDist"];


_wps = ["wp1", "wp2", "wp3"];

_rWP = _wps call BIS_fnc_selectRandom;

_wps = _wps - [_rWP]; 

_wpDist = DUDE distance getMarkerPos _rWP;

DUDE doMove getMarkerPos _rWP;

hint _rWP;

if(_wpDist <= 0) then {
hint _rWP + " reached!";
};

Share this post


Link to post
Share on other sites

It looks fine here, have a look at the script and scroll right down and make sure a }; hasn't dropped below the visible window.

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  

×