Forum Jump :

Author Message


Posts: 6
Rank:


Level: Member

Country: lt
Location: Vilnius
Occupation: Linux Admin
Age: 45
In-game name:

 
#1 Posted at 2018-05-09 09:52        
     
Hello everyone.
I have been trying for days now to simply get a helo to goto a specified location and land there. I have followed multiple posts from armaholic, BI forums, Youtube and redit and nothing seems to have worked for me. Its been a very frustrating couple of days. First off, I am a total newcomer to arma scripting. I have successfully implemented some scripts here and there for a private single-player mission just for me to have some fun by myself.

What i want to do, is using an addaction i have created for a specific helo, once clicked, to return to a set of coords and land there. some info:
    The AI in the helo (pilots) are grouped to player (team green);
    The helo has a global variable named transport;
    As you will see in a moment in the code snippet i have, i have setup hints and they all show up one by one, but the helo just sits there and does nothing. (Except that in the helo options once i choose the group green, a next waypoint option appears, but also does nothing;

I am not really interested in becoming a scripter (at least not yet at this point). The only thing i want to be able to do right now is to choose my RTB (Return to Base) addaction, and have the Helo go to the coords and land there and turn off it's engines (Hence land "LAND".
Please, no solutions with fuel 0, get in, get outs. Just a simple landing at the end with turning engines off. But for now, at least lets get the helo to actually move and go to that position, and later (if it does not work landing), i will solve that part.

Script: RTB.sqf
_heli = _this select 3;

_wp1 = (group _heli) addWaypoint [[12239.6,12635.7,0], 50];	
hint "Added waypoint";
sleep 3;																		
_wp1 setWaypointType "MOVE";
hint "Move waypoint";
sleep 3;																					
_wp1 setWaypointBehaviour "CARELESS";
hint "Be careless";
sleep 3;																			
_wp1 setWaypointStatements ["true", "(vehicle this) land 'LAND'"];
hint "land";
sleep 3;
//// [b]Notice:[/b] I have only added the sleep 3 in order to be able to catch the hints if they are at least working, which they are!

Trigger in eden:

soldier addAction ["RTB", "RTB.sqf", transport, 0, false, false]; //soldier is the global var that my player has in its variable field, needed for other addactions that i have and they work.

So basically when i click on RTB in my addaction option in-game, the helo just sits there and does nothing.
Let me please point out again that the AIs (pilots) in question are grouped to team green which are linked to my player so that i can control them for other stuff.

Can someone help me correct the script please?

Regards,
Bastian.


Author Message


Posts: 1526
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2018-05-09 14:36        
     
Seems to be fine here when player and is not part of the group.
Could you explain this bit in more detail AIs (pilots) in question are grouped to team green which are linked to my player

As for landing you need another waypoint right after the landWP very close to it so that it won't bother to fly there
_wp2 = (group _heli) addWaypoint [[12239.6,12635.7,0], 0];
_wp2 setWaypointStatements ["isTouchingGround (vehicle this) ", "(vehicle this) engineOn false ;systemchat 'engines off'"];
As long as you have no more wp's it should stay on the ground if you do need to have more wp's you will need the next wp to be locked and also close to the heli.

One other thing make sure [12239.6,12635.7,0] is a valid position on the map or it won't attempt to fly to it.

This post was edited by F2kSel (2018-05-09 14:49, 935 days ago)


Advertisement


Author Message


Posts: 6
Rank:


Level: Member

Country: lt
Location: Vilnius
Occupation: Linux Admin
Age: 45
In-game name:

 
#3 Posted at 2018-05-09 14:52        
     
# F2kSel : Seems to be fine here when player and is not part of the group.
Could you explain this bit in more detail AIs (pilots) in question are grouped to team green which are linked to my player

As for landing you need another waypoint right after the landWP very close to it so that it won't bother to fly there
_wp2 = (group _heli) addWaypoint [[12239.6,12635.7,0], 0];
_wp2 setWaypointStatements ["isTouchingGround (vehicle this) ", "(vehicle this) engineOn false ;systemchat 'engines off'"];

One other thing make sure [12239.6,12635.7,0] is a valid position on the map or it won't attempt to fly to it.

Hi F2kSel, thank you for your reply.
1 - Ai Pilot in group green: When i place the units down in Eden, i place a player (me), and i place several other units down near me and link them to me (i'm group/team leader of these AIs). 2 of them are pilots, so that i can command them ingame, like make them get vehicles, regroup, go there, etc etc. As for the pilots of the transport, i select them ingame (with F5 + F6 and team them to team green (so that later iu can easily select both ingame with SHIFT+F3 (which is team Green)).
The reason that i mentioned that is because i got a script working with AI pilots if they are not directly under my control ingame, but with AIs that are under my control, that script did not work at all.

Now about the landing, this is not my issue yet (havent even gotten that far), I place the helo and its pilots via eden on the ground away from the base/helipad) and when i select RTB from my addaction menu, it doesnt even start to go to the location (yes, the coords are accurate, i got them from eden from log-coords). The chopper doesnt even turn on it's engines when i click on RTB (however, i would like it to work regardless if the engines are on or off at the start).

Basicly all i want is for the darn chopper to liftoff and go to those coords. Once there i have several landing script-snippets that i can customize depending on what sort of landing i want.

Thank you for your script examples, I will try them out right now and see how it works out, but in general my problem seems to be not about landing, but just about getting the chopper to actually just go to the coords from it's current location on the map (which is random).

I will let you know how it turns out once i try your advice,
Cheers.

Bastian.


Author Message


Posts: 1526
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2018-05-09 16:50        
     
I don't think there's a way to give waypoints to other members of the group they always go to the player.
You may need to remove them from the group while they're flying and add them back later when needed or just use domove and waituntil with distance checks to simulate WP's.

I just checked you can do this using editor placed waypoints so I see no reason for it not to work when scripted. I'll take another look when I get back later.

This post was edited by F2kSel (2018-05-09 16:56, 935 days ago)


Author Message


Posts: 6
Rank:


Level: Member

Country: lt
Location: Vilnius
Occupation: Linux Admin
Age: 45
In-game name:

 
#5 Posted at 2018-05-09 18:03        
     
Hi again, and thanks for helping me out.

Unfortunately I am unable to test this now, my wife is nagging that I'm infront of the PC again :-(
I will try your suggestions in the morning and report back here.

Thank you again.
Bastian.


Author Message


Posts: 1526
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2018-05-09 20:59        
     
here's a simple sample script that will move a chopper to a gamelogic RTB or your location coordinates


//soldier addAction ["RTB", "RTB.sqf", transport, 0, false, false];
     _heli = _this select 3;
     
      driver _heli domove getpos rtb;// [12239.6,12635.7,0]
      hint "Move To RTB";
      _heli setbehaviour "careless";
    
      waituntil {_heli distance rtb <100};
      hint "landing";
      _heli land "land"; 
    
      waituntil {istouchingground _heli};
      hint "landed enigine off";
     _heli engineon false;


Author Message


Posts: 6
Rank:


Level: Member

Country: lt
Location: Vilnius
Occupation: Linux Admin
Age: 45
In-game name:

 
#7 Posted at 2018-05-10 08:43        
     
Good morning F2kSel.

Thanks to part of your code i finally got it working like a charm :)
However i had to edit it a bit, because everytime the Helo touched down (regardless of your engineone part of the code, the helo would touchdown and at once liftoff again. So as a way around that i edited the code to the following and it works perfect now:
_heli = _this select 3;
_unit = _this select 0;
_unit sidechat "Transport 1, return to base!";
sleep 2;
_heli sidechat "Roger that";
driver _heli domove getpos home;
_heli setbehaviour "careless";
waituntil {_heli distance home <200};
dostop _heli;
while {(count (waypoints group _heli)) > 0} do
{
 deleteWaypoint ((waypoints group _heli) select 0);
};
waypoint1 = (group _heli) addwaypoint [getpos _heli,0];
_heli land "LAND";
sleep 10;
_heli sidechat "Transport has returned to base";

Also it didnt like the coords (some error about array bla bla), so i set a logic and named it home.
I would not have managed without your help, thank you so much. Now finally after 4 days i can actually sit down and play for a change :p

Best regards,
Bastian.


Author Message


Posts: 1526
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#8 Posted at 2018-05-10 12:39        
     
istouching works fine for me but using the scripted moves as I posted also worked until I wanted to move it again a second time
but this time it always took off again.

Choppers have always been a bit strange.

this should have worked I bet you left the getpos in the command.
driver _heli domove [12239.6,12635.7,0];