Jump to content
Sign in to follow this  
Nicholas

Random Spawn and Waypoints

Recommended Posts

I think that ArmA III should introduce the capability to have random predefined spawn points and random predefined waypoints. We can already do spawn zones and waypoint zones, where the spawn or waypoint will be placed somewhere in that chosen radius.

What I would like is the ability to change where the unit spawns or where their next waypoint is, depending on predefined spawn positions or waypoints.

Basically something like this:

1) Place a unit.

2) Choose spawn type: Radius, Current, or Random Position If "Random Position" is selected, the user must then place several points on the map where the AI has the possibility of spawning.

The same thing can be applied to waypoints. The unit can have multiple waypoints. Such as Waypoint 1A, Waypoint 1B, and Waypoint 1C. It will then be randomly chosen which Waypoint 1 the unit will be required to go to.

Here is an example for waypoints

2432gj4.jpg

Share this post


Link to post
Share on other sites
2) Choose spawn type: Radius, Current, or Random Position If "Random Position" is selected, the user must then place several points on the map where the AI has the possibility of spawning.

This can be done by grouping the unit to markers since OFP.

Share this post


Link to post
Share on other sites
This can be done by grouping the unit to markers since OFP.

Ok, well I was not aware of this. Is it possible to have random waypoints as well?

Share this post


Link to post
Share on other sites

Thanks for the help but both of those commands do what I can already do ingame.

Moves the waypoint to a random position in a circle with the given center and radius.
The waypoint is placed randomly within a circle with the given center and radius

I do not want them placed within a "radius" that I will never actually know where they are being randomly placed. I want to be able to set predefined random waypoints.

Did you see my above example? I want to be able to set Waypoint 1 A or Waypoint 1 B, then have the AI randomly choose which Waypoint 1 to move to, A or B.

Share this post


Link to post
Share on other sites
Thanks for the help but both of those commands do what I can already do ingame.

I do not want them placed within a "radius" that I will never actually know where they are being randomly placed. I want to be able to set predefined random waypoints.

Did you see my above example? I want to be able to set Waypoint 1 A or Waypoint 1 B, then have the AI randomly choose which Waypoint 1 to move to, A or B.

I am quite drunk right now, but how about setWPPos? Though Addwaypoint would also work fine, even though its a bit of a hassle.

Share this post


Link to post
Share on other sites
I am quite drunk right now, but how about setWPPos? Though Addwaypoint would also work fine, even though its a bit of a hassle.

Nope, I do not believe it would work.

Share this post


Link to post
Share on other sites

You most definitely can already script this using either setWaypointPosition (radius 0) or setWPPos with some other commands, but it would be easier if we could use a grapical interface to do so.

Share this post


Link to post
Share on other sites
You most definitely can already script this using either setWaypointPosition (radius 0) or setWPPos with some other commands, but it would be easier if we could use a grapical interface to do so.

I'm not sure if people understand me or not. What I'm trying to say is this:

1) You place a unit on the map.

2) You give him five waypoints (WP1, WP2, WP3, WP4, WP5).

3) You want the unit to go to WP1, but then either WP2 or WP3 (Randomly chosen by unit), then onto WP4. So the AI will have to choose from two different paths it can take, before moving onto the next waypoint.

That is possible? ^^

I don't want to set the waypoint within a radius. I want it at a predefined position, predefined by me.

Edited by Nicholas

Share this post


Link to post
Share on other sites

It is very possible. You would run a script file when you want to make the unit move out, either via trigger or called in another script, or even from its init line if you wish for it to move straight away.

Start with:

_groupOne = group *whateverunit*;
_randomWPinteger = round (random 4);

...which will return either 0, 1, 2, 3 or 4. Moving on:

if (_randomWPinteger = 0) then {[_groupOne, 1] setWPPos markerPos "MarkerWPPossibility1"};
if (_randomWPinteger = 1) then {[_groupOne, 1] setWPPos markerPos "MarkerWPPossibility2"};
etc etc ad infinitum

The AI will randomly "select" and move to one of your 5 waypoints. All you do is put down markers where you want to give the option for the AI to move to in each case, and then run another similar script upon reaching the waypoint.

It's not easy, but it's certainly not Maths C surd multiplication either.

Note that the above code is probably broken in about 30,000 places, but I'm currently not in the mood to write something ironclad.

Further discussion probably belongs in A2 scripting.

Share this post


Link to post
Share on other sites
That is possible? ^^

Yes!

In WP1's on Act field:

myGroup setCurrentWaypoint [myGroup, 2 + floor random 2]

Then at WP2 (to stop them from going to WP3):

myGroup setCurrentWaypoint [myGroup, 4]

That's it. ArmA's script language allows you to do a lot more than you may think (and almost always in more than one way as CameronMcDonald shows) :)

Share this post


Link to post
Share on other sites

It would be nice if this were simplified as it is a very useful thing. Perhaps we could have a "DECISION" waypoint, which could be connected to multiple next waypoints, with some logic choosing which one to go to next. The default would be to choose randomly, but with the ability to attach some scripting to make the decision in other ways. Similar to trigger logic maybe. Yeah you can do this with some semi-complicated scripting but it would be nice to see it visually represented in the UI and to be able to draw these waypoints out in the editor and then hook them up, with at most a little coding in a "decision script" texbooks on the DECISION waypoint, that defaults to the code for "pick at random".

Here are some examples of things that it would be useful to make a decision on, which could be supported in the UI with minimal scripting:

-- Choose next waypoint based on whether enemy units are detected / how many

-- Choose next waypoint based on whether friendly units are detected / how many

-- Choose next waypoint based on time of day

-- Choose next waypoint based on how many units in my group

Lots of possibilities here:

-- A patrol that circles around to different locations until nightfall, at which point it heads home until morning

-- A patrol that circles different locations, but if it finds one abandoned, switches to garrison it

-- Move to an area, get in/out of a vehicle based on presence of enemies

-- A patrol that goes to different locations at random

Share this post


Link to post
Share on other sites
It would be nice if this were simplified as it is a very useful thing. Perhaps we could have a "DECISION" waypoint, which could be connected to multiple next waypoints, with some logic choosing which one to go to next. The default would be to choose randomly, but with the ability to attach some scripting to make the decision in other ways. Similar to trigger logic maybe. Yeah you can do this with some semi-complicated scripting but it would be nice to see it visually represented in the UI and to be able to draw these waypoints out in the editor and then hook them up, with at most a little coding in a "decision script" texbooks on the DECISION waypoint, that defaults to the code for "pick at random".

Here are some examples of things that it would be useful to make a decision on, which could be supported in the UI with minimal scripting:

-- Choose next waypoint based on whether enemy units are detected / how many

-- Choose next waypoint based on whether friendly units are detected / how many

-- Choose next waypoint based on time of day

-- Choose next waypoint based on how many units in my group

Lots of possibilities here:

-- A patrol that circles around to different locations until nightfall, at which point it heads home until morning

-- A patrol that circles different locations, but if it finds one abandoned, switches to garrison it

-- Move to an area, get in/out of a vehicle based on presence of enemies

-- A patrol that goes to different locations at random

Nice idea!

Share this post


Link to post
Share on other sites

Hi,

Nicholas point is, more functionality within the editor.

Share this post


Link to post
Share on other sites

For these situations, we've been using copyWaypoints for some time now. I think you'll find it allows you to do pretty much everything suggested here quite easily.

Share this post


Link to post
Share on other sites

Copying way points is a hack getting around the lack of a proper implementation. We should not argue against proper implementation on the grounds that some ridiculous hack can accomplish the same thing in a round about, arcane way.

For one thing it's not going to be obvious to new players. They might actually have to find this thread, or one like it, to learn about this hack. Common scripting cases should be implemented with clear, clean, intuitive, well documented methods that are directly accessible in the editor.

In general all ridiculous hacks should be replaced by proper, clear implementations if we want scripting to be something any savvy user can do, as opposed to old timers who scour forums for hacks.

Edited by Polar Bear

Share this post


Link to post
Share on other sites

I like what Nicholas is suggesting. The more features there are, the better. What I would like to see is some system like UPSMON as a module because I like using UPSMON for most of my missions. It gives it a bit more dynamic feeling to it and the AI reacts much better. Well, if that doesn't happen, I guess I can wait for a release.

Share this post


Link to post
Share on other sites

1) Set unit on map (nicknamed TheDude).

2) Place 5 waypoints on editor map (WP1, WP2, WP3, WP4, WP5). If you're trying to make waypoints in-game rather than in-editor, that's different.

3) Make a script:

_randomArray = [WP2, WP3];

//Presumably, WP2 and WP3 are variables for arrays like [(group TheDude), 3] and [(group TheDude), 4]

_randomSelect = (_randomArray select (round (random 1)));

// This will select either WP2 OR WP3 randomly

deleteWaypoint _randomSelect;

//This deletes the selected waypoint, leaving the other one as the only option

This way you can predefine the position of each waypoint via the editor while also randomly choosing one of the two waypoints (by deleting one). I hope that helps (though I might have misunderstood you).

Share this post


Link to post
Share on other sites
...

You love the word hack, don't you...

CopyWaypoints was introduced for quick and simple design of alternate paths for both players and the AI - which is exactly what is the required functionality described in this thread. I fail to see the "ridiculous hacking" side of this.

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  

×