Jump to content
anfo

Vehicle force headlights off

Recommended Posts

Hello

 

During a night mission I have some AI driven HEMTT trucks which turn their lights on at mission start. Additionally, the waypoint behaviour for the HEMTT is set to "careless" which is important because I don't want them to react to any enemy. I mention this because it is likely someone will recommend the behaviour "aware" to turn the lights off.

 

So while a unit is behaviour "careless", is there an init code to force the vehicles to not use headlights? (blackout)

 

Cheers, Anfo

Share this post


Link to post
Share on other sites

setPilotLight is a weird command.

The description can be a bit misleading, since AI still overrides the setPilotLight command. Same goes for action "LightOn" or "LightOff".

No clue why this command has been introduced since it neither overrides AI vehicle light handling, nor does it anything different than the light on/off actions.

It's simply a local alternative.

Kinda redundant.

 

The only way to override AI vehicle light behavior without messing with "safe", "aware" or "careless" humbug is to either destroy the vehicle lights to turn them off or use onEachFrame eventhandlers to force vehicle lights on.

Other solutions using while true loops with 0.01s sleep usually lead to flickering lights, so using onEachFrame is mandatory.

 

Making script commands override default AI behavior could make everything a bit more simple.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

you can set them aware (to turn off the lights) with combatmode blue (do not engage) which will not let them to attack enemy even if they see them.

Only issue is they will not always follow the roads as they do in safe and careless behaviour

 

I have also similar issue with AI Pilots where I want them not to bring their flap down but they always do!!

Share this post


Link to post
Share on other sites

you can set them aware (to turn off the lights) with combatmode blue (do not engage) which will not let them to attack enemy even if they see them.

 

Yeah I thinking that too and since the path they're taking is roadless it may not matter

Share this post


Link to post
Share on other sites

Id use this to get all of the available damage points

https://community.bistudio.com/wiki/getAllHitPointsDamage

Then use this to specifically break the headlights, probably the only way

https://community.bistudio.com/wiki/setHitPointDamage

 

Thanks for all replies. It appears that "getting all hitpoints" to return the value for the headlights of the HEMTT, then damaging the headlights is the way I am going to probably achieve my goal.

Using the debug console is proving a headache for a noob like me however and I was wondering if anybody would kind enough to either explain how to use the debug console to return the hitpoint values of a given vehicle, or alternatively let me know the names of the front headlights so I can damage them?

 

Many thanks.

Share this post


Link to post
Share on other sites

bump :)

Share this post


Link to post
Share on other sites

You can return it through using this

 

things = getAllHitPointsDamage car1

and in one of the watch lists, type things.

Returns the array of hitpoints which youll have to sift through

Share this post


Link to post
Share on other sites

This was the return

[["HitFuel","HitEngine","HitBody","HitLFWheel","HitLBWheel","HitLMWheel","HitLF2Wheel","HitRFWheel","HitRBWheel","HitRMWheel","HitRF2Wheel","HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitRGlass","HitLGlass","HitGlass5","HitGlass6","","","",""],["palivo","motor","karoserie","wheel_1_1_steering","wheel_1_4_steering","wheel_1_3_steering","wheel_1_2_steering","wheel_2_1_steering","wheel_2_4_steering","wheel_2_3_steering","wheel_2_2_steering","glass1","glass2","glass3","glass4","","","","","light_l","light_r","light_l","light_r"],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]

Can anybody see anything resembling headlights? I thought t was "light_l" or "light_r" but had no affect.

Share this post


Link to post
Share on other sites

since hitpoints for lights do not have names and hit selection names duplicate, you will have to use setHitIndex. do what GOM suggested and then you know which one is which.

Share this post


Link to post
Share on other sites

Interesting, as GOM says if you shoot the lights out and recheck getAllHitPointsDamage you can see the four light of the HEMTT all have recieved damage.

Before shooting

[["HitFuel","HitEngine","HitBody","HitLFWheel","HitLBWheel","HitLMWheel","HitLF2Wheel","HitRFWheel","HitRBWheel","HitRMWheel","HitRF2Wheel","HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitRGlass","HitLGlass","HitGlass5","HitGlass6","","","",""],["palivo","motor","karoserie","wheel_1_1_steering","wheel_1_4_steering","wheel_1_3_steering","wheel_1_2_steering","wheel_2_1_steering","wheel_2_4_steering","wheel_2_3_steering","wheel_2_2_steering","glass1","glass2","glass3","glass4","","","","","light_l","light_r","light_l","light_r"],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
After shooting

[["HitFuel","HitEngine","HitBody","HitLFWheel","HitLBWheel","HitLMWheel","HitLF2Wheel","HitRFWheel","HitRBWheel","HitRMWheel","HitRF2Wheel","HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitRGlass","HitLGlass","HitGlass5","HitGlass6","","","",""],["palivo","motor","karoserie","wheel_1_1_steering","wheel_1_4_steering","wheel_1_3_steering","wheel_1_2_steering","wheel_2_1_steering","wheel_2_4_steering","wheel_2_3_steering","wheel_2_2_steering","glass1","glass2","glass3","glass4","","","","","light_l","light_r","light_l","light_r"],[0,0,0.729648,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.972654,0.972487,0.972654,0.972487]]
Using setHitPointDamage has no effect on the lights and reading the wiki says

Set the current level of damage for a specific Hit Point (specified by its config class).

Notice the bit I have made bold. When checking the HMETTs config it has no hitpoint classes for "light_l","light_r","light_l","light_r".

The main lights seem to have two lights a high and low beam. Using setHit works but only takes out the high beams im presumming this is to do with them being named the same "light_l" and "light_l" and the engine finds the first match so never sets the damage for the second light of the same name.

EDIT: See KK posted while i was righting this and provided your answer.

Share this post


Link to post
Share on other sites

Hey anfo, its your lucky day, as you're being helped by the Dream Team:  Grumpy Old Man, Larrow, and the infamous KillZone Kid! :P

Share this post


Link to post
Share on other sites

just want to add my conclusion for this topic, because there is no clear conclusion to this topic.


I'm new with this Arma scripting and  it took me a very long time figuring  this out.

 

setpilotlight, lightOn, lightOff will not work due to AI behavior. then i read this

On 11/18/2016 at 4:08 PM, killzone_kid said:

you can always destroy headlights

this made me chuckle, been searching all over on how to force AI to turn the head lights off then this,

just destroy the headlights :soldier:, it never occurred in my mind you can do this.

 

setHitIndex

On 11/20/2016 at 6:34 PM, killzone_kid said:

since hitpoints for lights do not have names and hit selection names duplicate, you will have to use setHitIndex. do what GOM suggested and then you know which one is which.

 

getting all the damage points (used a Debug Console)

_x = "I_MRAP_03_gmg_F" createVehicle position player; 
_hitme = getAllHitPointsDamage _x;
hint (format["hit: %1 \n", _hitme]);
copyToClipboard str _hitme;

Result is a very long line

[["HitLFWheel","HitLF2Wheel","HitRFWheel","HitRF2Wheel","HitFuel","HitEngine","HitBody","HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitRGlass","HitLGlass","HitGlass6","HitLBWheel","HitLMWheel","HitRBWheel","HitRMWheel","","","","","HitTurret","HitGun","HitTurret","HitGun"],["wheel_1_1_steering","wheel_1_2_steering","wheel_2_1_steering","wheel_2_2_steering","palivo","motor","karoserie","glass1","glass2","glass3","glass4","glass5","","","","","","","","light_l","light_l","light_r","light_r","vez","zbran","commander_turret_hit","commander_gun_hit"],[1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.934845,0.934845,0.93773,0.93773,0,0,0,0]]			

at the end of the line, there is this "light_l"    ,"light_l"    ,"light_r"    ,"light_r",

from KKs comment is case of duplicate hit selection use HitIndex


i did this for testing and confirmation of the HitIndex

[
["HitLFWheel"			,"HitLF2Wheel"			,"HitRFWheel"			,"HitRF2Wheel"			,"HitFuel"	,"HitEngine","HitBody"	,"HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitRGlass","HitLGlass","HitGlass6","HitLBWheel"	,"HitLMWheel"	,"HitRBWheel"	,"HitRMWheel"	,""			,""			,""			,""			,"HitTurret","HitGun"	,"HitTurret"			,"HitGun"],
["wheel_1_1_steering"	,"wheel_1_2_steering"	,"wheel_2_1_steering"	,"wheel_2_2_steering"	,"palivo"	,"motor"	,"karoserie","glass1"	,"glass2"	,"glass3"	,"glass4"	,"glass5"	,""			,""			,""			,""				,""				,""				,""				,"light_l"	,"light_l"	,"light_r"	,"light_r"	,"vez"		,"zbran"	,"commander_turret_hit"	,"commander_gun_hit"],
[0						,0						,0						,0						,0			,0			,0			,0			,0			,0			,0			,0			,0			,0			,0			,0				,0				,0				,0				,0			,0			,0			,0			,0			,0			,0						,0]]
			1					2						3						4					5			6			7			8			9			10			11			12			13			14			15			16				17				18				19				20			21			22			23			24			25			26						27

     edit: NOTE: text indent are not align,
the 4th line, i numbered it to get the hitIndex, so "light_l"    ,"light_l"    ,"light_r"    ,"light_r" is at

index 20, 21, 22, 23.

	_x setHitIndex [20, 1];
	_x setHitIndex [21, 1];
	_x setHitIndex [22, 1];
	_x setHitIndex [23, 1];

but there is still light can't understand why, so further testing i added this line

_x setHit ["light_l", 1];
_x setHit ["light_r", 1];
note: this lines alone will turn headlight off for bikes

 

hahahaha,  all head light are off/gone.

 

  • Like 1

Share this post


Link to post
Share on other sites
On 11/21/2016 at 7:01 AM, johnnyboy said:

Hey anfo, its your lucky day, as you're being helped by the Dream Team:  Grumpy Old Man, Larrow, and the infamous KillZone Kid! :P

 

Says the guy with a ton of amazing scripts in his signature :don12:

  • Like 1

Share this post


Link to post
Share on other sites

Granted this is an old topic but the subject is still very relevant. For the sake of snippet harvesters like me, what line of code can we take to hit the head lights on any vehicle? Or, perhaps, is every line going to be different beause of different hitpoints?

 

So Guy's line

 

this setHit ["light_l", 1];
this setHit ["light_r", 1];

 

Seems to work on Marshalls. Not tested on other vehs.

Share this post


Link to post
Share on other sites

I guess you can't do anything. The lights seems to be undestroyable on Marshall.

 

the only way I found so far, probably more CPU demanding (but kill it when you don't use anymore):

 

- give a name to apc (tk1)

addMissionEventHandler ["eachFrame", {tk1 setPilotLight false}];

 

(don't know why the old onEachFrame EH ( onEachFrame {tk1 setPilotLight false}; ) doesn't work reliably from script, just fine from console..

Share this post


Link to post
Share on other sites

update   for Arma 3 v1.82.144710

 

hit index moved


bike ,  2 lights at index 21
"#light_l",    "#light_r"],


MRAP  ,  4 lights at index 25-28
"#light_l","#light_l","#light_r","#light_r"]

 

Marshall  has 6 lights at index = 25 -30
"#light_l","#light_l_flare","#light_l2_flare","#light_r","#light_r_flare","#light_r2_flare"


B_MBT_01_TUSK_F ,   has 4 lights  at  index 22
"#light_l",    "#light_r",    "#light_l_flare",    "#light_r_flare",

 

is there a script command to find just the word "light" in the array, then from there, you will get the

index location?

 

i was trying this but could not get it to work , i'm not good at this.

 

hint str "";
_x = cursortarget;                          'target veh
_array = getAllHitPointsDamage _x;
_g = (_array select 0);             get the first array only                    
{

_st = _x joinstring " ";                           merge the index , just in case
_st = _st splitString "#_,";                     remove the # and _    from   #light_l_flare  =  result will be "light" "l" "flare"
_st = {_x == "light"} find _st;              check if there is a word light
if (_st > 0) then                                     check if true
    {
    _hitme = (_array select 0) find _x;          get the index number
    _x setHitIndex [_hitme, 1];                      
    };
} forEach _g;
 

 

 

Share this post


Link to post
Share on other sites

Since 1.82, you can completely remove the driver of a tank or car, and allow the commander full control of the vehicle - driving and gunning, with the parameter hasDriver=-1. This is great for little one-man tanks, and there's no invisible AI trying to drive off with it. However, it only allows the CMDR to move the vehicle, not turn on/off lights, engine, or other driver operations. I was hoping to find an answer here... maybe it has something to do with

On 11/18/2016 at 1:03 AM, Grumpy Old Man said:

setPilotLight command. ... "LightOn" or "LightOff".

No clue why this command has been introduced since it... [does nothing] different than the light on/off actions.

 

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

×