Jump to content
Sign in to follow this  
scajolly

TANK teleport

Recommended Posts

Alright, I've searched the forum! Finally I can ask the question! :yay:

I have an armada of player-occupied tanks I need to teleport in an MP. Preferably, I'd like to use the standard flag Add-method where you're given the option to jump around to another base. Weasel or someone I think made those. But those aren't compatible with vehicles. I can't get the option when in the tank and next to the flag, anway.

IS THERE a way to transport a full vehicle and its crew, to a new location?

Preferably done with triggers/objects instead of markers (getmarker isn't as flexible etc).

Problem

For a large number of vehicles in an MP mission, how do you teleport them and their crew to an object? (Or a marker, but I went for object here)

The Solution

Make a flag. It's not important to use a flag, because the command will be called within the area of a trigger. I just want to use a flag because then it can double as a troop-teleporter through other scripts. In the Init, put

this allowdamage false;{_x addAction ["Teleport to FOB", "teleportvehicle.sqf", [<name here>],1,false, true, "action", "_target in list trigger1"]} forEach vehicles

First we make sure the flagpole won't be killed by anything.

Then we call addAction for every vehicle on the map: {_x (code) }forEach vehicles).

<name here> is the object we want to teleport to.

For information on AddAction syntax, go here.

The rest of it is only semi-well understood by me, but here's an important part:

If you want to be able to teleport at all times in this vehicle, replace

"_target in list trigger1"
with

"driver _target == player"
, or nothing at all.

This will call the init as soon as the driver is the player, meaning only the driver will spawn the addAction.

Now, create trigger1, a trigger set to activate on your preferred side, repeatedly, condition "this". This will make the teleport function within that trigger. Put the trigger on top of the flag in order to mimic the addAction belonging to the flag.

In the mission folder, make an sqf file called "teleportvehicle".

// this is the destination. select 3 is called in AddAction's script

_dest = (_this select 3) select 0;

// random direction

_dir = random 359;

// places the player's vehicle at _dest's position, at a random place as a function of -20*sin/cos(_dir)

vehicle player SetPos [(getPos _dest select 0)-20*sin(_dir),(getPos _dest select 1)-20*cos(_dir)];

Edited by SCAJolly

Share this post


Link to post
Share on other sites

All you need to do is "<vehicle> setPos <pos>."

If you don't have the name of the vehicle, but you do have the name of one of the crew members, do "vehicle <crewMember> setPos <pos>."

Share this post


Link to post
Share on other sites

Thank you, but there remains a problem!

I don't know how to make an addAction for a crewmember in a vehicle.

I tried to make a radio alpha-trigger (I'd prefer to avoid this. An action would be much better). It called

_teleportvehicle = player execVM "scripts\teleportvehicle.sqf";

teleportvehicle.sqf looks like this:

_dir = random 359;

vehicle player SetPos [(getmarkerPos FOB select 0)-25*sin(_dir),(getmarkerPos FOB select 1)-25*cos(_dir)];

This acheives nothing. I sit in a vehicle, drive up to the trigger, radio alpha, and nothing happes. :confused:

---------- Post added at 12:49 PM ---------- Previous post was at 12:18 PM ----------

In addition, I tried a cruder method. A trigger with radio bravo reads

On activation:

vehicle player SetPos [(getmarkerPos FOB select 0)-5*cos(getdir player),(getmarkerPos FOB select 1)-5*cos(getdir player)];

Although FOB has been both a default marker and, later, an ellipse marker very near, I always get sent to the middle of the ocean. :confused:

Problems with this approach are, besides not teleporting to the place I WANT to:

1) An action related to a flag or other object would be better than a radio call.

2) If a radio call must be used, I want the radio to be accessible only to those INSIDE the trigger area.

So far I've devised a trigger that reads

On Activation:

vehicle player SetPos [(getPos FOBflag select 0)-25*cos(random 359),(getPos FOBflag select 1)-25*cos(random 359)];

This seems to work well enough when FOBflag is a flag or trigger. However, the problem remains that I'd like the radio to be restricted. (otherwise you can just teleport at any time, which is shit for 'realistic' MP)

Edited by SCAJolly

Share this post


Link to post
Share on other sites

Your first example achieves nothing because marker names are string values. You would need to do getMarkerPos "FOB", not getMarkerPos FOB.

As for using an addAction, you can't really give a unit an addAction while the unit is in a vehicle, but you can give the vehicle itself an addAction that can only be used when the player is in the vehicle. To achieve this, use the condition parameter of the addAction call (see Biki for syntax). You can also use the condition parameter to make the action unavailable when the player is outside of the trigger area. Just name the trigger, make it repeatedly-activated, and make sure that the player meets the trigger conditions. Then use this for your addAction condition:

"player in <vehicleName> && player in list <triggerName>"

Share this post


Link to post
Share on other sites

Fantastic, thanks for that =) It seems to work very well now, I am truly thankful!

One question remains about the syntax: It states, "shortcut: String - (optional, default:"") One of the key names defined in bin.pbo (e.g. "moveForward")"

Does it matter at all which of these I use? Indeed, do they do anything?

Oh god, no sooner had I posted than I realized I messed up. I called

teleportout = BERIA addAction ["Teleport to FOB", "scripts\teleportvehicle.sqf", [],1,false, true, "teamSwitchPrev", "driver _target == player"];

This allows only thee vehicle called Beria to be transported. "vehicle player" in its place does me no good. :| Is there hope for me yet? I thought surely vehicle player would do the trick?

Edited by SCAJolly

Share this post


Link to post
Share on other sites

"vehicle player" will only return the vehicle that player is currently in. If the player doesn't start off in a vehicle, it will return the player. To add the action for every vehicle in the mission, use this:

{_x addAction ["Teleport to FOB",etc....]} forEach vehicles

"vehicles" is a script command that returns every vehicle in the mission (but not units).

Share this post


Link to post
Share on other sites
"vehicle player" will only return the vehicle that player is currently in. If the player doesn't start off in a vehicle, it will return the player. To add the action for every vehicle in the mission, use this:

{_x addAction ["Teleport to FOB",etc....]} forEach vehicles

"vehicles" is a script command that returns every vehicle in the mission (but not units).

I say, splendid! That's quite the amount of knowledge you've got there. This'll come right in handy. I'll post the summarized results up at the top.

It seems that problems are added for each solution. {_x } foreach vehicles calls this addaction to ALL vehicles. Therefore, we must use a condition in order that not everyone can teleport at any time.

"driver _target == player AND player in list <trigger near flag>" does not work. "player in list" alone does not suffice either, and seems to not compute. The action is never made possible.

The solution is "_target in list <trigger>

BWUAAHAHA IT FINALLY BLOODY WORKS

(also don't use teamswitchprev, that'll lead to hilariously bad consequences)

Edited by SCAJolly

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  

×