Jump to content
Sign in to follow this  
mcnools

Teleport any unit using an object (With Ace menu?)

Recommended Posts

EDIT: sorry for bumping this but I figured it's better than creating a whole new topic. I managed to get this working using TheDoor addAction ["Beam me scotty", {(_this select 1) setPosATL (_this select 3);}, getPosATL trainstation];

But now I'd like to be able to add the action as an ace-interaction rather than an addaction (OR if this is too complex, try to limit the radious the action can be used in, I'd like to have to walk up very close to the object to use it, like pressing a button/opening a door), with the current script I can activate it several metres away. I've tried to read up on how to create ace actions but I just can't figured it out. Does anyone with experience have an ideas? (oh, and it have to work on dedicated servers).

 

Long story short: I want to be able to interact with a tunnel entrance using the ACE MENU to teleport the person who interacts with it to another position (in a tunnel somewhere else), on a dedicated server.

 

 

 

Old post:

Hello, I'm making a bit of a fun mission for my group where we are supposed to enter an underwater door to reach a secret underground train station which will in turn lead to a top secret base at a volcano where we will enter a secret missile silo through a bunker door (no Mr. Bond, I expect you to die). Haha. Anyway, in order for us to do this I need a script that teleports any unit using an object (in this case, bunker-doors).

 

Now, I've managed to get a simple teleport-script working when entering a trigger (a repeatable trigger with blufor as activate and "{_x setPosATL getPosATL trainstation} forEach thisList" as "on activation"), it works fine (teleports you to the object called trainstation), but I need to be able to use this with the addaction command. Adding an action on the objects (large bunkers with doors) that activate a script that teleports the specific unit that used the action to the new location. Is there any way to do this in a somewhat simple way?

Share this post


Link to post
Share on other sites

Hey McNools - it's pretty straightforward approach:

 

In the object you want to have the scroll wheel action (Similar to Open Door) place the following code in the init:  

this addAction ["Enter Nuclear Bunker", {player setPos (getPos object)}]

Replace the "object" with the name of the object with the object to where the player will be teleported to.  Alternatively if you want to teleport them to a marker position, you can do it as such:  

this addAction ["Enter Nuclear Bunker", {player setPos (getMarkerPos "markername")}]

Hope this helps!

Share this post


Link to post
Share on other sites

Assuming you somehow have a reference to the door in TheDoor, you can do this. Or if the door is an object you put it, put this in its init.

 

TheDoor addAction ["Beam me scotty", {(_this select 1) setPosATL (_this select 3);}, getPosATL trainstation];

  • Like 1

Share this post


Link to post
Share on other sites

FINAL EDIT: Muzzleflash's method seems to work! (guessing because it has the setPosATL-part defining the altitude). I just added "TheDoor addAction ["Beam me scotty", {(_this select 1) setPosATL (_this select 3);}, getPosATL trainstation];" to a bunker-object called "TheDoor" (can be called anything I suppose) and placed an invisible object called "trainstation" at the teleportation destination. Works fine even if the destination is way above ground-level, thanks!

Now I can really got to town with this absurd mission, haha.

 

 

 

TheGeneral2899: thanks for the reply, will try this! Just to make sure, this will work for any of the players in MP as well and not just a single player-character in SP?

 

EDIT: Seems to be working in SP at least (will have to test with multiple players later). HOWEVER, since the place I need to teleport is not at ground level (inside a structure) there's a problem, I teleport to the objects position but on ground level rather than the level of the object itself.

 

EDIT AGAIN: Ah, nevermind! the object was too close to the floor, if I put it up in the air it works fine it seems. I'll just make it invisible.

EDIT AGAIN (AGAIN): Argh, no! It worked on the first two teleport (into the secret underground tunnel and then from the tunnel to the volcanic lair), but not into the missile silo (maybe because the missile silo is a modded structure and doesn work the same way?). In the first two I teleport about half a metre up in the air, but teleporting to or from the bunker I end up inside structures at ground level.

 

I'm hoping there's a way to set the destination altitude to the same as the destination objects and not just the long/lat coordinates of that object?

Share this post


Link to post
Share on other sites

@mcnools - I use this for a training map I designed for my squad to allow them to teleport to different training areas.  Works like a charm and keeps it very very simple.

 

I wasn't at home, but here is the exact code I used:

0 = this addaction ["Start Area",{(_this select 1) setpos (markerpos "homebase")}];

 

  • Like 1

Share this post


Link to post
Share on other sites

I updated the first post with another question, I would like to be able to do this teleporting (Muzzleflash's script a couple of posts up) using the ace-interaction menu instead, OR having to be very very close to the object to use it. I hope bumping the topic rather than creating an entire new one is better.

Share this post


Link to post
Share on other sites

Harzach: I've tried reading that but honestly I don't understand any of it whatsoever.  I figure fnc_addActionToObject is what I want to use but I don't know where to put it and how etc. Coding/scripting just never made sense in my illogical brain.

 

Perhaps it would be easier to modify the addaction-script I've mentioned in the original post to include a variable for distance (so that you have to be, say.. 1 metre from the object to get the action?), I've read in the wiki about addaction that there's such a parameter but I haven't managed to figure out how to add it to the script.

 

Edit: after seemingly trying the same thing again (must have missed something last time) I managed to incorporate a radious to the addaction command, I'd still prefer to do it with an ace-action so I'd love some help with that, but here's the script for the addaction with a limited radious (2 metres) for anyone interested:

 

Quote

this addAction["Enter tunnel",{(_this select 1) setPosATL (_this select 3);},getPosATL tunnel1,6,true,true,"","true",1,false,""];

(I put this on an object that will serve as the tunnel entrance, then I put a helper-object of some kind where I want the player to end up and name it "tunnel1", haven't tested in dedicated yet but I suppose it should work).

Share this post


Link to post
Share on other sites

For an ACE action there are two things we must do.

  1. Create the action (ace_interact_menu_fnc_createAction)
  2. Add the action to the object (ace_interact_menu_fnc_addActionToObject)

Here, we create the action:

mcn_action = ["mcn_teleport","Beam me scotty","",{_player setPosATL (getPosATL trainstation);},{true}] call ace_interact_menu_fnc_createAction;  

mcn_action is the action's tag/variable name. I don't know if you have chosen a tag for yourself, so I used "mcn".

mcn_teleport is the name of the action. We can reference this if we want to add a sub-action (multiple teleport locations, for example). It can be any string.

Beam me scotty is the text that is displayed in the HUD. Any string.

"" - We could use a custom icon, but we aren't, so this element is left empty.

_player setPosATL (getPosATL trainstation); is our code (_player is passed in both statement and condition, which is why it works here).

true is our condition. It is always "true" so the action is always available as long as the we allow it to exist.

 

Now, we add it to our object:

[TheDoor,0,["ACE_MainActions"],mcn_action] call ace_interact_menu_fnc_addActionToObject;

TheDoor is the object the action is attached to.

0 designates it as an action, as opposed to a self-action (1).

ACE_MainActions designates where in the ACE  interaction menu the action will appear. Here, it is at the top layer.

mcn_action again is the variable name of the action we are adding.

 

So, add this to the init field of your object named TheDoor:

mcn_action = ["mcn_teleport","Beam me scotty","",{_player setPosATL (getPosATL trainstation);},{true}] call ace_interact_menu_fnc_createAction;  
[TheDoor,0,["ACE_MainActions"],mcn_action] call ace_interact_menu_fnc_addActionToObject;

Tested local and dedi.

  • Thanks 1

Share this post


Link to post
Share on other sites

EDIT:  Nevermind , Harzach updated his post and the code is now working!

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  

×