Jump to content
zagor64bz

What's wrong with this script?

Recommended Posts

I'm trying to put together this snippet for having my AI pilot return to base:..so far this is what I've got:

IF ((Gunner (vehicle player)) == player) THEN {

	Driver (vehicle player) doMove (getMarkerPos "land01");
	sleep 10;
	  waitUntil{(unitReady (Driver (vehicle player)))}; 
	sleep .1;
	Driver (vehicle player) flyInHeight 10;
	sleep .1;
	Driver (vehicle player) doMove (getMarkerPos "land02");
	sleep .1;
	  waitUntil{(unitReady Driver (vehicle player))}; 
	sleep 1;
	Driver (vehicle player) land "LAND";
	sleep 3;
	if ((player distance getPos Airbase01) < 200) THEN {
	commandGetOut Driver (vehicle player); 
};

Not working...What's wrong with this?

Share this post


Link to post
Share on other sites

Zag,

What do you mean by it's not working?

Check out how Chad's flight path works in FTA,
This gives him 12 waypoints on 2 paths (6 each), however we can break him out and send him to any other marker or start on a marker out of order at any time. One quick little side script and he would break the pattern and land at an airport (like the wounded bird in JET TOYS). Each of the waypoints  can also have different flight conditions for speed, alt asl and agl.

On top of all that it's easy to just move the marker points (setpos) to establish even MORE paths using just these markers.

The FTA modules are almost finished. I've got a blue marker for you with an airport in it. 😉

 

Spoiler

fnc_chadPATH =
{

    if (chadID==1) exitWith
    {
        pathID = pathID + 1;
    currentPATH = [objNULL, chad1_1, chad1_2, chad1_3, chad1_4, chad1_5, chad1_6] select pathID;
    chadgroup = group chadPLANEd;
    chadgroup setGroupId ["Chad"];
    deleteWaypoint [chadgroup, 0];
sleep 0.5;
    chadDEST setpos (getpos currentPATH);
    chadWP = chadgroup addWaypoint [(getPos currentPATH), 0];
    chadWP setWaypointType "move";

        if (pathID == 6) then {
        pathID = 0;
        };
};
    if (chadID==2) exitWith
    {
        pathID = pathID + 1;
    currentPATH = [objNULL, chad2_1, chad2_2, chad2_3, chad2_4, chad2_5, chad2_6] select pathID;

    chadgroup = group chadPLANEd;
    chadgroup setGroupId ["Chad"];
    deleteWaypoint [chadgroup, 0];
sleep 0.5;
    chadDEST setpos (getpos currentPATH);
    chadWP = chadgroup addWaypoint [(getPos currentPATH), 0];
    chadWP setWaypointType "move";

        if (pathID == 6) then {
        pathID = 0;
        };
    };
};

 


Have fun!

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, wogz187 said:

Zag,

What do you mean by it's not working?

The AI pilot it's not following the command and not RTB. Looking at your script (which is already a bit complicated for my old brain,LOL) it may have to do with cancel waypoints or something...:headscratch:

Share this post


Link to post
Share on other sites

I misunderstood the original question. Just use a Get Out way point. Not "LAND" or anything like that. Just make one, simple Get Out way point.

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, zagor64bz said:

Not working...What's wrong with this?

 

You are missing };

Spoiler

IF ((Gunner (vehicle player)) == player) THEN
{

	Driver (vehicle player) doMove (getMarkerPos "land01");
	sleep 10;
	  waitUntil{(unitReady (Driver (vehicle player)))}; 
	sleep .1;
	Driver (vehicle player) flyInHeight 10;
	sleep .1;
	Driver (vehicle player) doMove (getMarkerPos "land02");
	sleep .1;
	  waitUntil{(unitReady Driver (vehicle player))}; 
	sleep 1;
	Driver (vehicle player) land "LAND";
	sleep 3;
	if ((player distance getPos Airbase01) < 200) THEN
	{
		commandGetOut Driver (vehicle player); 
	};	//	Missing bracket - Fixed.
};

 

 

I'm not 100% sure what the big picture is but there is an easier solution.

Spoiler

//	An array of instructions.
//	markerPos _x #0
//	waypointType _x #1

_orders = [ ["land01", "MOVE"], ["land02", "GETOUT"] ];

_pilot = driver vehicle player;
_pilot flyInHeight 10;

{
	_wp = group _pilot addWaypoint [markerPos (_x #0), 0];
    _wp setWaypointType (_x #1);
} forEach _orders;

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites
8 hours ago, Maff said:

You are missing };

IT WORKS NOW, THANK YOU!!

 

8 hours ago, Maff said:

I'm not 100% sure what the big picture is

Basically I'm putting together an SP mission where you are on duty as CAS pilot/gunner. We all know how AI pilots have a bad tendency to screw things up just when you need them to cill out and stay put.

So I'm making some scripted commands to "control" the pilot, in case you are the gunner.

 

-Raise altitude

-Lower altitude

-Keep altitude

-Face target

- Move there (open map)

-land there

-RTB

 

I have 2 "version" of the mission..one is base on a land airport, the other one, on board of the Carrier.

While most of the scripts work ok on land, some have to be adapted for the notorious deck issues.

For instance, I had to make some changes on this little snippet for it to work properly:

[Driver (vehicle player)] joinSilent (group player); // added this because sometime AI would not obey until he finish whatever he was doing.
vehicle player vehiclechat "ROGER...we're RTB!!"; //movet this on top, since he would show only once at the base
IF ((Gunner (vehicle player)) == player) THEN {
	
	Driver (vehicle player) doMove (getMarkerPos "land01");
	sleep 10;
	  waitUntil{(unitReady (Driver (vehicle player)))}; 
	sleep .1;
	Driver (vehicle player) flyInHeight 10;
	sleep .1;
	Driver (vehicle player) doMove (getPosASL LANDPOS); // had to use getPosASL and an object and not a marker, since it seam to "see" it better
	sleep .1;
	  waitUntil{(unitReady Driver (vehicle player))}; 
	sleep 1;
	vehicle player land "LAND";
	sleep 3;
	if ((player distance getPosASL BIGMAMA) < 100) THEN {
	commandGetOut Driver (vehicle player); 
	};
};

Now it works as intended.

 

8 hours ago, Maff said:

but there is an easier solution.

That's nice to know..thank you.

  • Like 2

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

×