Jump to content
Sign in to follow this  
madrussian

It's a vehicle! It's a man! It's... I have absolutely no idea what the heck it is!!!

Recommended Posts

So here's the simple question:

Given an unknown unit, how can we determine whether it's on foot? (I.e. Is it a vehicle or a man?)

Now some details:

So I've got a "fired" eventhandler set up. I get the shooter like this:

_shooter = _this select 0;

The next thing I need to do is to determine whether the unit is on foot, which I've always done like this:

_onFoot = false;
if ( _shooter == (vehicle _shooter) ) then
{
onFoot = true;
};

IIRC, this used to work like a charm, but apparently not any more! :confused:

When I do hints and check the values of _shooter and (vehicle _shooter), they are always the same value, regardless of if the firing unit is actually on foot or not!

I tried using (crew _shooter), but that returns a single unit when the unit is on foot, and thus would be ambiguous as well. (_shooter in _shooter) does not work as advertised either. It reports true no matter if on foot or in a vehicle.

I even tried assignedVehicleRole, as in:

_onFoot = false;
if ( (count ((assignedVehicleRole _shooter) select 1)) > 0 ) then
{
_onFoot = true;
};

which works (only gunners report a turret), but after thinking on it a bit, it's just as ambiguous as the others, because it could be a footman assigned to a gun position but be waiting on foot outside the vehicle (i.e. using orderGetIn false). :eek:

...As I've typed all this it finally dawned on me what I can use in my particular case. Tested it and it works in every case I can some up with (including a vehicle with an empty driver seat):

_onFoot = false;
if ( (driver _shooter) == _shooter ) then
{
_onFoot = true;
};

This works in my case because I know the unit fired and is thus not a driver. (Recall that I got the _shooter from a fired eventhandler.) However, I am still scratching my head on this though... :confused:

What if we simply need to determine whether an arbitrary unit is a vehicle or on foot?

Now that I've gone into all this detail, I have a feeling someone is gonna dazzle me with just how simple this really is. :)

EDIT:

Hmmmm... It appears I've just dazzled myself:

_onFoot = false;
if (_shooter isKindOf "Man") then
{
_onFoot = true;
};

Hope this helps someone out. :)

Edited by MadRussian

Share this post


Link to post
Share on other sites

Yes, you can use isKindOf "Man"...

If you want to find out the other way if its a vehicle, do this:

if ( (vehicle _unit) isKindOf "LandVehicle" OR (vehicle _unit) isKindOf "Air") then {

_vcl = vehicle _unit;

};

When you use the units _grp command you'll get everyone so you need to check their vehicle.

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  

×