Jump to content
Sign in to follow this  
eegore

Distance parameter and Arrays

Recommended Posts

I have multiple triggers in a mission that tell units to go to a Game Logic once the player is within 3 meters.

player distance goat1 < 3

goat 1 doMove getPosATL barn

I can't figure out if there's a way to put the goats all in one trigger.

player distance [goat1,goat2,goat3] < 3

This wont work, but before I kill hours trying different ways I was wondering if anyone knew of a way to keep me from having 30 triggers if I had 30 goats. Maybe creating the goat array and naming it somehow?

Thanks

Share this post


Link to post
Share on other sites

What about this:

{

if (player distance _x < 3) then {

_x doMove getPosATL barn;

};

} forEach [goat1, goat2, goat3...];

It has to be a script file, but its much more efficient.

Share this post


Link to post
Share on other sites

It seems more efficient. I am spawning these goats by script so should I just run this via trigger one second after the goats spawn in?

Share this post


Link to post
Share on other sites

You can have it in the same script. Just change the if syntax to waituntil, im writing from my phone so it takes too long...

Share this post


Link to post
Share on other sites

Should it be:

{

waituntil (player distance _x < 3) then {

_x doMove getPosATL barn;

};

} forEach [goat1, goat2, goat3];

I underlined the change.

---------- Post added at 02:46 AM ---------- Previous post was at 02:44 AM ----------

Should it be:

{

waituntil (player distance _x < 3) then {

_x doMove getPosATL barn;

};

} forEach [goat1, goat2, goat3];

I underlined the change.

---------- Post added at 03:11 AM ---------- Previous post was at 02:46 AM ----------

I added the code to the bottom of my spawn script but the goats don't move.

//spawn a goat that uses UPS
//_spawnPos = getMarkerPos "goatpatrol";
//goat0 = createGroup Civilian;
//"Goat" createUnit [(_spawnPos), goat0, "nul = [this, 'goatpatrol','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];
// NOTE: Learn how to hide "goatpatrol" marker

// spawnpos is my marker
_spawnPos = getMarkerPos "goat1";
// the animal belong to which side ""WEST", "EAST", "GUER", "CIV""
_group = createGroup Civilian;
// spawn the animal at my pos
Goat1= _group createUnit ["Goat01_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
// hide the created marker "u can use this line in ur init.sqf too
"goat1" setMarkerAlpha 0;

//Repeat of commands without notation
_spawnPos = getMarkerPos "goat2";
_group = createGroup Civilian;
Goat2= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
"goat2" setMarkerAlpha 0;

_spawnPos = getMarkerPos "goat3";
_group = createGroup Civilian;
Goat3= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
"goat3" setMarkerAlpha 0;

//goats move to barn when player within 3m
{
waituntil (player distance _x < 3) then {
_x doMove getPosATL barn;
};
} forEach [goat1, goat2, goat3];

Share this post


Link to post
Share on other sites
while {true} do {
{if(alive _x) then {
	if (player distance _x < 3)
	then {
		_x doMove getPosATL barn;
		}
		}
		} forEach [goat1, goat2, goat3];
sleep 0.5;
};

Share this post


Link to post
Share on other sites

This works well, I added Persion MO's code to the bottom and all the goats go to the barn. The only weird thing is they all stack up so after 6 or so goats they look like one super goat standing at the barn.

Is it possible to add multiple locations so goat 1 and 2 go to "Barn" and other goats go to "Barn2" or "Truck" ?

I tried repeating the above code with name changes but nothing happened. By this logic could I put cows, sheep and goats all in one script and direct them to different Game Logics or units on the map?

Share this post


Link to post
Share on other sites
s it possible to add multiple locations so goat 1 and 2 go to "Barn" and other goats go to "Barn2" or "Truck" ?

There should be a better way but temporary it handle this.

add 2 H_empty in map and name it, barn, barn1

while {true} do {
{if(alive _x) then {
	if (player distance _x < 3)
	then {
		_x doMove getPosATL barn;
		}
		}
		} forEach [goat1, goat2];

	{if(alive _x) then {
	if (player distance _x < 3)
	then {
		_x doMove getPosATL barn1;
		}
		}
		} forEach [goat3, goat4];
sleep 0.5;
};

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  

×