Jump to content
Sign in to follow this  
A-SUICIDAL

Teleport to Team Leader

Recommended Posts

I have a flagpole at base that offers the ability to teleport to Leader (s1). This is the script so far...

_unit = _this select 1;
_unit setPosATL [ getPosATL s1 select 0, (getPosATL s1 select 1) -4, getPosATL s1 select 2];

Now here's my problem...

We have a truck at base which is the only vehicle our team has access to. It's basically our MHQ vehicle. I even have Kylania's load ammo script working for the truck. Now if somebody were to walk up to the flagpole and choose "Teleport to Leader" and the leader is currently driving or riding in cargo, what I would like to do is have the teleporting player then be moved into cargo so he or she is not left standing in the open next to the moving truck. This is what I was trying to do but I can't seem to get it working correctly...

_unit = _this select 1;

if ( ? vehicle s1 != s1 ) then {

_unit moveInCargo MHQ;

} else {

_unit setPosATL [ getPosATL s1 select 0, (getPosATL s1 select 1) -4, getPosATL s1 select 2];

};

so basically.. if the leader is in a vehicle, then teleport into cargo, but if he is not in the vehicle, then teleport standing near the leader.

Lastly, and this is really important but I'm not sure if it can be made possible... when the player teleports to the leader when the leader is not in a vehicle, would there be a way to get the direction that the leader is facing and teleport the player behind the leader about 2 meters and set the players stance to prone. This way if the leader is already prone peaking over a hilltop at multiple enemy, the player would not be teleported standing in front of the leader in plain sight of all the enemy. Any help with this would be much appreciated.

---------- Post added at 10:36 PM ---------- Previous post was at 09:10 PM ----------

omg, I tried scripting this at least 30 different ways and then finally got it to work.

_unit = _this select 1;

if ( vehicle s1 != s1) then {

_unit moveInCargo MHQ;

} else {

if ( vehicle s1 == s1) then {

_unit setPosATL [ getPosATL s1 select 0, (getPosATL s1 select 1) -4, getPosATL s1 select 2];

};
};

so now the player teleports into cargo of the MHQ truck if the leader(s1) is in the truck, and if the leader hops out, the player would instead teleport standing near the leader.

Now I only need to figure out how to get the direction the leader is facing and teleport the player 2 feet behind the leader facing the same direction, which I don't think is possible. And setting the player to a prone position probably won't be possible either. But if anybody knows how to do this, please help me with it.

Share this post


Link to post
Share on other sites

Place the Functions Module on map first.

_dir = getDir s1; 
_newPos = [s1, -2, _dir] call BIS_fnc_relPos; 
_unit setdir _dir; 
_unit setPos _newPos;

Share this post


Link to post
Share on other sites

this worked too...

_unit setDir direction s1;

it definitely placed the player facing the same direction as s1, but it seemed to place the player behind and to the right a little. I kind of want him directly behind s1 if I can. Oh, and I stumbled on it when I was goofing around - trial and error guessing. I had no idea it would actually work, but it did.

I'll try what you just said.

How can I switch him to a lying down prone position?

---------- Post added at 11:55 PM ---------- Previous post was at 11:39 PM ----------

The reason why I used ATL was because... if s1 was on a rooftop, players would teleport to ground level below him. with the ATL it then teleported to the same height.

---------- Post added at 01:12 AM ---------- Previous post was Yesterday at 11:55 PM ----------

yeah, if I use "call BIS_fnc_relPos" it won't teleport me up onto to the roof that s1 is on. When I just tested, it teleported me inside of the building directly below s1 and there was no door that could be opened to get out, so I had to suicide and respawn at base. So I kind of need ATL to prevent that.

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

You could try using modelToWorld but I don't think that uses ATL either. Maybe check the ATL select 2 value of S1 and setPosATL them after the move? Or just tell players to A) don't teleport onto roofs or B) climb the stairs. :)

Share this post


Link to post
Share on other sites

Hmm, I'm not so sure how to use modelToWorld, and when you said... Maybe check the ATL select 2 value of S1 and setPosATL them after the move? I'm not so sure how to do that either. So far, this is what I have...

_unit = _this select 1;
if ( vehicle s1 != s1) then {
   _unit moveInCargo MHQ;
} else {
if ( vehicle s1 == s1) then {
   _unit setDir direction s1;
   _unit setUnitPos "DOWN"; 
   _unit setPosATL [ getPosATL s1 select 0, (getPosATL s1 select 1) - 2, getPosATL s1 select 2]
};
};

but "_unit setUnitPos "DOWN" doesn't seem to work on humans, and I have AI disabled in the coop mission, and even when I enable the AI and tell them to use the flagpole action, they run over to the pole and try to perform the action, but nothing happens.

Share this post


Link to post
Share on other sites

It's been a while, but I decided to use this script again in another mission that I'm working on. This is the script I am currently using:

_unit = _this select 1;
if ( !alive s1) then {
   hint "The Leader is currently dead";
} else {
if ( vehicle s1 != s1) then {
   _unit moveInCargo MHQ;
} else {
if ( vehicle s1 == s1) then {
   _unit setDir direction s1; 
   _unit setPosATL [ getPosATL s1 select 0, (getPosATL s1 select 1) - 1, getPosATL s1 select 2]
};
};
};

This script was designed to work with a 14 man coop mission that uses only 1 transport vehicle named "MHQ" (either a Blackhawk or a Ural UNO truck since they can both hold 14 soldiers in cargo). What I would like to do is use the script in some missions that have more than 1 vehicle and have the script check to see if there is enough room in the vehicle when players choose to teleport to the leader when the leader is in a vehicle. So if the leader is flying a Littlebird and the passenger seat is full, the player that chooses "Teleport to Leader" at the base flag pole will receive a message that says, "The leaders vehicle cargo is currently full", or something like that.

The script I'm using now is set up to work with 1 vehicle called "MHQ".

I was hoping that somebody could help me get this script working so it could work with all vehicles that the leader is in and have the script check to see if there is room in the vehicle and if there is, then teleport the player into the vehicle, and if there are no available seats, then the player would receive a hint letting them know that the vehicle is currently full.

It would be a great script to use in missions that have a multiple vehicles of different capacities and more than 14 players. Hell, it would be a great script to add to any mission, giving the game that BF2 spawn on leader ability, only it would be a teleport to leader from base option instead. If only I could just get it set up correctly. Any help with this would be much appreciated.

Edited by A-SUICIDAL

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  

×