Jump to content
Sign in to follow this  
Master_Chief

Detecting vehicle class, is there a way?

Recommended Posts

I am making a script where I want it to detect the nearest vehicle and determine whether it is a car, tank, plane, chopper, or boat. Can this be done or would I have to use nearestobject and define each vehicle manually?

Share this post


Link to post
Share on other sites

Use the counttype command:

"Man" counttype [unitname] == 1: hint "Unit is man class"

"air" counttype [unitname] == 1: hint "Unit is air class"

RED

Share this post


Link to post
Share on other sites

Okay, so how do I detect the nearest unit in a way that it could be different classes? Like now i have:

_nearest = nearestObject [_unit, "jeep"]

? ("Man" counttype [_nearest] == 1): hint "Unit is man class"

? ("Plane" counttype [_nearest] == 1): hint "Unit is air class"

? ("Tank" counttype [_nearest] == 1): hint "Unit is tank class"

? ("Helicopter" counttype [_nearest] == 1): hint "Unit is helo class"

so what would I replace "jeep" with?

Thanks smile_o.gif

Share this post


Link to post
Share on other sites

_nearest = nearestobject _pos

? ("Man" counttype [_nearest] == 1): hint "Unit is man class"

? ("Plane" counttype [_nearest] == 1): hint "Unit is air class"

? ("Tank" counttype [_nearest] == 1): hint "Unit is tank class"

? ("Helicopter" counttype [_nearest] == 1): hint "Unit is helo class"

Typeof does not detect base classes, it will be no use in this situation.

RED

Share this post


Link to post
Share on other sites

_nearest = nearestobject _pos

I assume that _pos is the getpos of the unit executing the script. This doesn't work because the nearestobject at those coordinates is the unit executing the script smile_o.gif Btw this script is done using addaction and what I want it to do is have it that you can walk up to a vehicle and check the base class.

Share this post


Link to post
Share on other sites

Try using something like this:

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

_unit = unitname

_i = 0.1

#loop

_pos = [(getpos _unit select 0) + sin (getdir _unit + 180) * _i, (getpos _unit select 1) + cos (getdir _unit + 180) * _i,0]

_nearest = nearestobject _pos

_i = _i + 0.3

?_nearest == _unit && _i < 3: goto "loop"

?_nearest == _unit : goto "no_unit"

? ("Man" counttype [_nearest] == 1): hint "Unit is man class"

? ("Plane" counttype [_nearest] == 1): hint "Unit is air class"

? ("Tank" counttype [_nearest] == 1): hint "Unit is tank class"

? ("Helicopter" counttype [_nearest] == 1): hint "Unit is helo class"

exit

#no_unit

hint "No unit present"

exit

Not tested, but it should work!

RED

Share this post


Link to post
Share on other sites

Hi,

Do you want an action that is only available to certain vehicle classes, or will the same action be displayed for all vehicles?

Do you want an action that just returns the actual class of any vehicle, like "M1A1" or "UAZ"?

Do you want an action that tells you if its Land, Air , Tank, APC e.t.c This is what I assume you mean when you say Base Class?

But I dont think you need to use nearest object, Actions should pass the Vehicle there attached to, to the script you call?

Hard to say without knowing exactly what the action is for?

Share this post


Link to post
Share on other sites
Quote[/b] ]_pos = [(getpos _unit select 0) + sin (getdir _unit + 180) * _i, (getpos _unit select 1) + cos (getdir _unit + 180) * _i,0]

Brilliant! it works, but the _pos position is always behind the _unit so you have to face away from the vehicle, could you fix this please? Thanks smile_o.gif

*edit* to fix it I just removed the + 180 from _pos.

It works prefectly now and I thank you for your help smile_o.gif

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  

×