Jump to content
HorribleGoat

How to use moveInTurret script command?

Recommended Posts

Hello!

I need some advice on how to populate empty turrets in a custom vehicle I have.

The turret indexes are [0,0] [0,1] [0,2] [0,3] and Ive tried creating new units and moving them into the vehicle with moveInTurret command in dev console and via useraction executed .sqf but have not managed to get it to work.

The turret gunner seats seem to work ok when units are placed in them in Eden but moveInTurret does not seem to work.   :confused:  :confused: 

I've got code as follows:

 

//_veh = vehicle player;
 
_veh = _this select 0;
 
_gunnerL1  = "B_Pilot_F" createvehicle position _veh;
_gunnerL2  = "B_Pilot_F" createvehicle position _veh;
_gunnerR1  = "B_Pilot_F" createvehicle position _veh;
_gunnerR2  = "B_Pilot_F" createvehicle position _veh;
//creating the units, B_Pilot_F used for testing.. (short classname :9)
//units appear around the vehicle as they should
 
//Not sure if this is even needed, but saw it in one example and tried it..
_gunnerL1 assignAsTurret  [_veh, [0,0]];
_gunnerL2 assignAsTurret  [_veh, [0,1]];
_gunnerR1 assignAsTurret  [_veh, [0,2]];
_gunnerR2 assignAsTurret  [_veh, [0,3]];
 
 
//Moving the wannabe gunners into the right turrets..
 
_gunnerL1 moveinturret [_veh, [0,0]];
_gunnerL2 moveinturret [_veh, [0,1]];
_gunnerR1 moveinturret [_veh, [0,2]];
_gunnerR2 moveinturret [_veh, [0,3]];
 
//But it seems to do nothing :o
 
 
_crew = fullcrew [_veh,"",true];
 
hint format ["%1",_crew];
//script runs to the end and hint shows none of the units enter the vehicle.
 

Tried this with vanilla vehicles too and with other crew positions but just don't know what Im missing. Any advice?

Share this post


Link to post
Share on other sites

You should use createUnit for your gunners, not createVehicle, or you will make brainless units that stand there like mannequins.

  • Like 1

Share this post


Link to post
Share on other sites

You should use createUnit for your gunners, not createVehicle, or you will make brainless units.

 

Oh, did not know this. :D Going to try this right away. Thank you sir!

Share this post


Link to post
Share on other sites

Something like this should work if you don't want to iterate through all the units (change the group side as you see fit):

_veh = _this select 0;
_grp = createGroup (side player);
{
    _bloke = _grp createUnit ["B_Pilot_F",[666,666,666],[],0,"can_collide"];
    _bloke assignAsTurret [_veh,_x];
    _bloke moveInTurret [_veh,_x];
} forEach [[0,0],[0,1],[0,2],[0,3]];


hint format ["%1",fullcrew [_veh,"",true]];
 
Not knowing what you needed, the script is based off the turret indexes you gave, but you could feed in allTurrets to do FFV only for example:
_veh = _this select 0;
_grp = createGroup (side player);
{
    _bloke = _grp createUnit ["B_Pilot_F",[666,666,666],[],0,"can_collide"];
    _bloke assignAsTurret [_veh,_x];
    _bloke moveInTurret [_veh,_x];
} forEach (allTurrets [_veh, true] - allTurrets [_veh, false]);


hint format ["%1",fullcrew [_veh,"",true]];

Share this post


Link to post
Share on other sites

Well the new units now run around now, but they still wont transfer into to the turrets/driver/commander/gunner seats. 

I'll try what you wrote. The case right now is very specific vehicle as in our walking tankman and its arm guns that Im experimenting with. 

Goal is to see if we can use hidden AI gunners to operate the weapons via remote commands to simulate fire groups and such.

Share this post


Link to post
Share on other sites

And now it works. :D Thank you das attorney for lightning fast reply! 

Another piece of the whole clicks into its place. 

  • Like 1

Share this post


Link to post
Share on other sites

Well the new units now run around now, but they still wont transfer into to the turrets/driver/commander/gunner seats. 

I'll try what you wrote. The case right now is very specific vehicle as in our walking tankman and its arm guns that Im experimenting with. 

Goal is to see if we can use hidden AI gunners to operate the weapons via remote commands to simulate fire groups and such.

 

Ah, ok I see where you're going now.   :)

 

Not sure if this has been considered by you already, but have you made sure that your vehicle can actually house crew?  (as in all the config and model work is complete)?

 

You might also want to check out how the UAV's have their crew set up (they use invisible units).

 

I just checked the second script I posted on an "I_G_Offroad_01_F" and it filled up the back with passengers. (Look at an empty vehicle and paste this in your debug console):

 

fnc_carFill = {
    _veh = _this select 0;
    _grp = createGroup (side player);
    {
       _bloke = _grp createUnit ["B_Pilot_F",[666,666,666],[],0,"can_collide"];
       _bloke assignAsTurret [_veh,_x];
       _bloke moveInTurret [_veh,_x];
    } forEach (allTurrets [_veh, true] - allTurrets [_veh, false]);
};


[cursorObject] call fnc_carFill
  • Like 1

Share this post


Link to post
Share on other sites

Sorry, didn't see your other post - 

 

That's no problem - I like the sci-fi stuff you're doing in Arma - if you need any script shennagins, let me know - I'm happy to help  :)

  • Like 1

Share this post


Link to post
Share on other sites

I have planned using the invisible UAV AIs and originally wanted to set up the vehicle so that the gun AIs would spawn in always and the rest of the seats would spawn empty. 

Did not get that to work as even though, driver, gunner and commander seats were set up to not have crew the dummy AIs spawned on them first and filled only one of the "hidden" turrets.

Thats why I opted to make a script to fill the turrets as I want and also because Im certain I have to clear the AI turrets when the vehicle is empty. Otherwise they'll start shooting on their own when a target passes them by.. :P

Im thinking of running the AI creation script as part of the vehicles startup sequence and maybe remove them on "getout" event.
 

 

Sorry, didn't see your other post - 

 

That's no problem - I like the sci-fi stuff you're doing in Arma - if you need any script shennagins, let me know - I'm happy to help   :)

I may take you up on the offer when I run into the next wall :D Now that I can control the spawning of the hidden AIs and firing with them I gotta figure out what kind of controls would be best for using the firegroups and after that the system might actually be ready for testing! :D
 

  • Like 1

Share this post


Link to post
Share on other sites

Thats why I opted to make a script to fill the turrets as I want and also because Im certain I have to clear the AI turrets when the vehicle is empty. Otherwise they'll start shooting on their own when a target passes them by.. :P

Im thinking of running the AI creation script as part of the vehicles startup sequence and maybe remove them on "getout" event.

 

 

 

Using "getOut"/"getIn" EH would be best as you say, but removing the units seems extreme imo.  You could try setting them as "setCaptive" so the game doesn't have to delete and recreate them everytime someone exits/enters the vehicle but puts them into a neutral chill-out civilian state instead.  Seeing as how creating units is one of the costliest things you can do in Arma (imo), it might be worth checking out.   :)

Share this post


Link to post
Share on other sites

Using "getOut"/"getIn" EH would be best as you say, but removing the units seems extreme imo.  You could try setting them as "setCaptive" so the game doesn't have to delete and recreate them everytime someone exits/enters the vehicle but puts them into a neutral chill-out civilian state instead.  Seeing as how creating units is one of the costliest things you can do in Arma (imo), it might be worth checking out.   :)

SetCaptive could be an option! have to try it out. 

I was hoping I could make some sort of an autofire mode too with the AIs that would fire when appropriate target was in line of fire but the normal AI firing behaviour seems too unreliable for that so Im opting now to make them as dum as possible. In y trials I've seen the AI blast away full auto on a tank and to just ignore the tank next to it. :D Im convinced that autofire has to be scripted mode to make sure it works.

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

×