derox 3 Posted February 24, 2014 Hello, I have been looking in too this for over a day now and i still dont get it. i have tryed many things but dident realy work out. I am using a script too simulate a mortar attack on a FOB but i want that if you kill the mortar gunner the script will stop repeating the simulation and will stop Script i used //null=["ARTY_Sh_122_HE",target,0.8,220,30,50]execVM "artillery.sqf" _ammotype = _this select 0;//ARTY_Sh_122_HE type of ammo to be used _target = _this select 1;//target of artillery fire _delay = _this select 2;//0.8 delay between each shell _height = _this select 3;//220 height shells will fall from _amount = _this select 4;//30 total shells fired _spread = _this select 5;//50 how close they will be to the target hint "1"; // this is too see if the script is working. while {alive gunner _mortar} do { //<--------------- Added by me for "_x" from 1 to _amount do { _targetpos = [getPos _target select 0, getPos _target select 1, _height]; _Strike = createVehicle [_ammotype, _targetpos, [], _spread, "NONE"]; _Strike allowdamage false; _Strike setvectorup [0,9,0.1]; _Strike setvelocity [0,0,-200]; sleep _delay; hint "2"; // this is too see if the loop is working }; }; now the problem is that i have tryed to make a unit with _Mortar = createvehicle etc. and i have tryed _Mortar = [mortar] (mortar is the name of the unit in game.) non of this examples did realy work out. except the script runned but still dident stop when i shot that gunner. in the state the script is now it will not work since there is no _mortar yet. I hope somone is able to help me that would be great. thanks :D Share this post Link to post Share on other sites
f2k sel 164 Posted February 24, 2014 Don't use the underscore when you create the mortar and don't use it in your script. Mortar = createvehicle etc while {alive gunner mortar} do { Share this post Link to post Share on other sites
derox 3 Posted February 24, 2014 Okey but how to connect the variable to an object or somting like that. what i want is that if mortar is dead that his script will stop Share this post Link to post Share on other sites
morieza 10 Posted February 24, 2014 Where did you put: _Mortar = createvehicle etc... I think: _Mortar = createvehicle etc... while {alive gunner _mortar} do { must be on the same script (local). Share this post Link to post Share on other sites
f2k sel 164 Posted February 24, 2014 Not really following but you could use target and when that is destroyed end the shelling. null=["ARTY_Sh_122_HE",mortar,0.8,220,30,50]execVM "artillery.sqf" //null=["ARTY_Sh_122_HE",target,0.8,220,30,50]execVM "artillery.sqf" _ammotype = _this select 0;//ARTY_Sh_122_HE type of ammo to be used _target = _this select 1;//target of artillery fire _delay = _this select 2;//0.8 delay between each shell _height = _this select 3;//220 height shells will fall from _amount = _this select 4;//30 total shells fired _spread = _this select 5;//50 how close they will be to the target hint "1"; // this is too see if the script is working. for "_x" from 1 to _amount do { _targetpos = [getPos _target select 0, getPos _target select 1, _height]; _Strike = createVehicle [_ammotype, _targetpos, [], _spread, "NONE"]; _Strike allowdamage false; _Strike setvectorup [0,9,0.1]; _Strike setvelocity [0,0,-200]; sleep _delay; hint "2"; // this is too see if the loop is working if (!alive gunner _target) exitwith {hint "Dead"}; }; Share this post Link to post Share on other sites
derox 3 Posted February 25, 2014 I will explain it again. I have a mission where i need an AI mortar to fire at some point on the map (target T1) but when the mortar starts to fire the player will get a new task to destroy the enemy mortar. So i want that if the mortar is dead that the script stops running. because this script simulates a mortar attack and the shells are spawned by the script and not shot from the mortar it self. so i did put in the part with while alive. But he doesnt see that unit in the game with the name mortar. If he dies the script needs to stop spawning the shells. This is the trigger that starts the script. null=["ARTY_Sh_122_HE",T1,7,220,30,70]execVM "artillery.sqf" Here i tryed to make a mortar maby the script would recognize it as _mortar but still dident work. //null=["ARTY_Sh_122_HE",target,0.8,220,30,50]execVM "artillery.sqf" _ammotype = _this select 0;//ARTY_Sh_122_HE type of ammo to be used _target = _this select 1;//target of artillery fire _delay = _this select 2;//0.8 delay between each shell _height = _this select 3;//220 height shells will fall from _amount = _this select 4;//30 total shells fired _spread = _this select 5;//50 how close they will be to the target Mortar = "2b14_82mm_TK_EP1" createVehicle (getMarkerPos "mr"); m1 moveingunner mortar; hint "1"; while {alive gunner _mortar} do { for "_x" from 1 to _amount do { _targetpos = [getPos _target select 0, getPos _target select 1, _height]; _Strike = createVehicle [_ammotype, _targetpos, [], _spread, "NONE"]; _Strike allowdamage false; _Strike setvectorup [0,9,0.1]; _Strike setvelocity [0,0,-200]; sleep _delay; hint "2"; }; }; so the problem is i need to connect _mortar to the unit in game or somting like that and then if you kill the mortar the script needs to stop spawning the shells :D Share this post Link to post Share on other sites
f2k sel 164 Posted February 25, 2014 (edited) Sorry I wasn't follow in, I thought the mortar man was the target of other mortars and when he died stop the arty. This should work now //null=["ARTY_Sh_122_HE",target,0.8,220,30,50]execVM "artillery.sqf" _ammotype = _this select 0;//ARTY_Sh_122_HE type of ammo to be used _target = _this select 1;//target of artillery fire _delay = _this select 2;//0.8 delay between each shell _height = _this select 3;//220 height shells will fall from _amount = _this select 4;//30 total shells fired _spread = _this select 5;//50 how close they will be to the target Mortar = "2b14_82mm_TK_EP1" createVehicle (getMarkerPos "mr"); m1 moveingunner mortar; hint "1"; while {alive gunner mortar} do { for "_x" from 1 to _amount do { if (!alive gunner mortar) exitwith {hint "exit for loop"}; _targetpos = [getPos _target select 0, getPos _target select 1, _height]; _Strike = createVehicle [_ammotype, _targetpos, [], _spread, "NONE"]; _Strike allowdamage false; _Strike setvectorup [0,9,0.1]; _Strike setvelocity [0,0,-200]; sleep _delay; hint "2"; }; }; Edited February 25, 2014 by F2k Sel Share this post Link to post Share on other sites
derox 3 Posted February 25, 2014 Thanks i will take a look at it this evening i will let you know if it works :D Share this post Link to post Share on other sites
derox 3 Posted February 25, 2014 (edited) Yo thanks man it works the only problem i still have is that for some reason it spawnes 2 mortars. And can i just remove that hint? -------------------------------------- Nevermind fixed it :D Edited February 25, 2014 by Derox I fixed it Share this post Link to post Share on other sites