Jump to content
Sign in to follow this  
Omer

Make jerrycans explodable

Recommended Posts

I don't think they explode engine-wise when being hit. You could however make it explode with a handleDamage eventhandler (by spawning an explosion shell, like a HE Artillery Shell and deleting the object & eventhandler). I'll test this and update this with a quick example

Share this post


Link to post
Share on other sites

Well it'll be harder because it seems like the ACE Jerrycan also uses HandleDamage to spawn fire and _unit returns <null>. I will continue testing but I hope Xeno or somebody else from the ACE Team will be able to help you since I guess you're using the ACE Jerrycans.

Share this post


Link to post
Share on other sites

No, I'm using the regular jerrycans man

Share this post


Link to post
Share on other sites

What regular jerrycans? I haven't found any when not using ACE.

Share this post


Link to post
Share on other sites

They're in Objects (small) IIRC. Called "fuel can".

Share this post


Link to post
Share on other sites

///////////////////////////////////////////////////
//original .sqs script by JBOY: 
//http://www.ofpec.com/ed_depot/index.php?action=details&id=603&game=ArmA
///////////////////////////////////////////////////
///////////////////////////////////////////////////
//To use put following code in the barrel's init field:
/*
this addeventhandler ["killed",{ [_this select 0] execVM "barrelfun.sqf";}]
*/
///////////////////////////////////////////////////

if (!isServer) exitWith {};

_obj = _this select 0;

_speed = random 9;
_dir = random 359;
_zvel = 25 + (random 20);

sleep (random 4);

//_boom = "Sh_100_HE" createVehicle (getPos _obj);
_boom = "Grenade" createVehicle (getPos _obj);

sleep 0.4;

_obj setVelocity [_speed * sin(_dir), _speed * cos(_dir), _zvel];

Save as .sqf script and call it in the objects init line as shown in the commented section.

I´m using it as a standard on red barrels :dance1:

Share this post


Link to post
Share on other sites

I don't think you can add an eventhandler to all objects, and I think default Fuel_can is one of them. Barrels are no problem.

Share this post


Link to post
Share on other sites
I don't think you can add an eventhandler to all objects, and I think default Fuel_can is one of them. Barrels are no problem.

I've tested this and I can confirm that, it doesn't seem to be possible. Wonder how to make it work otherwise? Maybe use a damage-check instead?

Share this post


Link to post
Share on other sites

No damage model that's why the evh's don't work.

Here's a crude way to do it but it has problems, I took it from something I was trying a while back.

place this in an init of an object null=[] execvm "explode.sqf"

// null=[] execvm "explode.sqf"
while {alive player} do {
_shake = 0;	
_target = cursortarget;

switch (typeof _target) do {
case "Fuel_can": {_shake =  velocity _target;if (_shake  select 1 >= 0.05 or _shake  select 2 >= 0.05) then {  bomb = "grenade" createvehicle getpos _target; deletevehicle _target}};

};
_target = 0;
sleep 0.1;
};

The problem is tying it in with a fired command so all moving cans don't just explode when you look at them.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Noticed that right now. So that leaves us with making a triggered explosion, but I'm not sure if OP wants that.

Share this post


Link to post
Share on other sites

No way to do that for all jerry cans on the map?

Share this post


Link to post
Share on other sites

This seems to be working better

just place this in the players init

this addEventHandler ["fired",{_this execvm "explode.sqf";} ];

save as explode.sqf

_exit = false;
while {alive player and !_exit} do {
 _shake = 0;	
  _target = cursortarget;
   _shake =  velocity _target;

switch (typeof _target) do {
 case "Fuel_can": {if (_shake  select 1 != 0 or _shake  select 2 != 0) then {  bomb = "grenade" createvehicle getpos _target; deletevehicle _target}};

 default  {_exit = true};

};
_target = "";
sleep 0.1;
};

The script is run when the player fires the weapon, if you looking aiming at the jerry can and it moves then it will explode.

You can add other items as well.

if you want add another item, example suitcase then just add another case statement

	case "Suitcase": {if (_shake  select 1 != 0 or _shake  select 2 !=0) then {  bomb = "grenade" createvehicle getpos _target; deletevehicle _target}};

Sometimes it may take more than one shot.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks, going to test this

Share this post


Link to post
Share on other sites

How do I apply this to all players using the init.sqf? I've tried "player addEventHandler ["fired",{_this execvm "explode.sqf";} ]; "

Didn't work

Share this post


Link to post
Share on other sites

Don't know about MP but in single player it works in the init.sqf file.

Share this post


Link to post
Share on other sites

No idea on how to do this in MP?

Share this post


Link to post
Share on other sites

Tried executing it client-side?

if (isServer) exitWith {};

Added to the top of the explode.sqf

Share this post


Link to post
Share on other sites

And how to execute it in init.sqf?

Share this post


Link to post
Share on other sites

Any one knows how i can execute it to all players?

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  

×