Jump to content
Sign in to follow this  
Duke101

AI hunting player...

Recommended Posts

Hello,

Hoping someone could help if possible?

I've tried myself and searched for a script, etc that works for AI chasing/hunting the player- until I find a script by Larrow:

trackerGroup = group trackerLeader;

trackerCurrentWP = currentWaypoint trackerGroup;

if (trackerCurrentWP == count waypoints trackerGroup) then {

trackerGroup addWaypoint [(getPosATL player), 2, trackerCurrentWP];

};

handle = [trackerGroup, trackerCurrentWP] spawn {

while {alive player} do {

_this setWaypointPosition [(getPosATL player),2];

sleep 10;

};

};

which works perfectly! (This is the first one I've found that actually works).

I just want to check - I'm making a mission mp coop for 10+ players- the scenario is essentially when a objective is complete and the team is waiting for extraction something screws up and then they are being hunted by the enemy. That's in a nutshell anyway.

So my question is, will this script work on a MP server? The getPosATL player does that need to change? Our unit will stay together (which hopefully should help), but just wondering about "player" do I need to add waitUntil {!isNull player}; or similar? Or should I just name the group (the human group) using name = group this and so it would be getPosATL "group name" etc ? OR... will it be ok anyway? Just wondering if it work, even if there are 10+ "players" ? In other words how does the AI know who to follow? I just want to ensure it will work in MP. Hope that makes sense and I appreciate any help/suggestions you may have. Thanks.

Regards !

Share this post


Link to post
Share on other sites

Seems that the Larrows script works only on SP missions. You need to change the "player" with something else. As there might be 10+ possible players, the script needs something (single location - maybe calculated from all the player locations) for the AI to "home to". You can't use the "getPosATL group" as the command doesn't work on groups. And the script should only be run on the serverside.

Hope that helps!

Share this post


Link to post
Share on other sites
Seems that the Larrows script works only on SP missions. You need to change the "player" with something else. As there might be 10+ possible players, the script needs something (single location - maybe calculated from all the player locations) for the AI to "home to". You can't use the "getPosATL group" as the command doesn't work on groups. And the script should only be run on the serverside.

Hope that helps!

Thanks for the reply, I appreciate it. OK at least that clears a few things up for me! That's given me something else to think about.

Thanks again.

Share this post


Link to post
Share on other sites

I don't know why it wouldn't work in MP. Larrow is very good. Can't test right now as I'm not at my gaming rig. But...

Who/How its activated, should then be the 'player' who groupTracker would go after. If its activated on the host (you?), then they would track you. If you have another player activate it, then they would get tracked.

I have a similar code that I can post later when I get home that I typed up for a suicide-bomber script and a Hunter-Killer Team that would start tracking the player that turn 'on' his un-encrypted radio.

I would recommend a longer sleep time (20+random120), and maybe name all your players then have the script pick randomly just one to track, so you'll never know who's the exact target. OR have them track for X amount of time to get close then terminate the script so it plays out more naturally once they're near and find you guys.

My quick 2 cents.

----------

UPDATE: ok, back quick. Not tested. Maybe try:

_footprints = ["P1","P2","P3","P4","P5","P6","P7","P8","P9","P10"] call BIS_fnc_selectRandom;

_null = [] spawn {
  while {true} do {
     (trackerGroup) doMove (getPos _footprints);
     sleep 30 + random 222;
  };
}; 

Edited by Goblin
add code

Share this post


Link to post
Share on other sites

Thanks Goblin, that's very kind of you. Yes Larrow IS very good and that script works perfectly well. What you're saying makes sense... so perhaps it would work on a server (unfortunately I cannot test it on a server- yet).

What you've suggested also looks great- its late now for me, but I will have a look at it in the morning. I am assuming P1,P2, etc is to name all the human player slots and the script is triggered onAct, synched with the AI hunter group(S) ? I am using the AI Spawn Script Pack by spunFIN. But I think its asking too much to get it to work with that! So for this part of the mission I will just call on spawning units within the editor.

Thanks for your help, its much appreciated.

Share this post


Link to post
Share on other sites

If using spunFIN's AI Pack, there is a spot you can add some more code into their init:

_null = [group this, getPos player, 55] call BIS_fnc_taskPatrol;

Now that I think about it, the above post with doMove will have them move fast or run towards you. So you may want to change that so they appear more to 'hunt' you casually.

_footprints = ["P1","P2","P3","P4","P5","P6","P7","P8","P9","P10"] call BIS_fnc_selectRandom;

_null = [] spawn {
  while {true} do { 
_null = [group groupTracker, getPos _footprints, 55] call BIS_fnc_taskPatrol;
     sleep 30 + random 222;
  };
}; 

I suppose you can also use the first code and change the true to a set distance away from the player so they won't try and run too close into you guys.

Share this post


Link to post
Share on other sites

hmm... this is working perfectly within the editor, but not when a do a self-hosted test on MP ? But spunFIN's AI Pack using "reinforcement chopper" works great (really tested that and they kept finding me, however far I "got away" or hid). I had an HMG ifrit with _null = [group this, getPos player, 55] call BIS_fnc_taskPatrol; in the init with a short waypoint and synced that to the trigger (with the PHP Code onAct). This worked great in the editor, but as mentioned not when I tested it in MP.

At worse I suppose I can just use spunFIN's AI Pack.

Thanks so much for your help.

P.S. it works with "militarize" as well. The main reason for wanting to spawn my own units, is that I can select specific vehicles, etc. which isn't an option with spunFIN's AI Pack, only random vehicles.

Edited by pathfinder2-1

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  

×