Jump to content

Recommended Posts

Hello:

With this small script, activated by trigger, a helicopter with its crew must appear on the ground, on a certain 3D position. When the script is activated, the helicopter itself is generated, but static and at a certain height, not perched on the ground. If the code indicates that the height must be 0 (_height = 0;), why does not it work? What am I doing wrong?

Please, can you help me?

Thank you.

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

_markerstr = createMarker ["MI8_C1", [9908.08,19424.5]];

_markerstr setMarkerShape "ICON";

_markerstr setMarkerType "hd_dot";

_height = 0;

_pos = getMarkerPos "MI8_C1";

_MI8_C1 = [ [_pos select 0, _pos select 1, _height], EAST, ["CUP_O_Mi8_RU"],[],[],[],[],[],270] call BIS_fnc_spawnGroup;

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Share this post


Link to post
Share on other sites
5 minutes ago, Coladebote said:

If the code indicates that the height must be 0 (_height = 0;), why does not it work? 

Please describe in more detail what is supposed to happen and how your results differ from the expected outcome.

Share this post


Link to post
Share on other sites

The helicopter must be generated on the ground, height 0, but it is generated in flight, static on the 3D position, at a height of 40/50 meters.

Share this post


Link to post
Share on other sites

flyInHeight might work and/or resetting the altitude to 0 right after spawning:

 

_markerstr = createMarker ["MI8_C1", [9908.08,19424.5]];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_dot";

_height = 0;

_pos = getMarkerPos "MI8_C1";

_MI8_C1 = [ [_pos select 0, _pos select 1, _height], EAST, ["CUP_O_Mi8_RU"],[],[],[],[],[],270] call BIS_fnc_spawnGroup;
_MI8_C1 setPos [_pos select 0, _pos select 1, _height];
_MI8_C1 flyInHeight _height;

 

  • Like 1

Share this post


Link to post
Share on other sites

Hello,
Thanks for your time.
This code does not work It produces an error from line 7.

 

 

_markerstr = createMarker ["MI8_C1",[9908.08,19424.5]];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_dot";
_height = 0;
_pos = getMarkerPos "MI8_C1";
_MI8_C1 = [ [_pos select 0, _pos select 1, _height], EAST, ["CUP_O_Mi8_RU"],[],[],[],[],[],270] call BIS_fnc_spawnGroup;
_MI8_C1 setPos [_pos select 0, _pos select 1, _height];
_MI8_C1 flyInHeight _height;

 

 

The helicopter appears, but static in flight, as seen in the photo.

 

Image link

https://drive.google.com/open?id=1wkeL71l8AezSuud7oadMYdaUKry_yJZ2

https://drive.google.com/open?id=1lTIgm1hkzpublfWkphVSuAb2PfEA_w3t


Grateful.

Share this post


Link to post
Share on other sites
46 minutes ago, Coladebote said:

Hello,
Thanks for your time.
This code does not work It produces an error from line 7.


 


_markerstr = createMarker ["MI8_C1",[9908.08,19424.5]];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_dot";
_height = 0;
_pos = getMarkerPos "MI8_C1";
_MI8_C1 = [ [_pos select 0, _pos select 1, _height], EAST, ["CUP_O_Mi8_RU"],[],[],[],[],[],270] call BIS_fnc_spawnGroup;
_MI8_C1 setPos [_pos select 0, _pos select 1, _height];
_MI8_C1 flyInHeight _height;

 

 

The helicopter appears, but static in flight, as seen in the photo.

 

Image link

https://drive.google.com/open?id=1wkeL71l8AezSuud7oadMYdaUKry_yJZ2

https://drive.google.com/open?id=1lTIgm1hkzpublfWkphVSuAb2PfEA_w3t


Grateful.

BIS_fnc_spawnGroup returns a group.

You can't use setPos on a variable holding a group, since it's a different data type.

 

Also @beno_83au BIS_fnc_spawnGroup uses BIS_fnc_spawnVehicle to spawn vehicles, which also spawns vehicles according to their simulation type, in this case aircraft will be spawned using createVehicle with "FLY" parameter.

Only solution would be to write a custom group spawner or force the vehicle on ground using setPosATL and turn engine off or similar.

 

Cheers

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Hello
My knowledge is very poor in this matter, the situation surpasses me. Also, I find few references in the forum to support me.
Pardon my ignorance.

Sorry.

Share this post


Link to post
Share on other sites

Does the helicopter have to spawn by script? If it's an editor object this is easy.
1) Create your helicopter in the engine, place it a meter off the ground, name it.
2) Create a helper object, name it and place it on the ground below your chopper.
3) Use BIS_fnc_attachToRelative to attach the helo to the marker.

[_helo, _marker] call BIS_fnc_attachToRelative;

4) Create a helper or marker where you want the helicopter to appear, name it.
5) Send the chopper marker to objNULL via init (to hide)

_marker setpos (getpos objNULL);

6) When it's time for your chopper to appear setpos the helo marker to the destination marker and use detach.

_marker setpos (getpos _locationMrk);
detach _helo;

While the helicopter is "attached" to the helper it will be in pseudo suspension-- the most obvious indication of which is the rotor blades moving in slow motion. After detach the chopper will function as normal. You can add a waypoint at the same time the setpos takes place.

    _wp =_group addWaypoint [(getPos _wpMrk), 0];
    _wp setWaypointType "MOVE";

I know it's not what you asked for but it's a viable workaround.

Have fun!

Share this post


Link to post
Share on other sites

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

_markerstr = createMarker ["MI8_C1", [9908.08,19424.5]];

_markerstr setMarkerShape "ICON";

_markerstr setMarkerType "hd_dot";

_height = 0;

_pos = getMarkerPos "MI8_C1";

_MI8_C1 = [ [_pos select 0, _pos select 1, _height], EAST, ["CUP_O_Mi8_RU"],[],[],[],[],[],270] call BIS_fnc_spawnGroup;

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

I think I did not have to explain myself correctly. With this script in a trigger-activated sqf file, the result is that of the photo:

 

Image link

https://drive.google.com/open?id=1wkeL71l8AezSuud7oadMYdaUKry_yJZ2

https://drive.google.com/open?id=1lTIgm1hkzpublfWkphVSuAb2PfEA_w3t

 

The script fulfills its function because the helicopter appears at the indicated point of the 3D position.

The problem is that the helicopter is not generated on the ground, but elevated. What I want is for the helicopter to be generated in the indicated 3D position, with its crew and on the ground, not in flight.

 

I clarify, I am creating a CTI in Altis and for performance reasons no object can appear on the map, everything works with sqf files, 3d position and triggers.

Share this post


Link to post
Share on other sites

@Coladebote,

Quote

The problem is that the helicopter is not generated on the ground, but elevated.

Sorry, I had it mixed up.
 

Quote

I am creating a CTI in Altis and for performance reasons no object can appear on the map,

Copy that.

  • Like 1

Share this post


Link to post
Share on other sites

0 = [] spawn {

  _markerstr = createMarker ["MI8_C1",[9908.08,19424.5]];
  _markerstr setMarkerShape "ICON";
  _markerstr setMarkerType "hd_dot";
  _pos = getMarkerPos _markerStr;
  _MI8_C1 = createVehicle ["CUP_O_Mi8_RU",_pos, [],0,"NONE"];
  _MI8_C1 setdir 270;
  createVehicleCrew _MI8_C1;
}

  • Like 5

Share this post


Link to post
Share on other sites

Hello, Pierremgi:

 

There's nothing like being an expert. Those lines of code work wonders, in the editor. I have not been able to test it on the server, but I guess it will work fine too.

 

Link of the image:

https://drive.google.com/open?id=14RurOFYmej1FtEk-D6LVENfx-mZ0Rjk3

 

It's the second time you saved my skin. Thanks for your valuable help. Generous people like you make Arma III a great game.

  • Like 4

Share this post


Link to post
Share on other sites

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 = [] spawn {

  _markerstr = createMarker ["MI8_C1",[9908.08,19424.5]];
  _markerstr setMarkerShape "ICON";
  _markerstr setMarkerType "hd_dot";
  _pos = getMarkerPos _markerStr;
  _MI8_C1 = createVehicle ["CUP_O_Mi8_RU",_pos, [],0,"NONE"];
  _MI8_C1 setdir 270;
  createVehicleCrew _MI8_C1;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

Hello:

 

I test the script with a Blufor attack on the point where the helicopter is. AI is stupid.

 

When they are in danger they must fly with the helicopter and defend the position from the air, but they descend from the vehicle and act as infantry. The Vcom does not manage this issue well.

 

It would be necessary for the script to order the AI to take flight and orbit the area to defend the position from the air, when it detects an enemy presence.

 

Honestly, I don't know where to start. Can you help me?


Thank you.

Share this post


Link to post
Share on other sites

One possible way:
 

0 = [] spawn {
  _markerstr = createMarker ["MI8_C1",[9908.08,19424.5]];
  _markerstr setMarkerShape "ICON";
  _markerstr setMarkerType "hd_dot";
  _pos = getMarkerPos _markerStr;
  _MI8_C1 = createVehicle ["CUP_O_Mi8_RU",_pos, [],0,"NONE"];
  _MI8_C1 setdir 270;
  createVehicleCrew _MI8_C1;
  waituntil {sleep 1; (allPlayers findIf {_MI8_C1 knowsAbout _x > 0}) >-1};
  _MI8_C1 engineOn true;
  waituntil {sleep 1; !isNull (_MI8_C1 findNearestEnemy _MI8_C1)};
  _pos = getpos (_MI8_C1 findNearestEnemy _MI8_C1);
  _wp = group _MI8_C1 addWaypoint [_pos,0];
  _wp setWaypointType "loiter";
  _wp setWaypointLoiterRadius 200;
  _MI8_C1 flyInHeight 30;
};

 

  • Like 2

Share this post


Link to post
Share on other sites

As soon as I get back from work, I try and tell you Thank you.

Share this post


Link to post
Share on other sites

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

0 = [] spawn {
  _markerstr = createMarker ["MI8_C1",[9908.08,19424.5]];
  _markerstr setMarkerShape "ICON";
  _markerstr setMarkerType "hd_dot";
  _pos = getMarkerPos _markerStr;
  _MI8_C1 = createVehicle ["CUP_O_Mi8_RU",_pos, [],0,"NONE"];
  _MI8_C1 setdir 270;
  createVehicleCrew _MI8_C1;
  waituntil {sleep 1; (allPlayers findIf {_MI8_C1 knowsAbout _x > 0}) >-1};
  _MI8_C1 engineOn true;
  waituntil {sleep 1; !isNull (_MI8_C1 findNearestEnemy _MI8_C1)};
  _pos = getpos (_MI8_C1 findNearestEnemy _MI8_C1);
  _wp = group _MI8_C1 addWaypoint [_pos,0];
  _wp setWaypointType "loiter";
  _wp setWaypointLoiterRadius 200;
  _MI8_C1 flyInHeight 30;
}

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

Hi, the script works perfectly.

As soon as the helicopter crew detects the enemy presence (BLUFOR) it opens fire and, at the same time, starts the engine, starts the flight and continues the attack from the air.
Everything works very natural.
I repeat, excellent. Thank you very much for your time and kindness.

  • Like 2

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

×