Jump to content
fin_soldier

doMove to Multiple Players

Recommended Posts

Hello,

 

I'm working on a two player scenario, in which I've set a group of enemies chasing the player with a simple doMove script as such:

Quote

(leader gr1) doMove (getPos p1);

sleep 45;

null = [] execVM "gr1.sqf";

The idea is that every 45 seconds the group moves to the players current location.

But there is a problem, what if player 1 (p1) dies. The group won't follow player 2.

 

Is there a solution for this, so that the AI group chases both players?

 

 

Thanks in advance! 🙂

Share this post


Link to post
Share on other sites

Yep, I'll search for it this afternoon, when I'm back from work.
Need to put an area-trigger, in which the first player entering is defined as target.
After that a script will follow the player an direct the enemy towards it every X seconds.
 

Share this post


Link to post
Share on other sites

1: Put an area-trigger named "trigger1" around the wanted area, when a player enters, he will be chased. (BLUFOR present, check server-sided!)

2: Put an enemy group "reactgrp1" (near the center) of the trigger, so it reaches the entering player with nearly same time, no matter from where the players entering the area-trigger.

condition:

(this) && {"MAN" countType thisList > 0}

or , if you want to get an entering vehicle (chopper-landing, etc.) as target.:

(this) && {"AllVehicles" countType thisList > 0}




 on activation:

if (isServer) then {
nul = [] spawn {
targetunit = (list trigger1) select 0;                                     // select 1,2,3, etc. for the second, third, fourth, etc. player
sleep 10 + random 10;                                                      // select a start-time for your needs, before they start chasing
{_x doMove (getPos _x)} forEach units reactgrp1;
sleep 1;
reactgrp1 setBehaviour "SAFE";
reactgrp1 setSpeedmode "LIMITED";
reactgrp1 setFormation "FILE";
while {{alive _x} count units reactgrp1 > 0} do {reactgrp1 move (getPos targetunit); sleep 15};           // checks every 15 sec. if any AI-unit is still alive to chase players and send them every 15 Sec. to the actual player-position.
};
};


Conclusion:
You cannot choose a complete player-group for chasing, so the first entering player will be the target.
In my experience, the enemy will spot the player group and attack them, no matter, which one was the first entering player and if they are at target distance, they are normally close enough to the whole player-team.
The behaviour of the enemy group in the example above suggest the player, that there is just a chilled patrol without any intentions, but the "SAFE"-Part allows to enter other behaviour-modes.
Change it to your needs.
The last line is the line, where you can insert 45 instead of 15 Sec.

Share this post


Link to post
Share on other sites

Hey fin_soldier, Purzel's solution will most probably do the trick for you. Since you are sure you will have at max two players I would suggest a different approach.

 

I will use your code to make it as "close-to-the-original" as possible

// I will assume you have the players in p1 and p2 variables

// Now check if p1 is alive
if(alive p1) then {
    (leader gr1) doMove (getPos p1); // Follow p1
} else {
    (leader gr1) doMove (getPos p2); // Follow p2
};

sleep 45; // Take a power nap
null = [] execVM "gr1.sqf"; // Do your thing

Now, if you don't handle the mission when both players are dead, then the code here will break. The second branch will execute, which is not what you want. This could be solved with the somewhat uglier code

// I will assume you have the players in p1 and p2 variables

// Now check if p1 is alive
if(alive p1) exitWith {
    (leader gr1) doMove (getPos p1); // Follow p1
    sleep 45; // Take a power nap
    null = [] execVM "gr1.sqf"; // Do your thing
};

// If p1 is dead check for p2
if(alive p2) exitWith {
    (leader gr1) doMove (getPos p2); // Follow p2
    sleep 45; // Take a power nap
    null = [] execVM "gr1.sqf"; // Do your thing
};

// DEBUG or whatever
systemChat "Nooooooooooo..., they are both dead!";

Hope this helps.

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

×