Jump to content
Sign in to follow this  
Guest

Is unit a vehicle within a trigger list

Recommended Posts

Guest

was justcurious if someone knows of a simple way to discover if a unit in a trigger list is actually a vehicle, aside from using typeOf, which I am using right now, although, of course then I have to cover every neccessary vehicle type this way - id like to just know if _x is a vehicle, and hence if it is a vehicle, then dont execute for him..

lil example here:

I need vehicles removed from this position being set

;get pos of last freindly unit in list

{if ((side _x == west) and (alive _x) and (_x != player) and (typeOf _x != "SoldierWCaptive")) then {_freindlypos = getPos _x}} forEach _listUnitsinTown

So, heres all I can find that works, more lengthy than desired tho...

{if ((side _x == west) and (alive _x) and (_x != player) and (typeOf _x != "SoldierWCaptive") and (typeOf _x != "Mi17_MG") and (typeOf _x != "T72") and (typeOf _x != "M1Abrams") and (typeOf _x != "BMP2")) then {_freindlypos = getPos _x}} forEach _listUnitsinTown

would be nice to just have one command that says if _x is vehicle, dont think there is..

Have tried ?(vehicle _x == x), problem is for the vehicle itself, it doesent return it as being a vehicle, so this only works for units in a vehicle...

Share this post


Link to post
Share on other sites
Guest

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if ("CAR" countType [_x]) > 0) or ("TANK" countType [_x]) > 0)} then .......

This will check if _x is a car or a tank, for car and tank classes follow this link.

btw, edit.......nevermind

Share this post


Link to post
Share on other sites
Guest

Thanks for that, wow, guess there is a way to know then, cool smile_o.gif

Ill have to mess with that, but this is great, will shorten this application considerably.

Thanks again El nino Foxhound

Share this post


Link to post
Share on other sites

vehicles is supposed to return an array of vehicles and units that aren't in vehicles, it actually returns only vehicles, so you could utilise that

Unless of course they fix it

_veh = vehicles

{if(_x in _veh)then{.........}}foreach list triggername

Share this post


Link to post
Share on other sites
Guest

Gotcha on that Terox, although that is a big list for it to go thru, considering the vehicles list in this mission is like alot, had thought about trying that tho, main purpose is to eliminate any possible additional lag by adding in this vehicle thing. I appreciate that still tho, knowing it could be fixed would concern me as well -

Thing I dont get, according to the Wiki, typeOf *supposedly* is the only other command that should work with 'parent' classes, although im not getting it to work like that, doesent respond to "Tank", "Car", etc, huh..

Within the description of countType it says that typeOf is aparently the only other command that can work with 'parent' classes (El Nino Foxhound spurred my interest wink_o.gif )

countType

Description:

Count how many units in the array are of given type. Other than typeOf this command also works with parent classes like "Air", "Tank" and "Car". For a full class reference see Classes.

Although I cant get typeOf to work with anything but direct vehicle names, broken?

Share this post


Link to post
Share on other sites
Guest

lol, this keeps gettin better (forgive me for not knowing all the commands in the wiki tounge2.gif)

ill give that new command a try

Share this post


Link to post
Share on other sites
Quote[/b] ]forgive me for not knowing all the commands in the wiki

Of course, that goes without saying. The most important thing is, you wanted to find and share the solution.

As far as the wiki goes. You never professed to know it's short comings smile_o.gif

All we have to decied now, is who updates it, in case anyone else has the same problem wink_o.gif

Share this post


Link to post
Share on other sites
Guest

Yep, that will work.

Still, odd that TypeOf doesent work on anything but direct vehicle sub-type names, although the wiki says otherwise about it.

Final script from testing (with manned t72 and a group of troops in a trigger area)

{if((vehicle _x == _x) and !(vehicle _x isKindof "Tank") and (_x != player)) then {_x doMove (getPos player)}} forEach (list temptrigger)

This of course, only moves the troops, no tanks.

(note - test was a success because only troops did a huddle with player, tank not inculded tounge2.gif)

Thanks all for the help, you guys certainly helped me get this addition wayyyyy smaller, greatly appreciated smile_o.gif

Share this post


Link to post
Share on other sites

Check if it has a driver, then if so if the driver is not equal to the unit in question or doesn't have one at all then it is a vehicle. All 'men' have 'drivers' that are equal to themselves.

Ex:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_driver = driver _unit

if((isnull _driver)||(_driver != _unit))then{hint format ["%1 is a vehicle",_unit]}

Share this post


Link to post
Share on other sites

@KyleSarnik

If I remember correctly from OFP, all non-mounted soldiers are in fact vehicles unto themselves, as in Vehicle Player will return Player, whereas Vehicle Driver Tank1 will return the name of the tank. So writing a simple ?vehicle Unit1 !=Unit1 : hint "This unit is in a vehicle!" should be sufficient to determine whether the unit in question is indeed inside a vehicle or not.

They might have changed that, of course. smile_o.gif

/Wolfrug

Share this post


Link to post
Share on other sites
Guest

?(Vehicle _x == _x): _x is not in a vehicle - works, except it is more/less useless with using a trigger, because a trigger list doesent return units in a vehicle, only the vehicle itself, and vehicle command used on a 'true' vehicle just returns it as itself, (unless that vehicle was in another vehicle ? tounge2.gif(im using it just as a backup, cant hurt))

My only desire was just to know if any unit cycled thru in a trigger list is a vehicle unto itself (tank, car, etc), so therefore that vehicle wont get counted in, only ground troops - this is for moving other units to that selected units position, imagine sending ground troops after a T80 tounge2.gif, thats why the vehicles are removed.

Share this post


Link to post
Share on other sites
Guest

While this topic is still active, got another question here.

In my mission, a trigger is used at start covering entire map that turns off fleeing for all units in the list - has worked great.

Last night, was testing a battle, and a tank 'appeared' to flee, which made no sense, initally.

Then I realised, that tank, along with a bunch of others, are initally empty, and although the tankers fleeing is turned off, Im trying to see if fleeing needs to be turned off for a vehicle itself once its been occupied - or if it merely can be turned off for the empty vehicle directly, this is kind of hard to replicate getting the tank to flee, but its real important, the tank took off and was gone for like 5 min during the battle wow_o.gif

Anyone maybe got some advise/info on this by chance ?

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  

×