z1_ 2 Posted July 26, 2021 (edited) Got an AI on the spotlight (CUP_O_SearchLight_static_RU). Got it to turn on and all that but he doesn't really move it around until the enemy is detected. Would like him to rotate it around. Came up with something that kinda works, turns only the light and not the base (which is good), but it flickers and jerks before each turn. Would be cool if it was smooth. Tried turning both the player and the searchlight, but only the searchlight will turn when he's in it. Also it really wouldn't turn much unless I scripted a handful of turns. Tried setDir, setFormDir, setVectorDir and only setDir seems to do anything. Also tried using the player as the direction to turn, but light would barely turn. Looked around but the only spotlight scripts I came across were in regards to them on helo's and couldn't find anything on the forum. #searchlight SL1_1 setDir 45; ~15 SL1_1 setDir 90; ~15 SL1_1 setDir 180; ~15 SL1_1 setDir 225; ~15 SL1_1 setDir 360; ~15 if (SL1G_1 call BIS_fnc_enemyDetected) then {goto "stop";}; goto "searchlight" #stop So this basically worked. He'll stop when the enemy is detected and actually search. The actual rotations look fine but right when he starts each turn the light jerks around which kinda kills immersion. I could live with it, but anyone have an idea? Edited July 29, 2021 by z1_ Solved Share this post Link to post Share on other sites
z1_ 2 Posted July 26, 2021 Maybe I'll try doing a unitCapture. Hopefully I only have to capture the spotlight. Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 Actually, I would assume if I make that initial script do every degree in the rotation it might look smooth and suffice for my needs. I'll try that. Share this post Link to post Share on other sites
Harzach 2518 Posted July 27, 2021 You can place a few gamelogics at positions where you'd like them to look, then use doTarget on the "gunner". nul = [] spawn { while {true} do { gunner1 doTarget spot_1; sleep (random [5,10,15]); gunner1 doTarget spot_2; sleep (random [5,10,15]); gunner1 doTarget spot_3; sleep (random [5,10,15]); gunner1 doTarget spot_4; sleep (random [5,10,15]); gunner1 doTarget spot_5; sleep (random [5,10,15]); } }; 2 Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 2 minutes ago, Harzach said: You can place a few gamelogics at positions where you'd like them to look, then use doTarget . Good idea, thanks. Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 Thanks for the syntax, I was using archaic stuff i learned when i was messing with camera scripts Share this post Link to post Share on other sites
Harzach 2518 Posted July 27, 2021 Or a little tidier: nul = [] spawn { _array = [spot_1,spot_2,spot_3,spot_4,spot_5]; while {true} do { { gunner1 doTarget _x; sleep (random [5,10,15]); } forEach _array; } }; Just as an example, of course. 3 Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 9 minutes ago, Harzach said: You can place a few gamelogics at positions where you'd like them to look, then use doTarget on the "gunner". nul = [] spawn { while {true} do { gunner1 doTarget spot_1; sleep (random [5,10,15]); gunner1 doTarget spot_2; sleep (random [5,10,15]); gunner1 doTarget spot_3; sleep (random [5,10,15]); gunner1 doTarget spot_4; sleep (random [5,10,15]); gunner1 doTarget spot_5; sleep (random [5,10,15]); } }; Can I use an array after do target or does it have to be object? Might be interesting to randomize which logic it chooses as well. Share this post Link to post Share on other sites
Harzach 2518 Posted July 27, 2021 Absolutely, plenty of ways to throw some randomness into it. Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 That works so much better, thanks again. 1 Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 On 7/26/2021 at 6:53 PM, Harzach said: Or a little tidier: nul = [] spawn { _array = [spot_1,spot_2,spot_3,spot_4,spot_5]; while {true} do { { gunner1 doTarget _x; sleep (random [5,10,15]); } forEach _array; } }; Just as an example, of course. How would you make it so it stops script when gunner1 detects an enemy? Noticed he just kept on turning no matter what. I did get it to work well using my original idea and doWatch instead, then when he detects enemy he stops targeting the logics with doWatch objNull and he'll look for the enemy. But I figure there's a way to do it with your loop, plus I couldn't get the random sleep to work along with my idea. Tried a lot of things with while and if/then but wasn't having luck doing it your way. Plus your way could go in an init if I recall correctly, and I have to call mine from a script. this exec "scripts\searchlight.sqs"; #searchlight gunner1 doWatch spot_1; ~ 10 gunner1 doWatch spot_2; ~ 10 gunner1 doWatch spot_3; ~ 10 gunner1 doWatch spot_4; ~ 10 gunner1 doWatch spot_5; ~ 10 gunner1 doWatch spot_6; ~ 10 gunner1 doWatch spot_7; ~ 10 gunner1 doWatch spot_8; if (gunner1 call BIS_fnc_enemyDetected) then {goto "stop";}; goto "searchlight" #stop gunner1 doWatch objNull; Share this post Link to post Share on other sites
sarogahtyp 1109 Posted July 27, 2021 nul = [] spawn { _array = [spot_1,spot_2,spot_3,spot_4,spot_5]; while { isNull (gunner1 findNearestEnemy gunner1) } do { { gunner1 doTarget _x; sleep (random [5,10,15]); } forEach _array; } }; you just have to define how long that while loop has to run. Above I used findNearestEnemy. The while loop should run as long as objNull is returned by this command. Not tested. 4 Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 13 hours ago, sarogahtyp said: nul = [] spawn { _array = [spot_1,spot_2,spot_3,spot_4,spot_5]; while { isNull (gunner1 findNearestEnemy gunner1) } do { { gunner1 doTarget _x; sleep (random [5,10,15]); } forEach _array; } }; you just have to define how long that while loop has to run. Above I used findNearestEnemy. The while loop should run as long as objNull is returned by this command. Not tested. The ai wouldn't break out of the loop this way. Unloaded in his vicinity and he kept on doing his turns. Not sure if it has to do with distance. He's high up in a tower. So far my version is working the best, I don't even have to shoot, if he catches me in the light he'll break out of the loop, but it's an ugly script 😛 Any ideas? Tried some other conditions without luck. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted July 27, 2021 Are you sure it will not break out? Try shorter sleep times like sleep (random [1,3,5]); Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 Just now, sarogahtyp said: Are you sure it will not break out? Try shorter sleep times like sleep (random [1,3,7]); I'll let you know how that works. Thanks Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 6 minutes ago, sarogahtyp said: Are you sure it will not break out? Try shorter sleep times like sleep (random [1,3,7]); It seems to break now, but he just stops and looks one direction, doesn't scan around. He has a teammate up there too who definitely knows when I'm shooting. Also doesn't seem to break unless I fire, he doesn't notice me in the light. Share this post Link to post Share on other sites
z1_ 2 Posted July 27, 2021 Is he treating the logics as an enemy when he breaks or something? No rush on replies or anything, just trying to learn the right way to do things. Mine works perfectly and will probably suffice for a SP mission, but not sure how that kind of scripting works in MP environment. Share this post Link to post Share on other sites
panther42 53 Posted July 28, 2021 (edited) @z1_, first of all, the code you've been posting is SQS syntax, yet you have it in an SQF script? 20 hours ago, z1_ said: this exec "scripts\searchlight.sqf"; SQF should be execVM "whatever.sqf" See SQS to SQF conversion. For a suggestion, you could try lookAt as utilized in this topic. Another option is the animationSources for the spotlight. I had a specific post in mind, but unable to locate it at this time. Ok, I found the post I was thinking about, and I doubt it will help much with this spotlight. Here's the post though, in case you need it for anything else... Another one you may give a try is by ALIAS on SW. I've never tried it, but he may not even use a spotlight item, just create a light source. Could be an option to look into these script(s). Edited July 28, 2021 by panther42 Found something else to add 1 Share this post Link to post Share on other sites
z1_ 2 Posted July 28, 2021 1 hour ago, panther42 said: @z1_, first of all, the code you've been posting is SQS syntax, yet you have it in an SQF script? SQF should be execVM "whatever.sqf" See SQS to SQF conversion. For a suggestion, you could try lookAt as utilized in this topic. Another option is the animationSources for the spotlight. I had a specific post in mind, but unable to locate it at this time. Ok, I found the post I was thinking about, and I doubt it will help much with this spotlight. Here's the post though, in case you need it for anything else... Another one you may give a try is by ALIAS on SW. I've never tried it, but he may not even use a spotlight item, just create a light source. Could be an option to look into these script(s). Thanks, that conversion chart is handy. I learned all that sqs syntax working with camera scripts years ago. Oddly enough my script works well, but I did want to use the correct syntax. Share this post Link to post Share on other sites
z1_ 2 Posted July 28, 2021 Okay, so it looks like the lookAt command panther suggested did the trick. This works well. nul = [] spawn { _array = [spot_1,spot_2,spot_3,spot_4,spot_5]; while { isNull (gunner1 findNearestEnemy gunner1) } do { { gunner1 lookAt _x; sleep (random [5,10,15]); } forEach _array; } }; 1 Share this post Link to post Share on other sites
z1_ 2 Posted August 4, 2021 Just wanted to add for anyone who uses this. The doTarget works fine if the unit isn’t in the Spotlight vehicle, like perhaps you want a unit looking around with flashlight. For some reason I had to use lookAt to get them to break loop while in the spotlight. Just wanted to mention that in case you wanted to use in a different way. Share this post Link to post Share on other sites