evans d [16aa] 12 Posted April 9, 2014 Ladies and Gentlemen, I'm making a training map for a group I'm in. One of the ranges I'm making is a designated marksman range but the targets can be tricky to find at times. Therefore, I want a way to pop purple smoke nearby (see: not directly on) the targets that have not yet been hit. I have an idea that it may go thus (NOTE: I'm aware that the bellow is not proper syntax but it gets the message across): if (targets animate ["terc",1] then { _smoke = "smokeShellPurple" createVehicle within 10 meters of target; }; else { exit; }; The problem is, I have no idea how'd I'd reference the knocked down targets from the ones still up and then spawn the grenades. I have a gamelogic in the middle of the targets called "DMR" so I can use nearestObject if I need to, I'm just unsure of the rest of the code. Does anyone have any ideas for this? Many thanks, Bashkire. Share this post Link to post Share on other sites
lkincheloe 12 Posted April 9, 2014 You could have an array of the target names, and when a target is hit, remove it from that array (variablename = variablename - (obName) ). Then after x period of time, call the array with a forEach command. Share this post Link to post Share on other sites
evans d [16aa] 12 Posted April 9, 2014 So something like this in the init: DMRTargets = [T1,T2,T3,T4,T5] And then add an event handler to each one along the lines of: this addEventHandler ["Hit",{this exec "removeTarget.sqf"}]; removeTarget.sqf: _target = _this select 0; _removeTarget = DMRTargets - (_target); Something like that? Share this post Link to post Share on other sites
evans d [16aa] 12 Posted April 10, 2014 Ok, so my above theory / method didn't work. Can anyone else suggest another way? Share this post Link to post Share on other sites
cobra4v320 27 Posted April 10, 2014 DMRTargets = [T1,T2,T3,T4,T5]; {_x addEventHandler ["Hit",{DMRTargets = DMRTargets - (_this select 0)}]} forEach DMRTargets; Not tested at all by the way just guessing, but something like this should work. Share this post Link to post Share on other sites
evans d [16aa] 12 Posted April 10, 2014 Ah ha! You reply as I come bearing new news! My current script looks like this (removeTarget.sqf): hint "Target should be removed"; //Debug _target = _this select 0; sleep 5; if ((T5 animationPhase "terc") <= 0) then { _smoke1 = "smokeShellPurple" createVehicle getPos T5; } else { }; Now, as you can see, I'm only firing this script for T5 at present and it's working so far. When I change the if statement to read _target instead of T5 it flags an error (the error is flagged when it gets to the animationPhase line: "Type: Array. Expected: Object"). How would one reference all the targets in that line without having to do the somewhat untidy method of creating an if statement for all 14 targets? Share this post Link to post Share on other sites
cobra4v320 27 Posted April 10, 2014 this addEventHandler ["Hit",{[_this select 0] execVM "removeTarget.sqf"}]; removeTarget.sqf private "_target"; _target = _this select 0; if ((_target animationPhase "terc") == 0) then {_smoke = "smokeShellPurple" createVehicle (getPos _target)}; Share this post Link to post Share on other sites
evans d [16aa] 12 Posted April 10, 2014 The problem is that that script wont (I believe) spawn smoke grenades on the positions of the taregts that are still up. I think I'm sorrect in saying that the _this select 0; means that it will only reference the target that was hit and that doesn't need a smoke spawned on it. This brings us back to the problem of removing a target from an array and then referencing that array later to spawn the smoke, but the if statement doesn't like arrays meaning that everything's fucking up again. Share this post Link to post Share on other sites
cobra4v320 27 Posted April 10, 2014 Well then use what I posted above: DMRTargets = [T1,T2,T3,T4,T5]; {_x addEventHandler ["Hit",{DMRTargets = DMRTargets - (_this select 0)}]} forEach DMRTargets; Im guessing you are using some sort of a timer? How long do you have to make these shots? Share this post Link to post Share on other sites
evans d [16aa] 12 Posted April 10, 2014 (edited) Well, gentlemen, thank you for your time but I've gone with a much longer version of the script I wanted... one with 14 if statements... Many thanks again, people. EDIT: As a quick note, here's my script now. I don't know why I was trying to over complicate this in the first place. I feel rather foolish... spawnDMRSmoke.sqf: // initialize with // this addAction ["Target Hint", "scripts\Actions\spawnDMRSmoke.sqf","",0]; DMRTargets = [T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14]; { if ( ( _x animationPhase "terc" ) <= 0) then { _posX = position _x; _pX = _posX select 0; _pY = _posX select 1; _dX = (random 30) - 15; _dY = (random 30) - 15; _pX = _pX + _dX; _pY = _pY + _dY; _bum = "smokeShellPurple" createVehicle [_pX,_pY,125]; }; } forEach DMRTargets; NOTE: This script is intended for use with targets that will stay down once shot. Edited April 10, 2014 by Bashkire Share this post Link to post Share on other sites
f2k sel 164 Posted April 10, 2014 I think this would do the same thing. // initialize with // this addAction ["Target Hint", "scripts\Actions\spawnDMRSmoke.sqf","",0]; DMRTargets = [T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14]; { if ( ( _x animationPhase "terc" ) <= 0) then { _bum = createVehicle [ "smokeShellPurple",(_x modeltoworld [0,0,125]) ,[], 30, "none"]; }; } forEach DMRTargets; Share this post Link to post Share on other sites