Mensur 1 Posted December 28, 2012 Hi, Does anyone know how to attach smoke grenade to a tank, so that it produces generated smoke screen. And how do I make it so that I can turn it on and off? Thanks. Share this post Link to post Share on other sites
iceman77 18 Posted December 28, 2012 you could give this a try. _smoke = "SmokeShellRed" createVehicle (position tank); _smoke attachto [tank, [3,2,.5]]; Share this post Link to post Share on other sites
Mensur 1 Posted December 29, 2012 im a total noob, when it comes to scripting, could you please break that down for me? I'd really appreciate it. Share this post Link to post Share on other sites
eagledude4 3 Posted December 29, 2012 How do you want to toggle the grenade on and off? Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted December 29, 2012 (edited) The commander in most armoured vehicles can press "R" to fire smoke grenades??? If you want the thing where they squirt oil into the exhaust to make dense white fog as they drive along I will have a go at it? Edited December 29, 2012 by Mattar_Tharkari Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted December 29, 2012 (edited) OK this works well: Example mission:https://dl.dropbox.com/u/37698503/smoke_gen.Shapur_BAF.zip In your init.sqf: {if (_x isKindOf "Wheeled_APC" || _x isKindOf "Tank") then { _x addaction [("<t color=""#ee6600"">" + ("Smoke Plume") +"</t>"), "smoke.sqf","", 1, false, true,"LaunchCM","isEngineOn _target && driver _target == _this"];}; } forEach vehicles; Adds the action to all tanks and APCs. Conditions added, Only the driver will see the action and only if the engine is on. Shortcut key is R, press R to trigger the shortcut without having to scroll and click. You can't trigger it from outside the vehicle. smoke.sqf: _vcl = _this select 0; _caller = _this select 1; _id = _this select 2; //_vcl removeAction _id1; //uncomment to use the action only once _smoke = createVehicle ["ARTY_SmokeShellWhite", getPosATL _vcl, [], 0, "CAN_COLLIDE"]; _smoke attachto [_vcl, [0,-3,-0.5]]; //this position works for all US armour and APCs - test it with everything - if you can see the shell PM me and I will change script to switch position according to class. sleep 3.5; _smoke2 = createVehicle ["ARTY_SmokeShellWhite", getPosATL _vcl, [], 0, "CAN_COLLIDE"]; _smoke2 attachto [_vcl, [0,-3,-0.5]]; Edited December 29, 2012 by Mattar_Tharkari posted example mision again - missing ; after select 2 Share this post Link to post Share on other sites
Mensur 1 Posted December 29, 2012 The arty smoke shell ain't all that. I think the Smoke grenade replicates it much better, take a look at this video: Working with your script now. ---------- Post added at 05:33 PM ---------- Previous post was at 05:27 PM ---------- Its not working dude. : \ Share this post Link to post Share on other sites
tryteyker 28 Posted December 29, 2012 Are you sure you met all the conditions for the action to be displayed? The engine has to be on, it has to be an APC or Tank, and you have to be the driver. @Mattar What I noticed is that you don't remove the action in the script (I know you got a commented-out line there), doesn't this cause the addAction to duplicate itself? I don't know addAction's advanced syntax at all so it may be hidden there within the true, false etc statements, but everytime I used an addAction and didn't remove it at the beginning of the script it duplicated itself, but the addAction before the duplicate was unusable. Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted December 29, 2012 Didn't think the smoke grenade had the volume to hide a tank? Just tested my script against some Takis with RPG's - it works - they can't see through the smoke. Mission reposted - accidentally put a : instead of a ; on 1 line. Something extra - launch smoke grenades option for the driver: init.sqf: {if (_x isKindOf "Wheeled_APC" || _x isKindOf "Tank") then { _x addaction [("<t color=""#ee6600"">" + ("Launch Smoke Grenades") +"</t>"), "smokenades.sqf","", 1, false, true,"","driver _target == _this"];}; } forEach vehicles; smokenades.sqf _vcl = _this select 0; _caller = _this select 1; _id = _this select 2; [_vcl,4.0,120,false,false] spawn BIS_Effects_SmokeLauncher; @tryteyker Never had an addAction duplicate itself in single player unless you add it more than once elsewhere? Where it does duplicate is in multiplayer where you can accidentally have it running on server and client at the same time. Script above are single player only. Share this post Link to post Share on other sites
Mensur 1 Posted December 29, 2012 [_vcl, [0,-3,-0.5] This is what is messed up, it doesn't work. What iceman gave me above: [3,2,.5]]; Does work. However, the smoke grenade appears like a foot above the tank. Now how do i make the smoke grenade ignite from the tank within? Is the question. Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted December 29, 2012 If you read what I said about that........you need something like this: http://community.bistudio.com/wiki/switch http://community.bistudio.com/wiki/Control_Structures _class = typeOf _vcl; switch (_class) do {case "M1A2_US_TUSK_MG_EP1": { _smoke attachto [_vcl, [0,-3,-0.5]]; }; case "MLRS_DES_EP1": { _smoke attachto [_vcl, [0,-3,-0.5]]; }; //etc etc for each type of tank where you need to change the position }; Share this post Link to post Share on other sites
iceman77 18 Posted December 29, 2012 [_vcl, [0,-3,-0.5] This is what is messed up, it doesn't work.What iceman gave me above: [3,2,0.5]]; Does work. However, the smoke grenade appears like a foot above the tank. Now how do i make the smoke grenade ignite from the tank within? Is the question. Mess with the values in the array: [3,2,0] to suit your needs. The values determine the x,y & z coordinates. Share this post Link to post Share on other sites
Mensur 1 Posted December 29, 2012 [-1.5,-3,-1.1]]; That works perfectly with the T55. for smoke: _smoke = "SmokeShell" createVehicle (position tank); _smoke attachto [tank, [-1.5,-3,-1.1]]; init: {if (_x isKindOf "Wheeled_APC" || _x isKindOf "Tank") then { _x addaction [("<t color="#ee6600"">" + ("SmokeScreen") +"</t>"), "smoke.sqf","", 1, false, true,"LaunchCM","isEngineOn _target && driver _target == _this];}; } forEach vehicles; Now how do i make it so i can turn it off and on? Share this post Link to post Share on other sites
iceman77 18 Posted December 29, 2012 deletevehicle _smoke Share this post Link to post Share on other sites
Mensur 1 Posted December 29, 2012 where do i put that? (sorry guys, told you im a newbie, still learning). Share this post Link to post Share on other sites
iceman77 18 Posted December 30, 2012 When you want to turn the smoke "off" you would simply delete the smoke shell/grenade. And then recreate it when you want to turn it on. I can't sit down and write the whole thing for you & test it atm. Anyhow, something along those lines. If you're not understanding variables then I suggest having a look @ Mr.Murrays editing guide. Look into how variables work. _smoke = "SmokeShell" createVehicle (position tank); _smoke attachto [tank, [-1.5,-3,-1.1]]; waitUntil {someVariable}; // waituntil a variable is true deletevehicle _smoke; //delete the smoke grenade someVariable=false; //set the variable back to false Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted December 30, 2012 (edited) I would have a look at the mission I posted in http://forums.bistudio.com/showthread.php?144053-How-to-attach-smoke-greande-Help!&p=2270506&viewfull=1#post2270506 It generates a more realistic ammount of smoke and you don't need to turn it off - shell deletes itself after 3.5 seconds, but if you really want to use a smokeshell, try this init.sqf {if (_x isKindOf "Wheeled_APC" || _x isKindOf "Tank") then { _x addaction [("<t color=""#e6e600"">" + ("Smoke on") +"</t>"), "smokeshl.sqf","turnon", 1, false, true,"LaunchCM","isEngineOn _target && driver _target == _this"];}; } forEach vehicles; {if (_x isKindOf "Wheeled_APC" || _x isKindOf "Tank") then { _x addaction [("<t color=""#e6e600"">" + ("Smoke off") +"</t>"), "smokeshl.sqf","turnoff", 1, false, true,"","isEngineOn _target && driver _target == _this"];}; } forEach vehicles; smokeshl.sqf - turns on and off in same script depending on argument passed from addAction _vcl = _this select 0; _caller = _this select 1; _id = _this select 2; _arg = _this select 3; switch (_arg) do { case "turnon": { smokeCan = createVehicle ["SmokeShell", getPosATL _vcl, [], 0, "CAN_COLLIDE"]; smokeCan attachto [_vcl, [0,-3,-0.5]]; }; case "turnoff": { detach smokeCan; deleteVehicle smokeCan; }; }; Edited December 30, 2012 by Mattar_Tharkari Share this post Link to post Share on other sites
Mensur 1 Posted December 30, 2012 All-right, thanks guys, you've been of great help. :) Share this post Link to post Share on other sites
mikie boy 18 Posted December 30, 2012 just for info - the attachto position differs for each vehicle so it may be a trial and error situation Share this post Link to post Share on other sites