Jump to content
INF_MIke64

Neat little rotating Radar script

Recommended Posts

while {true} do {
	{
		radar lookAt (radar getRelPos [100, _x]);
		sleep 2;
	} forEach [0, 90, 180, 270];
};

Figure you guys may like this little script (change as you like)
What it does it make a radar rotate to look around, what it importantly does it also not stop it from focusing on a contact and tracking it for a SAM, then once the hostile is gone it returns to rotating

  • Like 3
  • Thanks 4
  • Haha 1

Share this post


Link to post
Share on other sites
while {true} do {
	{
		radar lookAt (radar getRelPos [100, _x]);
		sleep 2.45;
	} forEach [120, 240, 0];
};

I tweaked the code a little to eliminate the jerkiness as it goes from point to point. Any lower than 2.45 will result in slightly smoother rotation but will cause the radar to occasionally reverse direction back to the previous point, pause, and then start up again. Reducing the number of points to three helps make things a little smoother as well as the ai is spending more time traversing between points that are further apart. Less than three just confuses the AI, you need at least three to establish a direction of rotation. [120, 240, 0] makes the radar start spinning instantly, instead of waiting a few moments to start up. As a last note, this script does not seem to work in the init field of the radar itself.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
On 7/8/2018 at 9:29 PM, INF_MIke64 said:

radar lookAt

 

Nice INF_MIke64 !

Just to ask ,

You mean about this radar?

B_Radar_System_01_F

  • Like 2

Share this post


Link to post
Share on other sites

B_Radar_System_01_F, and O_Radar_System_02_F

Although the script will work with any AI. Apply it to a tank gunner and the turret will spin around for instance.

  • Like 3

Share this post


Link to post
Share on other sites

This is more or less the scan horizon command for AI 

16 hours ago, Takahashi Yuuki said:

while {true} do {
	{
		radar lookAt (radar getRelPos [100, _x]);
		sleep 2.45;
	} forEach [120, 240, 0];
};

I tweaked the code a little to eliminate the jerkiness as it goes from point to point. Any lower than 2.45 will result in slightly smoother rotation but will cause the radar to occasionally reverse direction back to the previous point, pause, and then start up again. Reducing the number of points to three helps make things a little smoother as well as the ai is spending more time traversing between points that are further apart. Less than three just confuses the AI, you need at least three to establish a direction of rotation. [120, 240, 0] makes the radar start spinning instantly, instead of waiting a few moments to start up. As a last note, this script does not seem to work in the init field of the radar itself.

Cool thanks

Share this post


Link to post
Share on other sites
46 minutes ago, Sertica said:

This does not work .  "generic error in expression"

Probably because you're inside an unscheduled scope, not allowing the sleep command.

Try:

0 = [] spawn {
   while {alive radar} do { { radar lookAt (radar getRelPos [100, _x]); sleep 2.45; } forEach [120, 240, 0]; };

};

 

Share this post


Link to post
Share on other sites

I tried that in both mission init and a trigger with true condition.  It turns one rotation, then stops.

I don't understand that voodoo syntax.  How can you assign to an enumeration like 0, and what is "[] spawn".

Share this post


Link to post
Share on other sites
25 minutes ago, Sertica said:

I tried that in both mission init and a trigger with true condition.  It turns one rotation, then stops.

I don't understand that voodoo syntax.  How can you assign to an enumeration like 0, and what is "[] spawn".

The on act field of the trigger must return nothing (no code, no value). So, the handle of the script (here 0) is just for this aim, this "equality" returns nothing). You could write some other handles like myCode of 1 or null, as far as you don't use it further.

For spawn, follow the BIKI command. And more.

 

There is no reason to get just one rotation with my code... except if your radar (like Cronus) detects an enemy unit (even infantry! :huh2:).

Once again, BI decided to do "too clever" behavior, just forgetting the aim of an Anti-Air radar.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Note that both O_Radar_System_02_F and B_Radar_System_01_F require a gunner for this to work.

Use createUnit to make a O_UAV_AI and moveInGunner him.

  • Like 2

Share this post


Link to post
Share on other sites

Yes. I do almost the same to man empty radar (and launcher), so to make them operational by createVehicleCrew radar; ...   command,

then empty them again by {radar deleteVehicleCrew _x} forEach crew radar; (same for launcher), to disable them and give them a chance to be not fired by AI enemies.

 

  • Like 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×