Hello
How do I get ect. a barrel or can (or any unit) to explode when a bullet or two hits it?
I think it would be a cool effect to add to the battlefield.
Hope you can help me
Best regards
Jacob
Hello
How do I get ect. a barrel or can (or any unit) to explode when a bullet or two hits it?
I think it would be a cool effect to add to the battlefield.
Hope you can help me
Best regards
Jacob

Please do not crosspost. If you posted by accident in a wrong forum, report your post and ask for movement.
Okay sry about that. You may remove my other theard in the mission forum.
Does anyone know how to make a trigger to be activated on bullet impact??
Add this to your barrel's init line:
(You can change "G_40mm_HE" to whatever projectile you want to use. You can find the list here under Ammo classnames)PHP Code:this addEventHandler ["hit", {[_this, "G_40mm_HE"] execVM "explode.sqf"}];
Create a file called "explode.sqf" in the mission root (where mission.sqm is located). Put this into it:
PHP Code:_obj = (_this select 0) select 0;
_type = _this select 1;
_bomb = _type createVehicle (getPos _obj);
_bomb setPos (getPos _obj);
Thank you very much, ill try that.
Where did you find the "hit" code, if that is the code, that makes the barrel react to the hit of a projectile?
What if I want any bullet that hits the barrel to make it explode? is there a some allround ammo-code that I can substitude with the G_40mm_HE?
I looked through the Event Handler wiki thing and found out that you can type "", insteed of giving a given weapontype. Would that work, so all hits from any weapon would cause the explosion?
Last edited by JacobJ; Dec 13 2009 at 12:52.
The script gets triggered no matter what hits it, the ammo classname is the projectile that gets created for the explosion (a 40mm grenade in this case).
Okay nice. Thank you very much.
Okay I dont know what I did wrong, but now it is working with the barrel.
I still cant shoot a flying helicopter with this.. what can I do?
Last edited by JacobJ; Dec 14 2009 at 10:46.