Jump to content
killermanny9

Trying to create a random move waypoint for my mission.

Recommended Posts

I've been working on a mission for a while now and have the basic setup and AI all together. I decided to change up the way it does insertions though but cannot figure out how to get a helicopter to have a move way point randomly placed across marked points on the map.

Currently I have a helicopter (Heli1) go to a move way point and rappel troops down onto and invisible heli pad (RappelP) and fly off deleting itself on a trigger in the distance and it works great. My issue is that my mission works with a lot of randomly placed structures and loot with random spawn locations for the opposing team and items that do not start in a helicopter. I think its pretty lame to have everyone else randomly spawn but for one side to always have to be dropped in the same place.

Share this post


Link to post
Share on other sites

Make an array of your marked points and use *cough*-- ah-hem!-- selectRandom.

 

Like this,

randomPoint= selectRandom [point1, point2, point3];
_wp =_grp addWaypoint [position randomPoint, 0];

Have fun!

  • Thanks 1

Share this post


Link to post
Share on other sites
36 minutes ago, wogz187 said:

Make an array of your marked points and use *cough*-- ah-hem!-- selectRandom.

 

Like this,


randomPoint= selectRandom [point1, point2, point3];
_wp =_grp addWaypoint [position randomPoint, 0];

Have fun!


Thanks, This is my first creation with absolutely no experience with Arma scripting. I'll figure out where it goes and all that technical stuff.

Share this post


Link to post
Share on other sites

@wogz187

 

Just at mission start, I have a heli already in there air with a waypoint to the center of the map, I'm trying to get the second move waypoint be randomized once it reaches the first move waypoint so the helicopter goes to the center of the map then to a random position. Ive already got the markers out to the spots I want and already have them synced to the waypoint I want random. I assumed by array you mean synced like some other random spawned stuff I managed to get working without scripts.

Heli Variable (Heli1)
Pilot Variable (Heli1A)
Marker Variables (Point1, Point2, etc.)

I dont know if giving you the variables would be useful

Share this post


Link to post
Share on other sites

Okay. Sounds like you just need to stick the code in a trigger at the second waypoint. The first waypoint is editor placed?

What's the group name, I'll put the whole script together and check it works for you.

Share this post


Link to post
Share on other sites

@wogz187

Sorry, was feeding my baby. group name as in my team? If that's the case its Independant. Yes the first waypoint is editor placed

Edited by killermanny9
Forgot some info

Share this post


Link to post
Share on other sites

@killermanny9,

Put this in the ON ACTIVATION field of the trigger at WP 1.

heliGroup= group Heli1a;
randomPoint= selectRandom ["marker1", "marker2", "marker3"]; // array of named markers

_wp = heliGroup addWaypoint [getmarkerpos "randomPoint", 0];
_wp setwaypointtype "MOVE";
_wp setWaypointSpeed "NORMAL";
heliGroup setBehaviour "Aware";

This will make a waypoint at one of the markers you include in the array.

Get back to me if you have an error.

  • Like 1

Share this post


Link to post
Share on other sites

@wogz187

 

Sorry it took me a while. other things I had to do in life. I put the script in ON ACTIVATION on the trigger and kept getting some errors as I changed some things up, I guessed that _wp is the variable I named the waypoint I want to randomize? and some other things like the group up beside heliGroup =. I dont know a solution for this error though.

 

This is the error I get now.

call{heliGroup= H! |#| H1A;
randomPoint= selectRandom ["Marker...'
Error Missing ;

This is the updated version with some changes. please let me know if I screwed some things up.

heliGroup= H1 H1A; 
randomPoint= selectRandom ["Marker1", "Marker2", "Marker3", "Marker4"]; // array of named markers 
 
Insertion = heliGroup addWaypoint [getmarkerpos "randomPoint", 0]; 
Insertion setwaypointtype "MOVE"; 
Insertion setWaypointSpeed "NORMAL"; 
heliGroup setBehaviour "Aware";

 

Share this post


Link to post
Share on other sites

@killermanny9
Okay. Sorry.

Remove the comment, that can't go in a trigger. I put that there to call your attention to the array. So erase "// array of named markers".

I think everything else looks okay.

Share this post


Link to post
Share on other sites

@wogz187

 

Don't apologies, you're helping me even though you didn't have to go any farther than providing the script in the first place, and I really appreciate it. I do still seem to have an issue though. I dont thing I'm doing something right at this point because the helicopter now just stays still in the air with this error.

'... "Marker4"];

Insertion = heliGroup |#|addWaypoint [getmarkerpos "randomPoint",...'
Error Generic error in expression

 

Share this post


Link to post
Share on other sites

@killermanny9,
Let's try,
1) Remove your pilot's name (he's automatically named vehicle name +d = heli1d)
2) copy the code directly from this file. (to avoid the forum bug).

It'll work.

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites

@wogz187@killermanny9

 

Line 1 of the linked sqf is throwing error.

I retyped it and works.

 

It is best to use local variables.

 

Spoiler

comment "Heli1 is the helicopter object.";

_heliGroup = group Heli1;
_randomPoint = selectRandom ["marker1", "marker2", "marker3"];

_wp = _heliGroup addWaypoint [markerPos _randomPoint, 0];
_wp setwaypointtype "MOVE";
_wp setWaypointSpeed "NORMAL";
_wp setWaypointBehaviour "AWARE";

 

 

EDIT:

Updated in next post.

Edited by Maff
Update.

Share this post


Link to post
Share on other sites

@wogz187

 

Thanks, I removed the pilot and copilot's names and used the string but it still just hovers there. The only thing I changed this time was marker names to the ones I used and it accepted it and let me save it into the trigges ON ACTIVATION init.

 

The code as is. exactly how it is in the editor. The only thing that still has a name are the markers and the helicopter itself. Named H1

heliGroup= group Heli1d; 
randomPoint= selectRandom ["Marker1", "Marker2", "Marker3", "Marker4"]; 
 
_wp = heliGroup addWaypoint [getmarkerpos "randomPoint", 0]; 
_wp setwaypointtype "MOVE"; 
_wp setWaypointSpeed "NORMAL"; 
heliGroup setBehaviour "Aware";

 

Share this post


Link to post
Share on other sites

Ah, you're running it from a trigger.

 

Spoiler

heliGroup = group H1;
randomPoint = selectRandom ["marker1", "marker2", "marker3"];

wp = heliGroup addWaypoint [markerPos randomPoint, 0];
wp setwaypointtype "MOVE";
wp setWaypointSpeed "NORMAL";
wp setWaypointBehaviour "AWARE";

 

 

Updated helicopter name and switched to global variables.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

@Maff,

Quote

Line 1 of the linked sqf is throwing error.

Yeah. I only uploaded an sqf because that's what I have on my desktop. It was intended to be copied into a trigger.

Share this post


Link to post
Share on other sites

@wogz187 @Maff

 

I finally got it to work, thanks guys!

I'm pretty certain I can figure out how to add waypoint expressions on there on my own to make it to where they can still rappel down instead of having to switch to landing. Goodnight the both of you!

  • Like 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

×