Jump to content
csepi0101

TELEPORT ACROSS BRIDGES

Recommended Posts

----------------------------------------------------------------------------------------------------------------------------------------------------------------

UPDATE: SOLVED

thanks for beno_83au  (+pierreMGI)

 

-THE SIMPLE ANSWER IS:

{ (vehicle _x) setPos [6447,4788,0]; } forEach thisList;   (write into the trigger activation field,this numbers [6447,4788,0] is (your custom) coordinate of respawn on map,but when several units arrive at the same time they teleport into each other = gigantic explosion)

 

OR WITH SIMPLE _X

{  _x setPos [6447,4788,0]; } forEach thisList;                        

 

 

 

-THE BEST ANSWER IS WITH + RANDOM VALUES BETWEEN 5 AND 10 TO COORDINATES: (by adding a random value to the coordinates, the units in same time already fit side by side)

 

{(vehicle _x) setPos ([6447,4788,0] getPos [5 + random 10, random 360])} forEach thisList;   

 

OR WITH SIMPLE _X

{ _x setPos ([6447,4788,0] getPos [5 + random 10, random 360])} forEach thisList;

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

original question:

vehicle player setposatl [6447,4788,0];

 

This works with trigger for player but not for ALLSIDE ALL AI units.
what is the f.. g magic word instead of VEHICLE PLAYER?(allunits,unit...not works)
thanks

(I’ve been out of the game for 2 or 3 hours and  looking for this simple thing ever since.....

Baranow map nr6,russian soldiers ,trucks,swimming in the river)

 

Share this post


Link to post
Share on other sites

If you want to teleport multiple units you will need some kind of loop. SetPosATL can only work with 1 unit at a time. I would recommend the forEach loop, specifically, for this; but any of them could be used as long as you understand the syntax

 

Also you will have a problem if you are trying to move both vehicles and soldiers to the same spot, soldiers can be moved without issue, they will just push each other out of the way without getting hurt; but vehicles will explode when you move multiple to the same spot

  • Like 2

Share this post


Link to post
Share on other sites

This is one of those situations where being more descriptive would be beneficial.

  • Like 3

Share this post


Link to post
Share on other sites

"cant we live in a world where not Teleportation be needed to cross a bridge...??" ~ Kierkegaard

  • Like 1
  • Haha 3

Share this post


Link to post
Share on other sites

Place a small rock on the map.  Name it   rock1

 

Name yourself blue1

 

Walk into a trigger area with the command     blue1 setpos  getpos rock1   and you are teleported to the rock

 

Write a separate command for each unit.

Share this post


Link to post
Share on other sites
2 hours ago, Harzach said:

This is one of those situations where being more descriptive would be beneficial.

Most situations are one of those situations 😛 I answered the best I can with what I was given

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Harzach said:

This is one of those situations where being more descriptive would be beneficial.

After reading OPs post a second time I guess he wants to have a trigger which teleports each unit and each vehicle which is in trigger area to the given position.

  • Like 1

Share this post


Link to post
Share on other sites
42 minutes ago, sarogahtyp said:

After reading OPs post a second time I guess he wants to have a trigger which teleports each unit and each vehicle which is in trigger area to the given position.

 

Yeah sounds like it. I guess something like a repeating trigger for ANYBODY using:

{
	(vehicle _x) setPos [6447,4788,0];
} forEach thisList;

Prone to disaster though without accounting for things being tele'ed on top of other things. Things could get stratospheric very quickly 🤣

 

Also @csepi0101 you should look through https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands at the commands you are using so you can understand them better.

  • Like 4
  • Haha 1

Share this post


Link to post
Share on other sites

not tested but should do safe teleports if working generally:

Spoiler

private _pos = [6447,4788,0];

[thisList, _pos] spawn
{
 params ["_triggerObjects", "_teleportPosition"];
 
 private ["_radius", "_vec", "_minDist", "_maxDist", "_safePos"];
 private _maxRadius = 0;
 private _distLimit = 1000;
 private _defPos = [ 0, 0, 0];
  
 // select all land vehicles, get radius of all vehicles, get maximum radius
 private _triggerVehicles = _triggerObjects select { _x isKindOf "LandVehicle" } apply 
 { 
   _radius = (sizeOf _x) / 2;
   if ( _radius > _maxRadius ) then { _maxRadius = _radius };
   [ _x, _radius ]
 };
  
 // select all units which are on foot
 private _triggerUnits = _triggerObjects select  { _x isKindOf "Man" and isNull ObjectParent _x  };
 
 // find a safe position for each vehicle and place it
  {
    _vec = _x select 0;
    _radius = _x select 1;
    _minDist = _maxRadius + 2 + _radius;
    _maxDist = 50;
    _safePos = _defPos;
    
    while { _safePos isEqualTo _defPos and _maxDist < _distLimit } do
    {
     _safePos = [ _teleportPosition, _minDist, _maxDist, minDist, 0, 0.7, 0, [], [ _defPos, _defPos ] ] call BIS_fnc_findSafePos;
     _maxDist = _maxDist + _maxDist;
    };
    
    if( _safePos isNotEqualTo _defPos ) then { _vec setVehiclePosition [ _safePos , [], 1, "NONE" ]; };
      
  } forEach _triggerVehicles;
  
  _minDist = 2;
  
   // find a safe position for each unit and place it
  {
    _maxDist = 50;
    _safePos = _defPos;
    
    while { _safePos isEqualTo _defPos and _maxDist < _distLimit } do
    {
     _safePos = [ _teleportPosition, _minDist, _maxDist, minDist, 0, 0.7, 0, [], [ _defPos, _defPos ] ] call BIS_fnc_findSafePos;
     _maxDist = _maxDist + _maxDist;
    };
    
    if( _safePos isNotEqualTo _defPos ) then { _x setPos _safePos; };
    
  } forEach _triggerUnits;

 

  • Like 3

Share this post


Link to post
Share on other sites

Well, on this map, (not tested with other ones but should work...), it's not mandatory to teleport:

place 4 or 5 empty invisible markers on bridge you want to cross (tested on longer one, near Dlugoleka)

- for vehicles, this code seems to be reliable:

veh1 setDriveOnPath (["mk1","mk2","mk3","mk4","mk5"] apply {getMarkerPos _x});

 

-  for infantry, the behavior is less reliable but works most of the time:

{group1 addWaypoint [getMarkerPos _x,1]} forEach ["mk1","mk2","mk3","mk4","mk5"];

 

Not tested in combat environment. A "careless" behavior can help but you can't adjust the speed. It takes a rather long time for infantry to cross the river.

  • Like 2

Share this post


Link to post
Share on other sites
12 hours ago, dreadedentity said:

"If you want to teleport multiple units you will need some kind of loop. SetPosATL can only work with 1 unit at a time. I would recommend the forEach loop, specifically, for this; but any of them could be used as long as you understand the syntax

Also you will have a problem if you are trying to move both vehicles and soldiers to the same spot, soldiers can be moved without issue, they will just push each other out of the way without getting hurt; but vehicles will explode when you move multiple to the same spot"

maybe it won't be a problem to have 1 unit teleported at a time,beause they are not side by side when the next one enters the previous one goes on

 

Share this post


Link to post
Share on other sites
9 hours ago, Joe98 said:

Place a small rock on the map.  Name it   rock1

Name yourself blue1

Walk into a trigger area with the command     blue1 setpos  getpos rock1   and you are teleported to the rock

Write a separate command for each unit.

Of course I can do it by name but the point is that HAL commander takes the soldiers out of a repository, I don't give them  names (there are more spawns of one type, they will have a different name, but by default he will definitely give them a name as he commands them) and if so many triggers are weird at the same time, for every soldier 1, it slows down the game i need a general code for one trigger that applies to all incoming units

 

Share this post


Link to post
Share on other sites
49 minutes ago, csepi0101 said:

maybe it won't be a problem to have 1 unit teleported at a time,beause they are not side by side when the next one enters the previous one goes on

Yes you think it works in theory, now let's see what happens when we put a bunch of humans into the equation...

 

It's better to solve the human problem with code if possible

  • Like 1

Share this post


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

 

Yeah sounds like it. I guess something like a repeating trigger for ANYBODY using:


{
	(vehicle _x) setPos [6447,4788,0];
} forEach thisList;

Prone to disaster though without accounting for things being tele'ed on top of other things. Things could get stratospheric very quickly 🤣

 

Also @csepi0101 you should look through https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands at the commands you are using so you can understand them better. 

 

I wouldn't know more serious programming,(I don't want? to write,very complicated for me), but I understand the essence of the scripting, I learned a lot during under a unsung campaign (not ready yet), but not I can't find the global identifier that means=all AI units

I think I've tried this with what you wrote, don't need anything in the trigger condition field?"vehicle _x" it's a variable, what does it mean?how can this refer for all unit?if someone wants to solve it, write the whole solution don't put a part of program code in front of me

 

Share this post


Link to post
Share on other sites
7 hours ago, sarogahtyp said:

not tested but should do safe teleports if working generally:

 

if i run this in the trigger activation field as sqf in line 3 it writes an error..?
but thanks, good compliated,

for me a simple one would be enough, it doesn't have to find a place for the units, they don't come to the bridge at the same time

Share this post


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

Well, on this map, (not tested with other ones but should work...), it's not mandatory to teleport:

place 4 or 5 empty invisible markers on bridge you want to cross (tested on longer one, near Dlugoleka)

- for vehicles, this code seems to be reliable:veh1 setDriveOnPath (["mk1","mk2","mk3","mk4","mk5"] apply {getMarkerPos _x});

-  for infantry, the behavior is less reliable but works most of the time:

{group1 addWaypoint [getMarkerPos _x,1]} forEach ["mk1","mk2","mk3","mk4","mk5"];

Not tested in combat environment. A "careless" behavior can help but you can't adjust the speed. It takes a rather long time for infantry to cross the river.

The needing of teleport not need for mission making ,need for the NR6 HAL commanded war

I should type this for each unit by name, but I don't know the names of the newly created units that HAL gives them

i used this for unsung because ai doesn't go into the palm trees with a jeep

Share this post


Link to post
Share on other sites
7 hours ago, csepi0101 said:

what does it mean?

 

Like @beno_83au said, place a trigger on the "start" side of the bridge. Set it to REPEATABLE and activated by ANYONE. The condition field should be the default "this". In the activation field, place the code he provided:

{
	(vehicle _x) setPos [6447,4788,0];
} forEach thisList;

 

Let's break it down.

 

Think of curly brackets { } as sort of a container for code.  Above, they contain the code:

(vehicle _x) setPos [6447,4788,0];

which is a simple statement of the command setPos We are setPos'ing (vehicle _x) to the given coordinates [6447,4788,0]. But what does "(vehicle _x) mean? 

 

Vehicle is a command that returns the vehicle a unit is currently in. If they are not in a vehicle, it returns the unit (they are the vehicle.)

 

"_x" is a magic variable the represents the current focus of a loop or recursive code.

 

So, "(vehicle _x)" is the vehicle that our code loop is currently focused on. But what loop?

 

ForEach is a command that recursively iterates (loops) through an array. In this case, the array is any and all vehicles (including units on foot) that enter the trigger. 

 

So, in plain language, the code says:

 

"For every vehicle or unit that enters this trigger, set its position to the coordinates [6447,4788,0]."

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

{ (vehicle _x) setPos [6447,4788,0]; } forEach thisList;

 

i swear yesterday for lots of hours this was brought out to me by google a few times and it didn't work or i overlooked something

now i have tried it without HAL and it works

I'll try it with HAL right away

that’s exactly what I wanted, how simple it is

VERY VERY BIG BIG THANKS  (for beno_83au)

Share this post


Link to post
Share on other sites

THANKS WORKS WITH ALL AI UNITS TANKS etc..

 

(in test the leader tank teleported then he started back because of the second tank who had not yet teleported, but he move on the bridge (the back teleport had not yet been rewritten to the new version)

meanwhile the second tank also teleported and went away,and the third tank also teleported but stopped at the arrival teleport site because the boss started back to other side...

then the boss returned to the starter side of the bridge and he was teleported again into the third tank that waiting for him and they blew up... 😄 😄  :DD

 

maybe some regulation may really be needed 😄

Share this post


Link to post
Share on other sites

Thanks Harzach for the detailed description, I admire those who write this out from routine, I already had a lot of ideas but to start implementing it at this level is already science, (although I used to make a game in pascal and immersed in assembly (in 1995?)

Share this post


Link to post
Share on other sites
On 4/28/2022 at 11:01 AM, pierremgi said:

Well, on this map, (not tested with other ones but should work...), it's not mandatory to teleport:

place 4 or 5 empty invisible markers on bridge you want to cross (tested on longer one, near Dlugoleka)

- for vehicles, this code seems to be reliable:

veh1 setDriveOnPath (["mk1","mk2","mk3","mk4","mk5"] apply {getMarkerPos _x});

 

-  for infantry, the behavior is less reliable but works most of the time:

{group1 addWaypoint [getMarkerPos _x,1]} forEach ["mk1","mk2","mk3","mk4","mk5"];

 

Not tested in combat environment. A "careless" behavior can help but you can't adjust the speed. It takes a rather long time for infantry to cross the river.

I make some some script for that - and you have right - setdrive n path working quite good - but bugger problem is with waypoints and destination points when vehicles crossing bridhe in columns (after crosing bridge is problem with turn them back to go to next waypoint) is no command like "currentwaypoint" to register active waypoint of vehicle before it start to cross bridge to reasume it after crossing - but maybe expected destination in comparing with waypoints positions will give some solution) - here is example for all interested:

 

https://steamcommunity.com/sharedfiles/filedetails/?id=2801594216

 

I tested it on TANOA bridges and some of them causing broke of this command at all (on the end of the bridge vehicles start to turning and in effect droping from bridge before reach the end - it is strange beacouse end point is specially set some distance after orginal end of bridge).

Other problem is with start of movement on vehicles in column/group sometimes it reach trigger area and stoping there and not reacting on any command.

 

https://steamcommunity.com/sharedfiles/filedetails/?id=2802446504

 

Anyway command should be more independent (or have parameters like - type of obstacle reaction classes) and vehicles sholdn't  disturb it's movement/direction by any other vehicles/obstacles visible or not, now it react on too many objects on way of movement so this command is usless to do it good in most cases. 

 

for example veh1 setDriveOnPath [["mk1","mk2","mk3","mk4","mk5"],["man","car","building","terrainobjects"]]

  • Like 1

Share this post


Link to post
Share on other sites
On 4/30/2022 at 9:45 AM, h4wek said:

I make some some script for that - and you have right - setdrive n path working quite good - but bugger problem is with waypoints and destination points when vehicles crossing bridhe in columns (after crosing bridge is problem with turn them back to go to next waypoint) is no command like "currentwaypoint" to register active waypoint of vehicle before it start to cross bridge to reasume it after crossing - but maybe expected destination in comparing with waypoints positions will give some solution) - here is example for all interested:

 

https://steamcommunity.com/sharedfiles/filedetails/?id=2801594216

 

I tested it on TANOA bridges and some of them causing broke of this command at all (on the end of the bridge vehicles start to turning and in effect droping from bridge before reach the end - it is strange beacouse end point is specially set some distance after orginal end of bridge).

Other problem is with start of movement on vehicles in column/group sometimes it reach trigger area and stoping there and not reacting on any command.

 

https://steamcommunity.com/sharedfiles/filedetails/?id=2802446504

 

Anyway command should be more independent (or have parameters like - type of obstacle reaction classes) and vehicles sholdn't  disturb it's movement/direction by any other vehicles/obstacles visible or not, now it react on too many objects on way of movement so this command is usless to do it good in most cases. 

 

for example veh1 setDriveOnPath [["mk1","mk2","mk3","mk4","mk5"],["man","car","building","terrainobjects"]]

certain reactions of AI must be switched off,now I can't think of syntax but I remember things like Disableai move, danger, etc ...

it's my question if you're already here:

how to add a random number between 5 and 15 to one of this coordinates?

{ (vehicle _x) setPos [6447,4788,0]; } forEach thisList; 

in the simplest way

Share this post


Link to post
Share on other sites
{_x setPos ([6447,4788,0] getPos [5 + random 10, random 360])} forEach thisList; 

 

Share this post


Link to post
Share on other sites
19 hours ago, pierremgi said:

{_x setPos ([6447,4788,0] getPos [5 + random 10, random 360])} forEach thisList; 

 

yes i was hoping for similar,when not need to use new variables,big thanks

and the vehicle_x?

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

×