sknam 2 Posted November 3, 2016 Hello guys, In the mission Editor, I often put enemy sniper or rpg on roof of buildings, Unfortunately they are always fast detected and killed before to be a real menace. I use this dostop true or disable ai move and I also use setunitpos to select the stance. If I Iet the vanilla ai system, they just go prone when the detect enemy, and can’t fire through the window or from the roof… I would like to make a little scrips lunched on the AI initialization field, or from a trigger to make an ambush like situation to make my AI switch from down to middle just a little time to firing and hide again for a certain time. I was thinking to something like this: (sorry I am not aware about the syntax) _myunit setunitpos “down†Sleep random [ 30, 50] <- Wait random time from 30 to 50 sec _myunit setunitpos “middle†Sleep random [ 5, 10] (the time to select a target and dofire, and hide again) #loop I am sure that if it works it can add a lot immersion in hostile zone. Please if someone can help me in syntax for the script and for the initialization to run an maybe add a variable in the timing… Thanks for reading. Cheers Share this post Link to post Share on other sites
EO 11277 Posted November 3, 2016 This might fit your needs...... https://forums.bistudio.com/topic/190815-release-jboy-combat-up-down-script/ 1 Share this post Link to post Share on other sites
sknam 2 Posted November 3, 2016 Thank you Evil Organ, This very close what I am looking for! Thank you. In JBoy script you can see this: // ***************************************************** // ** JBOY_UpDown.sqf // ** by JohnnyBoy // ** AI will toggle between two stances with a delay between. Good for defenders to duck behind walls or windows, then pop back up. // ** Call: null = [dude, ["Up","Middle"]] execVM "JBOY\JBOY_UpDown.sqf"; // ** To start with an eventhandler, put this in unit's init: // this addeventhandler ["FiredNear",{ [_this select 0, ["Up","Middle"]] execVM "JBOY\JBOY_UpDown.sqf";}]; // this addeventhandler ["FiredNear",{ [_this select 0, ["Middle","Down"]] execVM "JBOY\JBOY_UpDown.sqf";}]; // // ***************************************************** if (!isServer) exitwith {}; // Parameters: _dude = _this select 0; _stances = _this select 1; _dude removeAllEventHandlers "FiredNear"; while {alive _dude} do { if ((unitpos _dude) == (_stances select 0)) then { _dude setUnitPos (_stances select 1); } else { _dude setUnitPos (_stances select 0); }; sleep (1 + (random 15)); }; with this scrips the middle and up postion are random from 1 to 16 second and same for the down position right? how I can modify the timing if I want the Unit is down 50 sec and middle only 5sec ? regards Share this post Link to post Share on other sites
johnnyboy 3797 Posted November 3, 2016 Try this: _dude removeAllEventHandlers "FiredNear"; while {alive _dude} do { if ((unitpos _dude) == "MIDDLE") then { _dude setUnitPos "DOWN"; sleep 50; } else { _dude setUnitPos "MIDDLE"; sleep 5; }; }; Share this post Link to post Share on other sites
sknam 2 Posted November 3, 2016 Thank you Johnnyboy, It works! now I understood how to have the perfect time control. // ***************************************************** // ** JBOY_UpDown.sqf // ** by JohnnyBoy // ** AI will toggle between two stances with a delay between. Good for defenders to duck behind walls or windows, then pop back up. // ** Call: null = [dude, ["Up","Middle"]] execVM "JBOY\JBOY_UpDown.sqf"; // ** To start with an eventhandler, put this in unit's init: // this addeventhandler ["FiredNear",{ [_this select 0, ["Up","Middle"]] execVM "JBOY\JBOY_UpDown.sqf";}]; // this addeventhandler ["FiredNear",{ [_this select 0, ["Middle","Down"]] execVM "JBOY\JBOY_UpDown.sqf";}]; // // ***************************************************** if (!isServer) exitwith {}; // Parameters: // Parameters: _dude = _this select 0; _stances = _this select 1; _dude removeAllEventHandlers "FiredNear"; while {alive _dude} do { if ((unitpos _dude) == "MIDDLE") then { _dude setUnitPos "DOWN"; sleep (20 + (random 30)); } else { _dude setUnitPos "MIDDLE"; sleep (4 + (random 4)); }; }; I understand that the script works with " addeventhandler ["FiredNear" " If I want to control when to lunch the script, like from a trigger for expample I have a patrol in a street and when they entrer in the trigger: the snipers crouch and fire. Do you know what syntax I must use to lunch the script? regards Share this post Link to post Share on other sites
johnnyboy 3797 Posted November 3, 2016 [mySniper, ["Middle","Down"]] execVM "JBOY\JBOY_UpDown.sqf"; Put that in your trigger, and change "mySniper" to whatever you have named your sniper unit. You might need to put "dummy=" at the beginning of this line like this: dummy=[mySniper, ["Middle","Down"]] execVM "JBOY\JBOY_UpDown.sqf"; One of the above should work for you. Share this post Link to post Share on other sites
sknam 2 Posted November 3, 2016 Oh JBoy ! It works, thx mate! is it possible to command several snipers at the same time like this ? dummy=[mySniper,mySniper3,mySniper4,mySniper5,mySniper6 ["Middle","Down"]] execVM "JBOY\JBOY_UpDown.sqf"; B) 1 Share this post Link to post Share on other sites
johnnyboy 3797 Posted November 3, 2016 {dummy=[_x, ["Middle","Down"]] execVM "JBOY\JBOY_UpDown.sqf";} foreach [mySniper,mySniper3,mySniper4,mySniper5,mySniper6]; That should do it. Glad I could help. :) Don't forget to put some chickens in your mission. Everyone knows that a good sniper mission needs chickens. 2 Share this post Link to post Share on other sites
sknam 2 Posted November 3, 2016 Yes, it works, thank you very much Jboy ! :) :) 1 Share this post Link to post Share on other sites