Jump to content
Sign in to follow this  
SilentSpike

Writing a function to find available person turrets (FFV seats)

Recommended Posts

I'm trying to figure out how I can find the FFV seats in a vehicle and produce an array of the indexes that are empty or occupied by a dead body. I also need the function to ignore regular cargo seats that don't support FFV. However I have almost no idea where to start.

So planning it out in my head I get this:

  1. Create an array of all the cargo indexes in a vehicle (available the vehicle config?)
  2. Deduce which of them has FFV support and remove the rest (no idea how to do this)
  3. Find out which indexes are occupied (can't figure out which commands might be able to do this)
  4. Find out which of the occupied indexes are occupied by dead units (if I can find a way to return the unit at a specific cargo index this is nice and simple)
  5. Return the array of non-occupied indexes combined with the indexes occupied by dead units

Has anyone tried producing anything like this? I feel like there are a lack of scripting commands relating to FFV and on top of that vehicle seating seems awkward to work with already (without using turret paths or cargo indexes specific to a vehicle).

Share this post


Link to post
Share on other sites

Hi,

You can use the difference between allturrets (just the physical hardpoints and turrets) and allTurrets (including FFV).

Subtract one from the other and you're left with just the FFV positions.

Try this (seems to work ok when testing at home):

_allTs = allTurrets[cursorTarget,true];
_nonFFVTs = allTurrets cursorTarget;
{
_turr = _x;
_ind = _forEachIndex;
{
	if (_turr isEqualTo _x) exitWith {
		_allTs set [_ind,"exorcise"]
	};
} forEach _nonFFVTs;
} forEach _allTs;

_allTs = _allTs - ["exorcise"];

_deadMen = [];
_freeSeats = [];

{
_bloke = cursorTarget turretUnit _x;
if (isNull _bloke) then {
	_freeSeats pushBack _x
} else {
	if not(alive _bloke) then {
		_deadMen pushBack _x
	};
};
} forEach _allTs;


systemChat format ["all turrs %1",_allTs];
systemChat format ["deaders %1",_deadMen];
systemChat format ["free seats %1",_freeSeats];

Substitute in the cursorTarget for your vehicle.

Hope that helps :)

edit: Updated for free seats & dead guys

Edited by Das Attorney

Share this post


Link to post
Share on other sites

Wow, thanks so much Attorney. Above and beyond the call of duty. :) I knew FFV were considered both cargo and turrets, but I wasn't sure how to get their turret paths so I wrote that method off. Thanks for enlightening me.

Praise the allTurrets command! :yay: I'll have to add it to the related commands section of some of the FFV specific stuff.

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  

×