I tried to do it once before but didn’t like the outcome. This time it is good enough to share. So basically in Arma 3 there are 3 barrel objects, empty, full and empty but with option to have a fire burning. The one we are going to use is “Land_MetalBarrel_F”, which also has a flammable sign. Since the sign doesn’t specify what is inside, we can just assume it has a really volatile mixture that should not even be shaken! :)

barrels

I often envy the modders, they can add remove objects, assign new properties to objects, like for example in this case it would have been so easy to make this barrel a bomb that detonate on impact. But trying to achieve the same with scripting only means you do not need to download mods, just the mission. Until BIS make mod requisition and initialisation as easy as connecting to a server and downloading the mission, I will continue focusing on this approach.

So I wanted to make this barrel a stand alone extra for a mission designer. Basically a bunch of barrels spawned on mission start in predefined locations and just stand there creating danger. Once barrel exploded, it is gone and doesn’t respawn, same principle as building destruction. The barrel will explode from bullet impact, nearby explosion, including that of another barrel, and if the barrel is moved.

I’m pretty sure there are other ways of doing the same thing, but I’m pretty happy with mine for now. I used “R_TBG32V_F” class warhead to create explosion because it has moderate destructive power, nice particle effect and convincing camera shake. As you can see from config, it also has anti infantry properties:

class R_TBG32V_F: R_PG32V_F
{
	hit = 100;
	indirectHit = 50;
	indirectHitRange = 5;
	model = "\A3\weapons_f\launchers\RPG32\tbg32v_rocket.p3d";
	CraterEffects = "ArtyShellCrater";
	ExplosionEffects = "MortarExplosion";
	allowAgainstInfantry = 1;
	class CamShakeExplode
	{
		power = "(110*0.2)";
		duration = "((round (110^0.5))*0.2 max 0.2)";
		frequency = 20;
		distance = "((5 + 110^0.5)*8)";
	};
};

Because I used a bunch of local event handlers, barrels should be spawned on the server only. However putting them in place could be a bit tricky as they can explode when shaken, remember? So I added 1 second cooldown, so if the coordinates of barrel position are not very precise, the barrel will have 1 second to come to rest. And here is the code:

if (isServer) then { ExplosiveBarrelsScript = [ [120,[1790.44,5444.02,5.50144]], [100,[1791.79,5443.62,5.50144]], [180,[1791.57,5444.7,5.50144]] ] spawn { Barrel_BOOM = compileFinal ' _ex = createVehicle [ "R_TBG32V_F", _this modeltoworld [0,0,0], [], 0, "CAN_COLLIDE" ]; _ex setVectorDirAndUp [[0,0,1],[0,-1,0]]; _ex setVelocity [0,0,-1000]; deleteVehicle _this; '; _bars = []; { _b = createVehicle [ "Land_MetalBarrel_F", [0,0,0], [], 0, "NONE" ]; _b setDir (_x select 0); _b setPosASL (_x select 1); _b setDamage 0.99; _b allowDamage false; _b addEventHandler ["Hit", { _b = _this select 0; if (alive _b) then {_b setDamage 0.99}; }]; _bars set [_forEachIndex, _b]; } forEach _this; sleep 1; { _x setVariable ["#PosASL", getPosASL _x]; _x addEventHandler ["EpeContact", { _b = _this select 0; if ( (getPosASL _b) distance (_b getVariable "#PosASL") > 0.1 ) then {_b call Barrel_BOOM}; }]; _x addEventHandler ["Killed", {_this select 0 call Barrel_BOOM}]; _x allowDamage true; } count _bars; }; };

The array of barrel coordinates should be ASL (get individual coordinates with getPosASL player). It is nested and should also contain barrel direction. The example coordinates are for Stratis airfield, so create your own.

barrels2

Enjoy,
KK