Jump to content
Sign in to follow this  
mcvittees

addeventhandler "hit" and vehicles

Recommended Posts

I'm trying to get an armoured vehicle to stop when it takes incoming fire and then move off again when once the player has cleared the area. My idea was to add a "hit" event handler to the vehicle to get it to stop (via setfuel 0) and then by a radio command get them to move again (via setfuel 1).

In the vehicle's (Lav1) init:

this addEventHandler ["hit", {Lav1 setfuel 0}];

The problem is, when I shoot at the Lav the handler doesn't seem to fire. If I put the same code in a infantry unit's init and shoot him, the code works and the Lav stops.

Where am I going wrong?

Share this post


Link to post
Share on other sites

try to use "Dammaged" insteed

Hit

Triggered when the unit is hit/damaged.

Is not always triggered when unit is killed by a hit.

Most of the time only the killed event handler is triggered when a unit dies from a hit.

The hit EH will not necessarily fire if only minor damage occurred (e.g. firing a bullet at a tank), even though the damage increased.

Does not fire when a unit is set to allowDamage false.

Dammaged

Triggered when the unit is damaged. In ArmA works with all vehicles not only men like in OFP.

Share this post


Link to post
Share on other sites

there is a "dostop" command, maybe not very handy for you but it's an idea.

you can execute it through the radio (by adding a trigger)

I used to do the same: when I was not the leader of the squad I used "dostop" to stop the leader when a firefight began, when it was over I used the second radio command with on act: "domove" to move to wp's again.

Share this post


Link to post
Share on other sites

From the Biki:

Hit

Triggered when the unit is hit/damaged.

Is not always triggered when unit is killed by a hit.

Most of the time only the killed event handler is triggered when a unit dies from a hit.

The hit EH will not necessarily fire if only minor damage occurred (e.g. firing a bullet at a tank), even though the damage increased.

Does not fire when a unit is set to allowDamage false.

Local.

Passed array: [unit, causedBy, damage]

unit: Object - Object the event handler is assigned to

causedBy: Object - Object that caused the damage.

Contains the unit itself in case of collisions.

damage: Number - Level of damage caused by the hit

As nikita320106 said, Dammaged is your best bet.

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  

×