Jump to content
Sign in to follow this  
snowmirage

All remaining enemy Chase player/team

Recommended Posts

I have a mission in which one objective is to take out an enemy general. It all works fine.

What I would like to do in order to give some more challenge and thrill to the end of the mission is to build a trigger or such so that when the general dies (aka Objective 3 is completed) ALL remaining enemy units (the generals team) will know the location of the player (its a MP mission so I suppose know the location of the player team leader) and will move to that location and attack.

When Objective 3 is completed I set chaseplayer=true;

then I have a trigger that states

condition: chaseplayer

activation: while{true} do { (allGroups) domove (getPos tank1); sleep5 }

for the moment I just played a Bluefor tank (named tank1) near by to see if the enemy in the area would respond but they dont seem to.

Anyone have any ideas on how to make this work?

I would greatly appreciate it, searched around the forums to get this far but cant seem to get it.

Thanks

-Snow

Share this post


Link to post
Share on other sites

These posts here should get you started.

If you're here 'till the end of the war.... you will have to learn how to modify code to suit your own needs at some point. You might as well start that learning process now.

http://forums.bistudio.com/showthread.php?t=119376

http://forums.bistudio.com/showthread.php?t=112731

Familiarise yourself with these.... Scripting Commands

Edited by twirly
Added link

Share this post


Link to post
Share on other sites

Thanks for the response and I have been looking at the exact links you supplied already from searching around.

I believe I understand how to get a particular enemy to chase the player. Though I need to go and test it still hopefully this weekend.

I am looking for some way of selecting multiple groups of enemies, or all remaining enemies.

The idea is your team just took out the enemy general and now they are on to you. Any enemy in the area are altered by radio of your position and given orders to take you out at all costs.

I am building this mission on what I already have. And short of naming each individual group of enemy units (there are 30 or 40) I thought there might be some way to select them all.

Share this post


Link to post
Share on other sites

Well... the main thing is doMove works with units..... not groups.

This is why you need to look up the commands and not just guess mate!

See how you go and post again.

Edited by twirly

Share this post


Link to post
Share on other sites

I think I know how to get this to work from some testing but it just seems like there must be an easier way to do it

while{true} do {

enemyunit1 domove (position playername);

enemyunit2 domove (position playername);

enemyunit3 domove (position playername);

// repeated for each and every enemy unit

sleep5;

}

I would have thought there might be a way to select all units in an area of a particular faction or side.

Maybe I can some how name each of the groups. Then use "leader groupname" to get the current leader of a group and have him move the rest of the group should follow I think? If I just use the starting leaders of each group they could be dead by the time this triggers.

Well back to searching.

---------- Post added at 06:22 PM ---------- Previous post was at 06:12 PM ----------

I created a group o f 5 soilders in the leaders init box added

enemygroup = group this; // From what I have read this names that group

then changed my trigger to

while{true} do {

(leader enemygroup) domove (position playername);

sleep5;

}

it works.... the leader of the group moves where he should. but for some reason his group will not follow. and the search continues

---------- Post added at 06:33 PM ---------- Previous post was at 06:22 PM ----------

Think I might be on to something

the units command seems to be what I am looking for

I'm now trying this

array = units enemygroup;

{_x domove (position playername)} foreach array;

Its getting there

---------- Post added at 06:42 PM ---------- Previous post was at 06:33 PM ----------

I think I can do this using the above and the allGroups function. But I would need a way to determine what side a unit is on, i'll see if I can find that.

pseudo code

while{true} do {

{

arrayofunitsingroup = units _x;

{

if (_y is Enemy) {

_y domove (position playername)

}

} forEach arrayofunitsingroup;

} forEach allGroups;

}

something like that back to the endless search

---------- Post added at 06:49 PM ---------- Previous post was at 06:42 PM ----------

while{true} do {

{

arrayofunitsingroup = units _x;

{

if (side _y == west) then { _y domove (position tank1);};

} forEach arrayofunitsingroup;

} forEach allGroups;

}

think I am on the right track....

FYI...... forgetting the sleep command in an endless loop = BAD...... ;o)

---------- Post added at 06:57 PM ---------- Previous post was at 06:49 PM ----------

Well I think I was on the right track but something is not working as it should.

Any ideas?

What I am currently trying


while{true} do {
{
	arrayofunitsingroup = units _x;
	{ 
		if (side _y == west) then { _y domove (position tank1);};	
	} forEach arrayofunitsingroup;
} forEach allGroups;
sleep 5;
}

I think my issue is with the allGroups command I havent been able to find many examples of it yet

Share this post


Link to post
Share on other sites

while{true} do {

(leader enemygroup) domove (position playername);

sleep5;

}

it works.... the leader of the group moves where he should. but for some reason his group will not follow. and the search continues

Actually you were very close try move not domove

All you need then is to move just the current group leaders.

Share this post


Link to post
Share on other sites

ypu were missing a ; after last }, and you were using _y inside a foreach loop, wich afaik only responds to _x, and i tweaked code alittle so it would simply pass on those groups not of the desired side.

while {true} do {
{
	_grp = _x;
	if (([b]side _grp[/b]) == west) then {
		{
			[b]_x[/b] domove (getPos tank1);
		} forEach units _grp;
	};
} forEach allGroups;
sleep 5;
}[b];[/b]

also i would have tried doTarget, but that would probably only work for units with AT weapons if its a tank, then unit would auto update his doMove to the last known position, and using reveal would also help in this case.

Edited by Demonized
_grp = _x; was in wrong scope, corrected now.

Share this post


Link to post
Share on other sites

Thanks for the help I think I am almost there.

while{true} do {  
{    
	_grp = _x;
	if ((side _grp) == east) then {

		(leader _grp) move (position tank1);
	}
} forEach allGroups;   


sleep 5;  

};

I think that should work, the issue I have at now is its just hanging the game. I dont know if its not sleeping for some reason or what the deal is.

But it seems to provide the desired effect.

if I omit the while loop and use

{    
	_grp = _x;
	if ((side _grp) == east) then {

		(leader _grp) move (position tank1);
	}
} forEach allGroups;   

it works but I think they will just move to the position the "tank" was at if the tank moves they wont keep after it.

Any ideas?

Share this post


Link to post
Share on other sites

The while loop works fine....just tested it. You don't have a space between while and {true}.

Maybe that's the problem.

Share this post


Link to post
Share on other sites

I tried adding that space between while and {true} unfortently it had no effect.

I thought the issue might be due to the sheer number of units I had in this mission. Probably over 100.

I copied the nessicary triggers and added them to a new mission file. This mission has about 20 units if that.

When the script runs it still hangs, though in this case after about 1min it clears up and units move as they should.

In the mission I have been building it has sat there locked up and not responding for more than 7 min before I finally kill the task.

I just cant imagine why its hanging like that.... hmmmm....

Share this post


Link to post
Share on other sites

you are still missing ; at end of your }.

while {true} do {  
{    
	_grp = _x;
	if ((side _grp) == east) then {

		(leader _grp) move (position tank1);
	}[b][size="8"];[/size][/b]
} forEach allGroups;   


sleep 5;  

};

in sqf scripts its important to end lines with a ; unless its a return value of a call or a {

Share this post


Link to post
Share on other sites

One thing that could be a problem using the MOVE command is that it won't work on any units that have been ordered to stop using DoStop..

Share this post


Link to post
Share on other sites
you are still missing ; at end of your }.

I just noticed that this is true. It is missing! Went back and checked the demo I made and it's missing there too....but the script still ran fine. Go figure???!!!!

Share this post


Link to post
Share on other sites

Thanks for pointing out the missing ;

Fixed that though and still having the same issue. hmmm

---------- Post added at 12:38 AM ---------- Previous post was at 12:22 AM ----------

Has anyone seen this happen before? maybe in other situations? Might give me some idea whats causing it.

Share this post


Link to post
Share on other sites

Here mate.... did two little demos for you. Tested and working. Done in Arma 2/OA

In Demo 1 the trigger executes a script.

In the triggers OnAct:-

nul = [] execVM "chase.sqf";

chase.sqf:-

while {true} do {
{
	_grp = _x;

	if ((side _grp) == east) then {
		(leader _grp) move (position tank1);
	};

} forEach allGroups;

sleep 5;
};

In Demo 2 the trigger spawns the code. So the code is in the trigger.

Code in OnAct:-

nul = [] spawn {while {true} do {{_grp = _x;if ((side _grp) == east) then {(leader _grp) move (position tank1);}} forEach allGroups;sleep 5;}};

Hope they help you man.

Edited by twirly
Clarity

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  

×