Jump to content
Sign in to follow this  
Kommiekat

Attach Smoke grenade to barrel

Recommended Posts

Hello, I was wondering if this could be done and how.

I need to attache, say, a red smoke grenade to a red barrel and then have it activate when either bluefor or opfor is present in the trigger area.

Reason why:

To mimic a container like a barrel that is full of toxic poisonous gas and is leaking it out.

So green smoke for green barrel and red smoke for red barrel.

Thank you for your help.

Share this post


Link to post
Share on other sites

Change variable names/locality as needed:

_redSmoke = "SmokeShellRed" createVehicle (position redBarrel);
_redSmoke attachto [redBarrel, [0,0,0]];

Green smoke would be "SmokeShellGreen", other colors follow the same format (white being simply "SmokeShell").

redsmoke_zps7499a71f.jpg

If you want constant smoke, you'll need to loop the script every 20-30 seconds, depending on how long a smoke shell lasts and taking into account falloff of the previous shell and buildup of the new one.

*edit* - 25 seconds. Take a look at W0lle's post at the end of this thread: http://www.armaholic.com/forums.php?m=posts&q=8631&print=topic

Edited by Harzach

Share this post


Link to post
Share on other sites

Hey Harzach, thanks for that.

Looks like you got it to work.

Could you kindly send me the mission.sqm that you used to make that happen with the script as well?

I'd like to test it out and learn more from it.

Credits going to you for sure on this one when I release the mission.

Cheers!

Share this post


Link to post
Share on other sites

I didn't save a mission, but it's pretty simple. Here's W0lle's example tweaked for your purpose:

smoke.sqf (looping)

private ["_smoke","_shells","_pos","_color","_type"];

_shells = ["SmokeShellGreen","SmokeShellRed"];
_pos = _this select 0;
_color = _this select 1;
_type = _shells select _color;

while {true} do
{
 _smoke=_type createVehicle [getPos _pos select 0, getPos _pos select 1, 0.5];
 sleep 25;
};

smoke.sqf (no loop)

private ["_smoke","_shells","_pos","_color","_type"];

_shells = ["SmokeShellGreen","SmokeShellRed"];
_pos = _this select 0;
_color = _this select 1;
_type = _shells select _color;

_smoke=_type createVehicle [getPos _pos select 0, getPos _pos select 1, 0.5];

Place a barrel in the editor, no need to name it. In the init line, put:

nul=[this,#] execVM "smoke.sqf"

"#" is either 0 (for green smoke) or 1 (for red smoke). You can add other colors by including their classnames in the _shells array.

The barrel should start emitting smoke on mission start, and continue until mission end.

If you want to call the script at a specific time, via trigger, other script, etc, then name the barrel (I'll name it "barrel_1") and call the script this way:

nul=[barrel_1,#] execVM "smoke.sqf"

There is certainly no need to credit me, just passing along public information, but thank you!

*edit* - Ah, easy enough - here's a mission with three barrels. On the left, a red barrel that will emit red smoke on mission start, no loop. On the right, a green barrel that will emit green smoke when you get within ten meters, no loop. Straight ahead, a black barrel that will emit white smoke when you get within ten meters, looping.

https://dl.dropboxusercontent.com/u/61752237/missions.zip

Edited by Harzach

Share this post


Link to post
Share on other sites

Hey Harzach!

Thanks mucho for that!

Will save me hours of editing time!

Share this post


Link to post
Share on other sites

I forgot to add the attachTo bit. Not a huge deal, but it might look better. I arbitrarily set Z to 0.5, so another value might look better. This is mainly to make the smoke appear to emit from the top of the barrel.

smoke.sqf (looping)

private ["_smoke","_shells","_pos","_color","_type"];

_shells = ["SmokeShellGreen","SmokeShellRed","SmokeShell"];
_pos = _this select 0;
_color = _this select 1;
_type = _shells select _color;

while {true} do
{
 _smoke=_type createVehicle [getPos _pos select 0, getPos _pos select 1, 0.15];
_smoke attachTo [_pos,[0,0,0.15]];  //  add this line, change the Z value to whatever looks best
 sleep 25;
};

smoke.sqf (no loop)

private ["_smoke","_shells","_pos","_color","_type"];

_shells = ["SmokeShellGreen","SmokeShellRed","SmokeShell"];
_pos = _this select 0;
_color = _this select 1;
_type = _shells select _color;

_smoke=_type createVehicle [getPos _pos select 0, getPos _pos select 1, 0.15];
_smoke attachTo [_pos,[0,0,0.15]];  //  add this line, change the Z value to whatever looks best

*edit* - Fixed attachTo code, sorry for any confusion. Also tested Z value, 0.15 seems ideal.

Edited by Harzach

Share this post


Link to post
Share on other sites

With the script above I have created a wall of smoke.

Instead of using a barrel I used a baseball. It is tiny and difficult to see in grass.

Instead of using one baseball I used 20. I placed them in a straight line across a field. I named them base01 through base20.

In the trigger I typed 20 commands:

nul=[barrel01,2] execVM "smoke.sqf"; through to nul=[barrel20,2] execVM "smoke.sqf";

When the trigger fires, a wall of white smoke is created.

If you feel the smoke dissipates too fast, create a second trigger that runs the script a second time .

There is some great stuff on this forum!

Share this post


Link to post
Share on other sites

For some reason, that only the Editor God itself can understand, I can't get the trigger to initialize.

I've got a barrel named "barrel01"

Trigger
Bluefor
Present
player in thislist;
nul=[barrel01,1] execVM "Scripts\smokeLoop.sqf";

As you can see, the file is located in my "Scripts" folder.

Player is Bluefor and walk into the trigger zone set at Axis a and b, 3.

Perhaps the CONDITION is wrong?

If I don't use a trigger, then the barrel will work.

But I need the player to approach the barrel to simulate an initiation of the smoke, leaking out of the barrel,

therefore, a trigger does come in handy, if I can get the !BASTARD! to work.

Share this post


Link to post
Share on other sites

Place your script in the mission file.

In the trigger you would type: nul=[barrel01,1] execVM "smokeLoop.sqf";

.

Share this post


Link to post
Share on other sites
Perhaps the CONDITION is wrong?

(vehicle player) in thisList

---------- Post added at 21:53 ---------- Previous post was at 21:49 ----------

Instead of using a barrel I used a baseball. It is tiny and difficult to see in grass.

Use this hideObject true on your anchor objects to make them invisible. Invisible helipads are even better.

---------- Post added at 22:22 ---------- Previous post was at 21:53 ----------

Here's an all-in-one version. The script takes a third argument in the form of an integer indicating how many times to loop the script. A negative value is an infinite loop.

nul=[this,_color,_loop] execVM "smoke.sqf"

smoke.sqf

private ["_smoke","_shells","_pos","_color","_loop","_type"];

_shells = ["SmokeShellGreen","SmokeShellRed","SmokeShell"];
_pos = _this select 0;
_color = _this select 1;
_loop = _this select 2;
_type = _shells select _color;

if ( _loop >= 0 ) then 
{
for "_i" from 0 to _loop do
{
	_smoke=_type createVehicle [getPos _pos select 0, getPos _pos select 1, 0.15];
	_smoke attachTo [_pos,[0,0,0.15]];  //  change the Z value to whatever looks best
	sleep 25;
};
} 

else

{
while {true} do
{
	_smoke=_type createVehicle [getPos _pos select 0, getPos _pos select 1, 0.5];
	_smoke attachTo [_pos,[0,0,0.15]];  //  change the Z value to whatever looks best
	sleep 25;
};
};

Share this post


Link to post
Share on other sites

Hi Harzach,

Could you kindly make an example with trigger activation from a unit walking into it for downloading?

That would greatly help me out mucho. I'm on mission 3. One more to go before release.

---------- Post added at 03:37 PM ---------- Previous post was at 02:42 PM ----------

Place your script in the mission file.

In the trigger you would type: nul=[barrel01,1] execVM "smokeLoop.sqf";

.

That should not matter, but what the heck, I'll try it out anyways.

Share this post


Link to post
Share on other sites

nul=[barrel01,1] execVM "Scripts\smokeLoop.sqf"

As you can see, the file is located in my "Scripts" folder.

Your scripts folder would most likely be stored on the "C" drive hence: "C:\ ............"Scripts\smokeloop.sqf"

.

.

Share this post


Link to post
Share on other sites
Your scripts folder would most likely be stored on the "C" drive hence: "C:\ ............"Scripts\smokeloop.sqf"

.

.

Most missionmakers place a "scripts" folder in their mission file, or at least a tagged folder for their own scripts. We can assume this is the case with Kat's mission, as he describes the script as working when called directly. It was an issue with his trigger condition "player in thisList", which needed to be "(vehicle player) in thisList".

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  

×