Jump to content
Sign in to follow this  
Arched

HandleDamage Question

Recommended Posts

Hello ther

I've been looking around everywhere and I can't seem to find what I'm looking for anywhere

So I wanted to trigger a car explosion once you shoot it with a sniper rifle.

So I thought the best to do it was a HandleDamage EH, however I have no clue how to do it cause I've never worked with EHs before, so how should I do this?

Any help is appreciated

Thanks in advance,

Cheers

Share this post


Link to post
Share on other sites

You'll want to add the event handler, and check that the bullet is the same kind fired from sniper rifles. If it is, set the car damage to 1.

this addEventHandler ["HandleDamage",
{
private "_return";
_return = 0; //car is invincible unless conditions are met
if (isPlayer (_this select 3)) then //shot must be from a player/prevents AI fluke
{
	if ((_this select 4) == "RIFLE_BULLET_CLASSNAME") then //additionally, the ammo used must be correct.
	{
		_return = 1; //allow engine to handle setting the damage, you could also use (_this select 0) setDamage 1; it would do the same thing
	};
};
_return;
}];

Use a "Fired" event handler to get the classname of the bullet you want to use:

//add to player
this addEventHandler ["Fired",
{
hint (_this select 4);
}];

Share this post


Link to post
Share on other sites

Or just a HitPart, does all the same without the second EH.

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  

×