\b;Objective
Shoot down the flying wasps.

\t;Program
Here is again the program of the previous exercise that shoots all ants and adapts to the terrain:
\c;
\s;extern void object::JetFighter2()
\s;{
\s;	\l;object\u cbot\type; item;
\s;	
\s;	\l;aim\u cbot\aim;(-20);
\s;	
\s;	\l;while\u cbot\while; (true)
\s;	{
\s;		\l;while\u cbot\while; (\l;radar\u cbot\radar;(AlienAnt, 0, 360, 0, 20) == null)
\s;		{
\s;			item = \l;radar\u cbot\radar;(AlienAnt);
\s;			\l;turn\u cbot\turn;(\l;direction\u cbot\direct;(item.position));
\s;			\l;motor\u cbot\motor;(1,1);
\s;			
\s;			\l;jet\u cbot\jet;(0);
\s;			\l;if\u cbot\if; (position.z-topo(position) < 6)
\s;			{
\s;				\l;jet\u cbot\jet;(1);
\s;			}
\s;			
\s;			\l;if\u cbot\if; (position.z-topo(position) > 9)
\s;			{
\s;				\l;jet\u cbot\jet;(-1);
\s;			}
\s;			\l;wait\u cbot\wait;(0.2);
\s;		}
\s;		\l;fire\u cbot\fire;(1);
\s;	}
\s;}
\n;
In order to adapt the program to shooting wasps, you need to make a few changes. Replace all \c;radar(AlienAnt)\n; with \c;radar(AlienWasp)\n;. The cannon must aim straight forward and not downward, replace \c;aim(-20);\n; with \c;aim(0);\n;. And the bot must fly at the same height as the wasp. For this, you must compare the altitude of the bot given by \c;position.z\n; with the altitude of the wasp given by \c;item.position.z\n;: if \c;position.z > item.position.z\n;, go down slowly with \c;jet(-0.3);\n;. If \c;position.z < item.position.z-1\n;, climb slowly with \c;jet(0.3);\n;. A winged shooter is higher than a wasp, therefore it is better if the altitude of the bot is a little lower than the altitude of the wasp. In this case, we admit that the altitude of the bot ranges between the altitude of the wasp and the altitude of the wasp minus 1.

\t;Further improvement
Wasps move very fast. In order to increase your chances to get them, better to repeat just before the \c;fire(1);\n; a \c;radar\n; and a \c;turn\n; in order to perform a last readjustment of the direction before the shot.

\t;See also
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.
