Jump to content
Sign in to follow this  
anthonyfromtheuk

Spawn enemy group that knows player position and hunts them down.

Recommended Posts

Hi, I have searched around but can't quite find what I want. What I would like is an enemy group to spawn that knows the player position and will actively hunt the player. can anybody explain how to do this or point me in the right direction of something similar I may be able to use? Thank you

Or even just an enemy group that will follow set waypoints and despawn once they have searched

Edited by Anthonyfromtheuk
That would also be useful to know :D

Share this post


Link to post
Share on other sites

Hmm nevermind guess i'll just learn how to spawn a group and get them to search waypoints and despawn them after, back to searching!

Share this post


Link to post
Share on other sites

Instead of creating the waypoint and setting all its properties, just spawn the group and use this command on them:

http://community.bistudio.com/wiki/move

If you want them to hunt down the enemy, try this:

http://community.bistudio.com/wiki/setCombatMode

That command probably works well with 'reveal' to make them go after a known enemy. A seek and destroy waypoint only makes them search in a small radius around the waypoint position and then stop and do nothing.

Share this post


Link to post
Share on other sites
while { {alive _x} count (units groupOne) >= 1 } do {
   groupOne move (position player);
   sleep 30;
};

Share this post


Link to post
Share on other sites

As many suggested, repeatedly setting the current waypoint to the player position is the most reliable solution.

Share this post


Link to post
Share on other sites

This is what I ended up using, works really well for my needs

if (!isServer) exitwith {};
_side = createCenter west;
_GroupSquad1 = [getMarkerPos "Group", _side, ["o_soldier_TL_F", 

"O_soldier_AA_F", "o_soldier_AA_F", "o_soldier_AA_F"], [], [], 

[0.3, 0.6]] call BIS_fnc_spawnGroup;
_waypoint1 = _GroupSquad1 addWaypoint [(getPosATL player),2];
       sleep 10;    
_waypoint1 setWaypointType "MOVE";
_waypoint1 setWaypointStatements ["true", ""];  

They spawn and then then hunt me down quite nicely (I know it is side west with eastern troops need to find classnames for bluefor)

Now I want to be able to despawn them via a trigger.

Code I was using before which worked perfect for an individual unit of which I knew its name (I am under the assumption this will work even if he is in a car)

{deleteVehicle _x} forEach (crew unit1); deleteVehicle unit1;

but if I replace unit1 with groupsquad1 nothing happens how can I despawn this group I have spawned in?

On a side note could I use group names and spawn a whole group instead of individual units with the same code? (again need to find classnames ,so I haven't tried this yet)

Share this post


Link to post
Share on other sites

That's because the BIS_fnc_spawnGroup returns a group, not a signle unit. (According to your code, at least.) To "delete" all members of a group simple use:

{deleteVehicle _x} forEach units _groupsquad1;

Share this post


Link to post
Share on other sites
That's because the BIS_fnc_spawnGroup returns a group, not a signle unit. (According to your code, at least.) To "delete" all members of a group simple use:

{deleteVehicle _x} forEach units _groupsquad1;

Thanks Again IndeedPete, you are helpful :D

Ah wait I get an error. Local variable in globalspace. ???

Share this post


Link to post
Share on other sites

if (!isServer) exitwith {};
_side = createCenter EAST; // if you already have opfor on the map you dont need this.
GroupSquad1 = [getMarkerPos "Group", _side, ["o_soldier_TL_F", "O_soldier_AA_F", "o_soldier_AA_F", "o_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;

_waypoint1 = GroupSquad1 addWaypoint [(getPos player),2];
_waypoint1 setWaypointType "MOVE";

{deleteVehicle _x} forEach units groupsquad1;

local = _groupSquad1

global = groupSquad1

Another method would be:

if (!isServer) exitwith {};
_side = createCenter EAST; // if you already have opfor on the map you dont need this.
_groupSquad1 = [getMarkerPos "Group", _side, ["o_soldier_TL_F", "O_soldier_AA_F", "o_soldier_AA_F", "o_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
_leader = leader _groupSquad1;

_waypoint1 = _groupSquad1 addWaypoint [(getPos player),2];
_waypoint1 setWaypointType "MOVE";

waitUntil { { alive _x} count (units _groupSquad1) == 0 or player distance _leader > 500};

{deleteVehicle _x} forEach units _groupsquad1;
deleteGroup _groupSquad1;

Edited by cobra4v320

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  

×