Home   Help Search Login Register  

Author Topic: How to get AI randomly patrolling a map?  (Read 805 times)

0 Members and 1 Guest are viewing this topic.

Ruste

  • Guest
How to get AI randomly patrolling a map?
« on: 01 Aug 2004, 03:44:07 »
Im creating a map where AI soldiers are randomly placed in the map (I can do this part), that move around the map searching for you. I guess you would be able to do this using random waypoints - but I dont know how that is done.

Also I have random vehicles and ammo around the map. It would be great if they could use vehicles and ammo crates when they find them.

Im new to this so im not sure what the capabilities of the editor are, would this be even possible?

Oh and I've only got Cold war crisis.

Thanks for any help

Nulear_Man

  • Guest
Re:How to get AI randomly patrolling a map?
« Reply #1 on: 01 Aug 2004, 10:10:27 »
i can help you with this
ok let me get this straight... You want to randomly place waypoints, if so heres a script that you might use

Quote
RandomWaypoints (Square)

_Group = _this select 0
_Area = _This select 1
_AreaX2 = _Area * 2

_Group move [((Getpos _Group) Select 0) + (Random _AreaX2 - _Area),((Getpos _Group) Select 1) + (Random _AreaX2 - _Area),0]
exit

or

Quote
RandomWaypoints2 (Circle)

_Group = _this select 0
_MaxDistance = _This select 1
_Dir = Random 360
_Distance = Random _MaxDistance

_Group move [((Getpos _Group) Select 0) + sin _Dir * _Distance,((Getpos _Group) Select 1) + sin _Dir * _Distance,0]
exit
« Last Edit: 01 Aug 2004, 10:12:36 by Nuclear_Man »

Offline KTottE

  • Former Staff
  • ****
Re:How to get AI randomly patrolling a map?
« Reply #2 on: 01 Aug 2004, 10:33:38 »
Or you could use the nifty Radius of Placement function in the mission editor. This specifies the radius (in meters) in which the waypoint (or unit) will be placed. Enter a radius of 500, or even 1000 and you will have a major variation in where the waypoint ends up every time you play the mission.

There is no need to script this, as it only uses up valuable resources.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:How to get AI randomly patrolling a map?
« Reply #3 on: 01 Aug 2004, 13:06:49 »
As KTottE says, placement radius works on both units and waypoints.    For units, you can also use the probability of presence and conditon of presence fields.

If you wanted a group to have a 50% chance of appearing, anywhere on the map, with between 3 and 6 members, but only if the player was in Veteran mode, then you would do this

Create the group leader and name him loon1.    Make his placement radius big enough for the whole map (but be careful about having him appear in the sea)

Name:  loon1
Condition of presence:   not cadeMode
Probality of presence:  50% (halfway along the slider)

The rest of the squad don't need placement radii as long as their special field is set to "formation", so that they start where the group leader starts.    

The first two have
Condition:  alive loon1
Probability:  100%

This means they will definitely appear if the group leader appears.

The other three have
Condition:  alive loon1
Probability:  50%   (or whatever you like).


An alternative trick, for slightly different circumstances, is to place markers on the map, make them invisible, then group them to a unit.  The unit will appear randomly at one of the marker positions.


Plenty of reviewed ArmA missions for you to play

Ruste

  • Guest
Re:How to get AI randomly patrolling a map?
« Reply #4 on: 02 Aug 2004, 10:08:04 »
Thanks for your help guys, I dont quite have what I want though.

Im wanting the random waypoints to be in a loop or something, so they wonder the map forever - not having to place lots and lots of points on the map.

What im thinking is this. Having one waypoint in the middle of the map, with radius of 1500 (to cover the whole island). When the unit has reached that waypoint, I could loop to the same waypoint (but it would be different because of the radius), so it could go forever.

Problem is I dont know how to do this.

Also I dont want squads, just seperate units. I dont know how to get different squads though, like when I play multiplayer it would have Apha Black, Alpha Green... etc.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:How to get AI randomly patrolling a map?
« Reply #5 on: 02 Aug 2004, 11:13:34 »
Use a cycle waypoint to make a group go through its waypoints again.    If you give it a big radius you won't know which of the other waypoints it "thinks" its next to.

Once a mission has started, a waypoint with a placement radius is in a precise place and it stays in that place for the whole mission.  

A unit cannot have waypoints.    However, a group (with waypoints) may have only one member.

To set group identies like Alpha Black use the setGroupId command.    This is not the same as the group name which is used in scripting.
Plenty of reviewed ArmA missions for you to play

Offline Roni

  • Members
  • *
  • Play the Game !
Re:How to get AI randomly patrolling a map?
« Reply #6 on: 03 Aug 2004, 02:09:11 »
Hi Ruste

Try the attached script.  It's part of a big mission that I'm working on at the moment which SHOULD be on the boards in the next few days.

What the script does is continually check which direction the player is heading, then resets the target waypoint to a random point somewhere in front of the players.  So if the player moved 200m NE since the last check then the waypoint is moved to  point around 200m to the NE of his current position.

The script actually has an "uncertainty radius", which is dependant upon how much the tracking unit knowsAbout the target.  Once they see you they wil head directly towards you, but if they lose sight of you they will start to hunt in wider and wider circles out to 400m away.

The script uses sound effects to let you know how close the tracking enemy are.  One is a custom  sound (a crow call), I have attached the relevant description.ext and sound files to make this work.

I've found this script to be pretty fun - put it on about four enemy groups and then try to slip the noose.  Zigzagging and doubling back really works, but the enemy is pretty smart and no matter how well you run or hide they will always keep tracking you down.  The script may in fact be TOO good - I'm still testing it (which is why I haven't put it on the boards yet  ;D )

Full usage notes etc are in the script commentary - good luck with it.


Roni

Ruste

  • Guest
Re:How to get AI randomly patrolling a map?
« Reply #7 on: 07 Aug 2004, 09:51:26 »
Hey Roni, that script you made looks very good. But im not sure how to implement it into my mission.

I guess im supposed to put this "[Group, Target, Waypoint] exec "huntToFrontContinuous.sqs" into my initialisation box for the unit I want to patrol, but I already have this "this addrating ((- rating this) - 100000)" which is a respawn script or something.

Also I dont know what values im supposed to put in. Come to think of it, are you even supposed to put that syntax into the unit init, or do you put it in for a group?

I think an example of the code used would help me out. Have you uploaded your mission yet?

Thanks,

Ruste

Offline Roni

  • Members
  • *
  • Play the Game !
Re:How to get AI randomly patrolling a map?
« Reply #8 on: 08 Aug 2004, 06:48:17 »
Hi ruste

Oops !  It looks like I didn't make my script commentary clear enough.  Sorry, my bad !    :P

Here's a worked example -

First, create your man and call him (say) - bigfattarget.

Next, create a group of enemy and name the leader (say) - huntgroup1.  In my mission I actually have lots of groups converging on the players from various directions so I named the groups after their town of origin - eg LaTrinite, Cancon, StPierre etc.

Now give this group a Seek and Destroy waypoint anywhere on the map and give it a radius of (say) 50m.  Don't worry about where you put the waypoint, the script will keep moving it every 2 minutes or so anyway - that's its job !

Go back to your group leader and in his Init field type in - [huntgroup1, bigfattarget, 1] exec "huntToFrontContinuous.sqs"

Now test the mission and try not to get yourself tracked down and killed !  

The first few times I tried it I kept getting run to ground and wiped out.  I then learned a few tricks that made my job a LOT easier.

First - listen carefully.  Once you hear that crow call you know that they're on to you (ie, within 400m).  By the time you get the voice cues it may be too late - the close voice cue ("unit say . . . ") kicks in at only 50m so they may actually see you before you hear them !

Second - note that even though the baddies will continually keep circling in on your position, they won't know exactly where you are until they actually spot you or you do something stupid like fire at them.  Until they spot you their search circle will be 400m - plenty of room for you to get lost in !

Once they spot you they become VERY hard to shake.  Hide in bushes or buildings or use LOTS of third person views to keep trees and buildings between you and the bad guys.  If worse comes to worse - RUN !  They probably won't keep up (at least in the short term) and you will be able to put some distance between you and them before they update their search pattern.

Third - zigzag frequently and often.  The script continually works out your path of movement and sends the hunting groups to a point somewhere in front of you in this direction.  If you don't move at all then the search is actually centered on your current position !

If you zig zag then they will keep moving to a point in front of your LAST direction of movement.  If they are on foot then you should be able to keep them so confused and behind the curve that they'll never catch up !

Even if they have trucks then all that movement will mean that they will have little time to search - the AI spends most of its time loading and unloading !  Give your man a move order of some sort and try playing as a member of the hunt group for a bit and see what I mean !

Finally - if the bad guys are all over you then sometimes a few wild shots or grenades can make them stop and head for cover.  You can then use that time to run, run and run some more !


Once you get ahead of a pursuing group then you should have no problems, especially if the baddies are on foot.  That's why I play with one final trick . . . !

Try this -

Set up your man and a hunting group as detailed above.  Now place another group (huntgroup2) at some point around the player's position.  Give this group TWO waypoints - the first to Guard and the second to Seek and Destroy.

Now make an "enemy present" Trigger and link it to this new group's Guard waypoint.  Edit the script in the hunters Init field to read

[huntgroup2, bigfattarget, 2] exec "huntToFrontContinuous.sqs"


Note the number "2", rather than 1 - this refers to the group's SECOND waypoint, not it's first.

Resize and move the trigger until it is in front of the player's escape route and voila - there you have it !  This new group will wait at its assigned Guard point until the player enters the trigger zone, then it will join in the hunt.

Tee hee !   :noo:  :help:

Have fun with the script.  I am finalising some fatigue, thirst and hunger scripts to go with it.  You think running is hard ?  Try running when you have to periodically stop to eat, drink and sleep !

Cheers !



Roni