Jump to content
Sign in to follow this  
malkekoen

Hunt script?

Recommended Posts

Hi.

Could anyone give some advice on how to make several units hunt an enemy unit continuosly?

I have tried adding a "move to pos NAME" in the init line of units, but they will only move to the position where the unit starts.

I then tried creating a global trigger that said "NAME move to pos NAME" and set it to check continously, but this just seem to do the same as in the above case.

Maybe this can only be done creating a sort of script, but I'm not very strong in that field I'm afraid. Any advice would be appreciated.

*** Edit: Added mission for anyone interested:

If anyone would care to see what I'm using these fine hunt scripts for, you're welcome to try my *very early* alpha release of the mission.

When I first tried LurchiDerLurch's AC-130 script I was inspired to try and do something like CoDMW (yeah I know, very original :o). I have only little experience in scripting, so this is a bit of learning-by-doing project.

As stated above, this is not to be regarded as a complete mission, but is more of a sketch of what I strive to do:

SETUP:

Bravo 2-1, a five man special operative team, has performed an extraction of an undercover agent behind enemy lines. Their helicopter has been shot down, probably by a man portable launcher. All flight crew died in the crash.

An AC-130 Spectre Gunship from a Turkish base patrolling along the Chernarusian border in the Black Sea has been dispatched to the Bravo 2-1 crash site.

Objective is to walk the survivors to a safe extraction zone further south out of enemy AA fire.

A helicopter, code-named "Saviour", is en route from the Khe Sahn.

OBJECTIVE:

Get Bravo 2-1 to the extraction zone with minimal casualties. Enemy are low-tech Chedaki rebels: Technicals and numerous personel presumed en-route to the crash site. Trucks and light armor has been confirmed to operate in the area.

NOTES ON GAME-PLAY:

There is no "end" or "win" triggers yet. So far you just have to judge your own performance by how many of the Bravo 2-1 team reaches the extraction zone.

You start in the AC-130, but due to limitations in my scripting skills you need to select "Call AC-130" in the roll-down menu and click on the Bravo 2-1 crash site.

The mission has no add-on requirements and has been made using the latest Betas as of today.

Download link:

http://www.filehosting.org/file/details/152953/SaviourNoAce.Chernarus.zip

The link might not work in Chrome for some reason.

To install, move the file in the documents/ArmA 2/missions and open it through the editor.

Edited by malkekoen
Added mission

Share this post


Link to post
Share on other sites

Easiest way is propobly by setting up a loop in an external scriptfile 'hunt.sqf' in your mission folder, like this:

hunt.sqf


_hunter = _this select 0;
_target = _this select 1;

while {(alive  _target) and (alive _hunter)} do {
  _hunter move getpos _target; 
   sleep 10;
};

Execute the script for example from the init line of the hunter like following:

[HUNTERNAME, TARGETNAME] execVM "hunt.sqf"

This script will let the hunter move towards the targets position. The move call is updated every 10s. The script will exit if either hunter or target is dead.

Good luck with your mission.

Edited by Walker001

Share this post


Link to post
Share on other sites

Thanks alot Walker001, this seems easy.

I've been playing around with a script made by a french guy called FAR-FD, but it's a little too complicated for me and the scope of my mission.

I'll try this tonight when I get some time!

Cheers!

Edit: I just spend the whole night fiddling with your script (when I should have been sleeping) and it works like a charm. Beautiful. Thank you for your help!

Edited by malkekoen

Share this post


Link to post
Share on other sites

Sorry to bother again, but can anyone explain what this function does in the above script made by Walker001:

_hunter = _this select 0;

_target = _this select 1;

What is the purpose of this?

Share this post


Link to post
Share on other sites

It does read your array entries from the script call.

Local script variable _hunter will become HUNTERNAME and _target will become TARGETNAME. This way the script suits for more than just one target, hunter or even mission because everything is setup with the execution line.

As long as the hunting unit and the it's target are alive the target's position is issued as move order to the hunter every ten seconds.

The short interval could be an issue if the hunter bothers more about the many move orders than combat. I would try how much minutes of script interruption still do for a realistic chase.

Edited by Trapper

Share this post


Link to post
Share on other sites

_hunter assigns a first variable you set via exec call, _target is the second variable. They are the unit names in editor.

Share this post


Link to post
Share on other sites

Thanks for the answers. I figured that the _hunter and _target were a "name-holder", but what's the point in the 0 and 1? It doesn't seem to use these numbers in the script...

Please forgive my stupidity ;)

Would it be possible then, to target a group as a whole, or is this script limited to single persons. Another thing: When I tried grouping more scripts into the same SQF file, as here:

c1 = _this select 0;

x1 = _this select 1;

while {(alive x1) and (alive c1)} do {

c1 move getpos x1;

sleep 10;

};

c2 = _this select 0;

x1 = _this select 1;

while {(alive x1) and (alive c2)} do {

c2 move getpos x1;

sleep 10;

};

... the script doesn't seem to work. So I set up a script for every unit chasing the target, which is quite alot. Here it would also help if I could get the hunter to target the group, and not just an individual.

Hope you can help a bit

Edit: Just to help me understand: If I deleted the "sleep 10;" at the end of the script, would it then just run once, or continously as long as hunter and target are alive?

Edited by malkekoen
More questions

Share this post


Link to post
Share on other sites

Some thing like this would work.

You will need to create a real group by placing this in each leaders init, named differently of course.

for the hunted it would be

prey=group this;

and for the hunters lets have two groups.

1st group init

pack1 = group this;

2nd group init

pack2 = group this;

You now have three groups with names.

to start the hunt from a trigger set the trigger up how you want and then in the on act box put nul=[prey,pack1] execvm "hunt.sqf";nul=[prey,pack2] execvm "hunt.sqf";

when the tigger is activated both groups will hunt the prey group. (Hopefully)

_hunted = _this select 0;
_hunter = _this select 1;

while {{alive _x} count units _hunter  >= 1  and {alive _x} count units _hunted  >= 1 } do {
_leader = leader _hunted;
  _leadpos = getpos leader _leader;
   _hunter move getpos _leader;
sleep 30;
};

This script will actually be running twice once for pack1 and again for pack2 or more if you have more groups.

sleep 30; will run the script once every 30 seconds which is more than enough for this type of script.

You should aim for running all scripts as little as possible to keep the game running quickly.

Share this post


Link to post
Share on other sites

Ok that is great. This script is working perfectly! Thanks mate

Share this post


Link to post
Share on other sites

If anyone would care to see what I'm using these fine hunt scripts for, you're welcome to try my *very early* alpha release of the mission.

When I first tried LurchiDerLurch's AC-130 script I was inspired to try and do something like CoDMW (yeah I know, very original :o). I have only little experience in scripting, so this is a bit of learning-by-doing project.

As stated above, this is not to be regarded as a complete mission, but is more of a sketch of what I strive to do:

SETUP:

Bravo 2-1, a five man special operative team, has performed an extraction of an undercover agent behind enemy lines. Their helicopter has been shot down, probably by a man portable launcher. All flight crew and one special operative died in the crash.

An AC-130 Spectre Gunship from a Turkish base patrolling near the Chernarusian border in the Black Sea has been dispatched to the Bravo 2-1 crash site.

Objective is to walk the survivors to a safe extraction zone further south out of enemy AA fire.

A helicopter, code-named "Saviour", is en route from the Khe Sahn.

OBJECTIVE:

Get Bravo 2-1 to the extraction zone with minimal casualties. Enemy are low-tech Chedaki rebels: Technicals and numerous foot mobiles are presumed en-route to the crash site. Trucks and light armor has been confirmed to operate in the area.

NOTES ON GAME-PLAY:

There is no "end" or "win" triggers yet. So far you just have to judge your own performance by how many of the Bravo 2-1 team reaches the extraction zone.

The mission has been made with ACE, and even though I tried to keep it independent by not selecting any ACE specific units or modules, it does not work yet without ACE.

You start in the AC-130, but due to limitations in my scripting skills you need to select "Call AC-130" in the roll-down menu and click on the Bravo 2-1 crash site.

Download link for Saviour:

Removed, see top.

Future plans: I would like to make a collection of CoDMW inspired missions, from the extraction of the agent, to the flight from the crashed helicopter, and finally this AC-130 mission. Let's see how my skills progress.

I am not sure about the location yet, so maybe I'll move the crash site later on.

There seems to be a problem with AI not engaging the Bravo 2-1 team properly, so I have set up triggers that forces AI teams to target Bravo 2-1. This has helped, but I'm working on a more permanent solution.

Have fun, and please forgive my Noobish skills!

Edited by malkekoen
Editorial

Share this post


Link to post
Share on other sites

Hey malkekoen, the link didnt work

No worries, it works in IE, not chrome... cheers

Share this post


Link to post
Share on other sites

I don't use ACE so never mind.

Thinking about the hunt script I think a better idea would be to use a created waypoint, the reason for this would be that you have much more control on how the units respond at each waypoint.

Also one thing I would change in the current script would be the sleep 30;

maybe sleep 20+random 10; would be better then the groups would be running the code at different times rather than all at once and they wouldn't all change direction at the same time.

Share this post


Link to post
Share on other sites

Too bad with ACE... Strange I really tried to keep it clean from ACE stuff, I'll try to get it set up without when I get home in a few days.

Maybe ACE makes some independent classes in the "default" categories and not only in the defined "Æ ACE" classes.

No worries, it works in IE, not chrome... cheers

:)

Share this post


Link to post
Share on other sites

Excuse my ignorance... but wheres the OP?

Can you throw a link up?

Share this post


Link to post
Share on other sites
Excuse my ignorance... but wheres the OP?

Can you throw a link up?

The original post, top of the thread :)

Thinking about the hunt script I think a better idea would be to use a created waypoint, the reason for this would be that you have much more control on how the units respond at each waypoint.

Also one thing I would change in the current script would be the sleep 30;

maybe sleep 20+random 10; would be better then the groups would be running the code at different times rather than all at once and they wouldn't all change direction at the same time.

How would you create a waypoint? I have the problem that infantry units don't seem to engage the targets and neither does the targets engange the hunter's infantry. I have tried alterering the sleep to much more, but it doesn't change anything. Maybe a waypoint would fix this behaviour. Vehicles engange normally though, strange...

Any ideas?

Edited by malkekoen
Editorial

Share this post


Link to post
Share on other sites

I haven't looked at waypoints yet, I did just check the script and they are engaging just fine here.

Don't do as I once did and remove the ammo from my units, that took me a whole night to find that one out.

Check they're not in safe or careless mode.

Other than that I don't know.

I just tried the mission and removed the vehicles and just let foot1 and foot2 move in and they open fire as they should.

Sometimes if they get too close it goes a bit funny but I think that's just how the game is at times.

I don't have time to test it fully, I couldn't see anyone from the c130.

Edited by F2k Sel

Share this post


Link to post
Share on other sites
I haven't looked at waypoints yet, I did just check the script and they are engaging just fine here.

That's because I set up triggers to force the groups to engage. I made 3 triggers, all set up to activate repeatedly, one that gives the CommandTarget order, one Fire order, one Reveal order. I don't know if they're all necessary + they are set up to target the team-leader only. Is there a way to let a group target another group as a whole and not just one person in that group?

And would it be possible to use the hunt script to allow the groups to target each other, something like:

_hunted = _this select 0;

_hunter = _this select 1;

while {{alive _x} count units _hunter >= 1 and {alive _x} count units _hunted >= 1 } do {

_leader = leader _hunted;

_leadpos = getpos leader _leader;

_hunter target (or engage or something) _leader;

};

It's strange, I tested this:

If two enemy AI groups (infantry only) move towards each other due to, eg. converging paths or a hunt script, they will not fire or even report seeing the other part. I tested this by making myself a member of unit (not in command) and placed myself far away from my leader. No radio calls like "enemy man at XXXX".

As can be seen from the AC-130 groups will just not engage, I've seen them literally bump into each other (without the triggers running as mentioned earlier). And they are in "aware" mode and have full stocks of ammo.

If then, I choose one playable and switches to that unit, they open up on each other immediately. Also if I make myself, eg. a civilian and places me next to the action they also engage normally.

So it seems that AI is "forgetting" to report and engage enemies if there's not an active player around to supervise them.

So if this is a fact, then how could a script be done that contiously forces one group to target (and fire upon) an enemy group?

Share this post


Link to post
Share on other sites

Have you tested in daylight, mine work as I would expect and report seeing each other at around 500meters. They open fire at about 150meters.

For my test I placed myself as a civ in a helicopter a few thousand meters away and let them get on with it and as I expected they open fire without any problems.

I them moved a soldier not leader but still grouped into the chopper and he was still receiving radio commands.

Try giving some of the OPFOR night vision, on another test I did you can put a BLUFOR two meters infront of OPFOR and he won't fire unless BLUFOR moves or fires his weapon.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

I just made a video to show you what I mean.

The OPFOR AI are following the hunt script, the BLUFOR a waypoint. Notice how neither part engages, and all BLUFOR and OPFOR leaders have NVG. Notice that as soon as I select one unit the targeting engages. And they are all "aware" and "open fire". Strange...

http://www.youtube.com/watch?v=e_i1bj2FiqM

Share this post


Link to post
Share on other sites

It does seem like a bug, I set it to daylight and turned off the hunt script and your targeting and they did come across each other and never fired. It doesn't happen all the time for me though.

It would be interesting to display the knowsabout command and see if they really know they are there.

I will try using a waypoint move and see if that makes a difference as that could be changed to a seek and destroy if they knowabout the enemy but I'cant look at that until tonight.

I must admit I never look a night battles as it's always felt a bit unreal in the way they respond and can't see any better when your light up by lighting and flares.

What version are you running, I'm using the latest beta.

Share this post


Link to post
Share on other sites
What version are you running, I'm using the latest beta.

Me too and for testing purposes without any add-ons. I actually tried moving units with waypoints too, and the same happens. Even with a search and destroy waypoint. I'm not sure, but I suspect that maybe to conserve processing power, AI units are kept on a kind of "maintenance" mode when a player is far away.

But sometimes, yes, they engage each other (rarely though). It is strange.

Share this post


Link to post
Share on other sites

I've never seen this happen on Utes which is where I've spent 90% of my time as until a few weeks ago I didn't have a pc good enough to run Chernarus .

I hate the idea of revealing one side to the other as it's hard to make it fair, if you target the leader you won't last long and if your hidden there's no benefit.

After more testing I think the problem is within the C130 script, it only happens when using this script.

I did some more testing by placing two opposing sides and watched them engage.

I then put myself in a chopper miles away and again they engaged each other.

I then ran the c130 script but didn't select call c130 action until shooting had started, when I did that the carried on fighting.

Then I reran the game and selected call c130 action before shooting started and in this case no engagement took place until I exited the c130 when I suspect the script stops.

I'm convinced the problem lies in the C130 script but it's a bit beyond my understanding so I wouldn't know how to debug it.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

I agree with you. I've never seen this happen before I used the AC130 script neither. The AI generally has a lot of problems coming to terms with the script there, also you're practically invulnerable as the AI rarely targets the plane and when it does it seems that it's invincible.

I'll try and post the movie in the AC130 script forum to see if the author has any comments on it.

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  

×