ZealOS/docs/Demo/Games/FlatTops.CC.html
2021-09-21 23:45:45 -04:00

1068 lines
104 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.01">
<style type="text/css">
body {background-color:#fef1f0;}
.c10{color:#000000;background-color:#0148a4;}
.c1A{color:#82bc49;background-color:#0148a4;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>define</span><span class=cF0> GAME_SPEED_SCALE </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF1>F64</span><span class=cF0> game_speed,
<a name="l4"></a> launch_unit_x1, launch_unit_y1, launch_unit_x2, launch_unit_y2, launch_t,
<a name="l5"></a> return_unit_x1, return_unit_y1, return_unit_x2, return_unit_y2, return_t,
<a name="l6"></a> set_theta_unit_x1, set_theta_unit_y1, set_theta_unit_x2, set_theta_unit_y2, set_theta_t,
<a name="l7"></a> next_noise;
<a name="l8"></a></span><span class=cF9>CTask</span><span class=cF0> *main_task;
<a name="l9"></a>
<a name="l10"></a>#</span><span class=cF1>define</span><span class=cF0> OT_CARRIER </span><span class=cFE>0</span><span class=cF0>
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> OT_CRUISER </span><span class=cFE>1</span><span class=cF0>
<a name="l12"></a>#</span><span class=cF1>define</span><span class=cF0> OT_FIGHTER </span><span class=cFE>2</span><span class=cF0>
<a name="l13"></a>#</span><span class=cF1>define</span><span class=cF0> OT_TYPES_NUM </span><span class=cFE>3</span><span class=cF0>
<a name="l14"></a>
<a name="l15"></a>#</span><span class=cF1>define</span><span class=cF0> OF_SHIP </span><span class=cFE>1</span><span class=cF0>
<a name="l16"></a>#</span><span class=cF1>define</span><span class=cF0> OF_ACTIVE </span><span class=cFE>2</span><span class=cF0>
<a name="l17"></a>#</span><span class=cF1>define</span><span class=cF0> OF_RETURNING </span><span class=cFE>4</span><span class=cF0>
<a name="l18"></a>#</span><span class=cF1>define</span><span class=cF0> OF_SHOOTING </span><span class=cFE>8</span><span class=cF0>
<a name="l19"></a>
<a name="l20"></a>#</span><span class=cF1>define</span><span class=cF0> FIRE_WIDTH </span><span class=cFE>56</span><span class=cF0>
<a name="l21"></a>#</span><span class=cF1>define</span><span class=cF0> FIRE_HEIGHT </span><span class=cFE>16</span><span class=cF0>
<a name="l22"></a>#</span><span class=cF1>define</span><span class=cF0> FIRE_X_SCALE </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>
<a name="l23"></a>#</span><span class=cF1>define</span><span class=cF0> FIRE_Y_SCALE </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>
<a name="l24"></a>
<a name="l25"></a>#</span><span class=cF1>define</span><span class=cF0> FIRE_COLORS </span><span class=cFE>16</span><span class=cF0>
<a name="l26"></a></span><span class=cF1>U8</span><span class=cF0> fire_colors[FIRE_COLORS] = {</span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF3>LTRED</span><span class=cF0>, </span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF3>BLACK</span><span class=cF0>, </span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF3>RED</span><span class=cF0>, </span><span class=cF3>YELLOW</span><span class=cF0>,
<a name="l27"></a> </span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF3>BLACK</span><span class=cF0>, </span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF3>LTRED</span><span class=cF0>, </span><span class=cF3>RED</span><span class=cF0>, </span><span class=cF3>YELLOW</span><span class=cF0>, </span><span class=cF3>DKGRAY</span><span class=cF0>, </span><span class=cF3>YELLOW</span><span class=cF0>};
<a name="l28"></a>
<a name="l29"></a></span><span class=cF1>class</span><span class=cF0> Obj
<a name="l30"></a>{
<a name="l31"></a> Obj *next, *last;
<a name="l32"></a> Obj *next_in_squadron, *last_in_squadron;
<a name="l33"></a> Obj *host;
<a name="l34"></a> </span><span class=cF1>U8</span><span class=cF0> player, type;
<a name="l35"></a> </span><span class=cF9>U16</span><span class=cF0> flags;
<a name="l36"></a> </span><span class=cF9>I16</span><span class=cF0> squadron, member_num;
<a name="l37"></a> </span><span class=cF1>F64</span><span class=cF0> x, y, theta, dtheta,
<a name="l38"></a> speed, turn_rate,
<a name="l39"></a> life_percent,
<a name="l40"></a> target_x, target_y,
<a name="l41"></a> ship_guns, ship_guns_range,
<a name="l42"></a> air_guns, air_guns_range,
<a name="l43"></a> fuel, max_fuel, fuel_burn_rate,
<a name="l44"></a> death_time, next_action_time;
<a name="l45"></a> </span><span class=cF9>I32</span><span class=cF0> torpedos, max_torpedos;
<a name="l46"></a> </span><span class=cF1>F64</span><span class=cF0> torpedos_range;
<a name="l47"></a> </span><span class=cF1>U8</span><span class=cF0> fire[(FIRE_WIDTH * FIRE_HEIGHT + </span><span class=cFE>7</span><span class=cF0>) / </span><span class=cFE>8</span><span class=cF0>];
<a name="l48"></a>
<a name="l49"></a>} obj_head;
<a name="l50"></a>
<a name="l51"></a></span><span class=cF1>class</span><span class=cF0> Torpedo
<a name="l52"></a>{
<a name="l53"></a> Torpedo *next, *last;
<a name="l54"></a> Obj *target;
<a name="l55"></a> </span><span class=cF1>F64</span><span class=cF0> x, y, theta, speed, timeout;
<a name="l56"></a>
<a name="l57"></a>} torpedo_head;
<a name="l58"></a>
<a name="l59"></a>#</span><span class=cF1>define</span><span class=cF0> SA_PARKED </span><span class=cFE>0</span><span class=cF0>
<a name="l60"></a>#</span><span class=cF1>define</span><span class=cF0> SA_LAUNCHING </span><span class=cFE>1</span><span class=cF0>
<a name="l61"></a>#</span><span class=cF1>define</span><span class=cF0> SA_FLYING </span><span class=cFE>2</span><span class=cF0>
<a name="l62"></a>#</span><span class=cF1>define</span><span class=cF0> SA_SET_theta </span><span class=cFE>3</span><span class=cF0>
<a name="l63"></a>#</span><span class=cF1>define</span><span class=cF0> SA_RETURNING </span><span class=cFE>4</span><span class=cF0>
<a name="l64"></a>#</span><span class=cF1>define</span><span class=cF0> SA_DEAD </span><span class=cFE>5</span><span class=cF0>
<a name="l65"></a>
<a name="l66"></a></span><span class=cF1>class</span><span class=cF0> Squadron : Obj
<a name="l67"></a>{
<a name="l68"></a> </span><span class=cF9>I64</span><span class=cF0> action, dead_mask, total_mask;
<a name="l69"></a>
<a name="l70"></a>} *squadrons;
<a name="l71"></a>
<a name="l72"></a></span><span class=cF1>U0</span><span class=cF0> SquadronIns(Obj *o, Obj *pred)
<a name="l73"></a>{
<a name="l74"></a> Obj *succ = pred-&gt;next_in_squadron;
<a name="l75"></a>
<a name="l76"></a> o-&gt;next_in_squadron = succ;
<a name="l77"></a> o-&gt;last_in_squadron = pred;
<a name="l78"></a> pred-&gt;next_in_squadron = o;
<a name="l79"></a> succ-&gt;last_in_squadron = o;
<a name="l80"></a>}
<a name="l81"></a>
<a name="l82"></a></span><span class=cF1>U0</span><span class=cF0> SquadronRemove(Obj *o)
<a name="l83"></a>{
<a name="l84"></a> Obj *pred = o-&gt;last_in_squadron, *succ = o-&gt;next_in_squadron;
<a name="l85"></a>
<a name="l86"></a> pred-&gt;next_in_squadron = succ;
<a name="l87"></a> succ-&gt;last_in_squadron = pred;
<a name="l88"></a>}
<a name="l89"></a>
<a name="l90"></a>#</span><span class=cF1>define</span><span class=cF0> PLAYERS_NUM </span><span class=cFE>2</span><span class=cF0>
<a name="l91"></a>
<a name="l92"></a></span><span class=cF9>I64</span><span class=cF0> num_carriers[PLAYERS_NUM] = {</span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>},
<a name="l93"></a> num_cruisers[PLAYERS_NUM] = {</span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>},
<a name="l94"></a> num_planes_per_squadron[PLAYERS_NUM] = {</span><span class=cFE>6</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>},
<a name="l95"></a> num_squadrons_per_carrier[PLAYERS_NUM] = {</span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>},
<a name="l96"></a> num_alive[PLAYERS_NUM],
<a name="l97"></a> num_squadrons;
<a name="l98"></a>
<a name="l99"></a>Obj *ObjFind(</span><span class=cF1>F64</span><span class=cF0> x, </span><span class=cF1>F64</span><span class=cF0> y,
<a name="l100"></a> </span><span class=cF9>I64</span><span class=cF0> flag_mask=OF_ACTIVE|OF_RETURNING, </span><span class=cF9>I64</span><span class=cF0> flag_val=OF_ACTIVE,
<a name="l101"></a> </span><span class=cF9>I64</span><span class=cF0> type_mask=-</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> player_mask=-</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> *_d=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l102"></a>{
<a name="l103"></a> Obj *tmpo = obj_head.next, *best = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l104"></a> </span><span class=cF1>F64</span><span class=cF0> dd, best_dd = </span><span class=cF3>F64_MAX</span><span class=cF0>;
<a name="l105"></a>
<a name="l106"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l107"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l108"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; flag_mask == flag_val &amp;&amp; </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;type_mask, tmpo-&gt;type</span><span class=cF7>)</span><span class=cF0> &amp;&amp; </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;player_mask, tmpo-&gt;player</span><span class=cF7>)</span><span class=cF0>)
<a name="l109"></a> {
<a name="l110"></a> dd = </span><span class=cF5>Sqr</span><span class=cF0>(tmpo-&gt;x - x) + </span><span class=cF5>Sqr</span><span class=cF0>(tmpo-&gt;y - y);
<a name="l111"></a> </span><span class=cF1>if</span><span class=cF0> (dd &lt; best_dd)
<a name="l112"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l113"></a> best = tmpo;
<a name="l114"></a> best_dd = dd;
<a name="l115"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l116"></a> }
<a name="l117"></a> tmpo = tmpo-&gt;next;
<a name="l118"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (_d)
<a name="l120"></a> *_d = </span><span class=cF5>Sqrt</span><span class=cF0>(best_dd);
<a name="l121"></a>
<a name="l122"></a> </span><span class=cF1>return</span><span class=cF0> best;
<a name="l123"></a>}
<a name="l124"></a>
<a name="l125"></a></span><span class=cF1>U0</span><span class=cF0> ObjDel(Obj *tmpo)
<a name="l126"></a>{
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo)
<a name="l128"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l129"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> &lt; tmpo-&gt;death_time)
<a name="l130"></a> tmpo-&gt;flags &amp;= ~OF_ACTIVE;
<a name="l131"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l132"></a> {
<a name="l133"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;squadron &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l134"></a> SquadronRemove(tmpo);
<a name="l135"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpo);
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;squadron &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l137"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;squadrons[tmpo-&gt;squadron].dead_mask, tmpo-&gt;member_num);
<a name="l138"></a> num_alive[tmpo-&gt;player]--;
<a name="l139"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpo);
<a name="l140"></a> }
<a name="l141"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l142"></a>}
<a name="l143"></a></span><span class=c10>
<a name="l144"></a>
<a name="l145"></a></span><span class=c1A>
<a name="l146"></a>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=c10>
<a name="l147"></a>
<a name="l148"></a>
<a name="l149"></a>
<a name="l150"></a></span><span class=c1A>
<a name="l151"></a>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=c10>
<a name="l152"></a>
<a name="l153"></a></span><span class=c1A>
<a name="l154"></a>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=c10>
<a name="l155"></a>
<a name="l156"></a>
<a name="l157"></a></span><span class=c1A>
<a name="l158"></a>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=c10>
<a name="l159"></a>
<a name="l160"></a>
<a name="l161"></a>
<a name="l162"></a></span><span class=c1A>
<a name="l163"></a>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=c10>
<a name="l164"></a>
<a name="l165"></a></span><span class=c1A>
<a name="l166"></a>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=c10>
<a name="l167"></a></span><span class=cF0>
<a name="l168"></a></span><span class=cF1>U8</span><span class=cF0> *imgs[PLAYERS_NUM][OT_TYPES_NUM] = {</span><span class=cF7>{</span><span class=cFA>&lt;1&gt;</span><span class=cF0>, </span><span class=cFA>&lt;2&gt;</span><span class=cF0>, </span><span class=cFA>&lt;3&gt;</span><span class=cF7>}</span><span class=cF0>, </span><span class=cF7>{</span><span class=cFA>&lt;4&gt;</span><span class=cF0>, </span><span class=cFA>&lt;5&gt;</span><span class=cF0>, </span><span class=cFA>&lt;6&gt;</span><span class=cF7>}</span><span class=cF0>};
<a name="l169"></a>
<a name="l170"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawIt</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l171"></a>{
<a name="l172"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, k;
<a name="l173"></a> </span><span class=cF1>F64</span><span class=cF0> d, cur_time = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l174"></a> Obj *tmpo;
<a name="l175"></a> Torpedo *tmpt;
<a name="l176"></a>
<a name="l177"></a> tmpt = torpedo_head.next;
<a name="l178"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != &amp;torpedo_head)
<a name="l179"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l180"></a> dc-&gt;color = </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l181"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc, tmpt-&gt;x, tmpt-&gt;y);
<a name="l182"></a> tmpt = tmpt-&gt;next;
<a name="l183"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l184"></a>
<a name="l185"></a> tmpo = obj_head.next;
<a name="l186"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l187"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l188"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; OF_ACTIVE &amp;&amp; tmpo-&gt;flags &amp; OF_SHIP)
<a name="l189"></a> {
<a name="l190"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc, tmpo-&gt;x, tmpo-&gt;y, </span><span class=cFE>0</span><span class=cF0>, imgs[tmpo-&gt;player][tmpo-&gt;type], tmpo-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l191"></a>
<a name="l192"></a> k = </span><span class=cFE>0</span><span class=cF0>;
<a name="l193"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; FIRE_HEIGHT; j++)
<a name="l194"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; FIRE_WIDTH; i++)
<a name="l195"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;fire, k++</span><span class=cF7>)</span><span class=cF0>)
<a name="l196"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l197"></a> dc-&gt;color = fire_colors[</span><span class=cF5>ToI64</span><span class=cF0>(k + </span><span class=cFE>10</span><span class=cF0> * </span><span class=cF5>tS</span><span class=cF0>) &amp; (FIRE_COLORS - </span><span class=cFE>1</span><span class=cF0>)];
<a name="l198"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc, tmpo-&gt;x + FIRE_X_SCALE * </span><span class=cF7>(</span><span class=cF0>i - FIRE_WIDTH / </span><span class=cFE>2</span><span class=cF0> + (</span><span class=cFE>11</span><span class=cF0> * </span><span class=cF5>tS</span><span class=cF0> + i) % </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>7</span><span class=cF7>)</span><span class=cF0> *
<a name="l199"></a> </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;theta</span><span class=cF7>)</span><span class=cF0> - FIRE_Y_SCALE * </span><span class=cF7>(</span><span class=cF0>j - FIRE_HEIGHT / </span><span class=cFE>2</span><span class=cF0> + (</span><span class=cFE>12</span><span class=cF0> * </span><span class=cF5>tS</span><span class=cF0> + j) % </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>7</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;theta</span><span class=cF7>)</span><span class=cF0>,
<a name="l200"></a> tmpo-&gt;y + FIRE_Y_SCALE * </span><span class=cF7>(</span><span class=cF0>j - FIRE_HEIGHT / </span><span class=cFE>2</span><span class=cF0> + (</span><span class=cFE>19</span><span class=cF0> * </span><span class=cF5>tS</span><span class=cF0> + j) % </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>7</span><span class=cF7>)</span><span class=cF0> *
<a name="l201"></a> </span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;theta</span><span class=cF7>)</span><span class=cF0> + FIRE_X_SCALE * </span><span class=cF7>(</span><span class=cF0>i - FIRE_WIDTH / </span><span class=cFE>2</span><span class=cF0> + (</span><span class=cFE>13</span><span class=cF0> * </span><span class=cF5>tS</span><span class=cF0> + i) % </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>7</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l202"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l203"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l204"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l205"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l206"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0>, tmpo-&gt;y, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0> + </span><span class=cFE>10</span><span class=cF0>, tmpo-&gt;y);
<a name="l207"></a>
<a name="l208"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;life_percent &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l209"></a> {
<a name="l210"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;life_percent &lt; </span><span class=cFE>33</span><span class=cF0>)
<a name="l211"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l212"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;life_percent &lt; </span><span class=cFE>66</span><span class=cF0>)
<a name="l213"></a> dc-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l214"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l215"></a> dc-&gt;color = </span><span class=cF3>GREEN</span><span class=cF0>;
<a name="l216"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0>, tmpo-&gt;y, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0> + </span><span class=cFE>10</span><span class=cF0> * tmpo-&gt;life_percent / </span><span class=cFE>100</span><span class=cF0>, tmpo-&gt;y);
<a name="l217"></a> }
<a name="l218"></a>
<a name="l219"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l220"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0>, tmpo-&gt;y + </span><span class=cFE>2</span><span class=cF0>, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0> + </span><span class=cFE>10</span><span class=cF0>, tmpo-&gt;y + </span><span class=cFE>2</span><span class=cF0>);
<a name="l221"></a> d = tmpo-&gt;fuel * </span><span class=cFE>100</span><span class=cF0> / tmpo-&gt;max_fuel;
<a name="l222"></a> </span><span class=cF1>if</span><span class=cF0> (d &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l223"></a> {
<a name="l224"></a> </span><span class=cF1>if</span><span class=cF0> (d &lt; </span><span class=cFE>33</span><span class=cF0>)
<a name="l225"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l226"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (d &lt; </span><span class=cFE>66</span><span class=cF0>)
<a name="l227"></a> dc-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l228"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l229"></a> dc-&gt;color = </span><span class=cF3>GREEN</span><span class=cF0>;
<a name="l230"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0>, tmpo-&gt;y + </span><span class=cFE>2</span><span class=cF0>, tmpo-&gt;x + </span><span class=cFE>5</span><span class=cF0> + </span><span class=cFE>10</span><span class=cF0> * d / </span><span class=cFE>100</span><span class=cF0>, tmpo-&gt;y + </span><span class=cFE>2</span><span class=cF0>);
<a name="l231"></a> }
<a name="l232"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l233"></a> }
<a name="l234"></a> tmpo = tmpo-&gt;next;
<a name="l235"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l236"></a>
<a name="l237"></a> tmpo = obj_head.next;
<a name="l238"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l239"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l240"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; OF_ACTIVE &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;flags &amp; OF_SHIP</span><span class=cF7>)</span><span class=cF0>)
<a name="l241"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc, tmpo-&gt;x, tmpo-&gt;y, </span><span class=cFE>0</span><span class=cF0>, imgs[tmpo-&gt;player][tmpo-&gt;type], tmpo-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l242"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; OF_SHOOTING)
<a name="l243"></a> {
<a name="l244"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l245"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, tmpo-&gt;x, tmpo-&gt;y, tmpo-&gt;target_x, tmpo-&gt;target_y, </span><span class=cFE>3</span><span class=cF0>);
<a name="l246"></a> }
<a name="l247"></a> tmpo = tmpo-&gt;next;
<a name="l248"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l249"></a>
<a name="l250"></a> dc-&gt;flags |= </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l251"></a> </span><span class=cF1>if</span><span class=cF0> (cur_time &lt; launch_t)
<a name="l252"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l253"></a> dc-&gt;color = </span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l254"></a> </span><span class=cF5>GrArrow3</span><span class=cF0>(dc, launch_unit_x1, launch_unit_y1, </span><span class=cFE>0</span><span class=cF0>, launch_unit_x2, launch_unit_y2, </span><span class=cFE>0</span><span class=cF0>);
<a name="l255"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l256"></a> </span><span class=cF1>if</span><span class=cF0> (cur_time &lt; return_t)
<a name="l257"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l258"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l259"></a> </span><span class=cF5>GrArrow3</span><span class=cF0>(dc, return_unit_x1, return_unit_y1, </span><span class=cFE>0</span><span class=cF0>, return_unit_x2, return_unit_y2, </span><span class=cFE>0</span><span class=cF0>);
<a name="l260"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l261"></a> </span><span class=cF1>if</span><span class=cF0> (cur_time&lt;set_theta_t)
<a name="l262"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l263"></a> dc-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l264"></a> </span><span class=cF5>GrArrow3</span><span class=cF0>(dc, set_theta_unit_x1, set_theta_unit_y1, </span><span class=cFE>0</span><span class=cF0>, set_theta_unit_x2, set_theta_unit_y2, </span><span class=cFE>0</span><span class=cF0>);
<a name="l265"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l266"></a>
<a name="l267"></a> dc-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l268"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, -task-&gt;scroll_x, -task-&gt;scroll_y, </span><span class=cF6>&quot;Game Speed: %5.2f&quot;</span><span class=cF0>, game_speed);
<a name="l269"></a> dc-&gt;color = </span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l270"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, -task-&gt;scroll_x, -task-&gt;scroll_y + </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>, </span><span class=cF6>&quot;Player 1: %d&quot;</span><span class=cF0>, num_alive[</span><span class=cFE>0</span><span class=cF0>]);
<a name="l271"></a> dc-&gt;color = </span><span class=cF3>LTPURPLE</span><span class=cF0>;
<a name="l272"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, -task-&gt;scroll_x, -task-&gt;scroll_y + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>, </span><span class=cF6>&quot;Player 2: %d&quot;</span><span class=cF0>, num_alive[</span><span class=cFE>1</span><span class=cF0>]);
<a name="l273"></a>
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>!num_alive[</span><span class=cFE>0</span><span class=cF0>] || !num_alive[</span><span class=cFE>1</span><span class=cF0>]</span><span class=cF7>)</span><span class=cF0> &amp;&amp; </span><span class=cF5>Blink</span><span class=cF0>)
<a name="l275"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l276"></a> </span><span class=cF1>if</span><span class=cF0> (!num_alive[</span><span class=cFE>1</span><span class=cF0>])
<a name="l277"></a> {
<a name="l278"></a> dc-&gt;color = </span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l279"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, task-&gt;pix_width &gt;&gt; </span><span class=cFE>1</span><span class=cF0> - </span><span class=cF7>(</span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>14</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> - task-&gt;scroll_x,
<a name="l280"></a> task-&gt;pix_height &gt;&gt; </span><span class=cFE>1</span><span class=cF0> - </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> - task-&gt;scroll_y, </span><span class=cF6>&quot;Game Completed&quot;</span><span class=cF0>);
<a name="l281"></a> }
<a name="l282"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l283"></a> {
<a name="l284"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l285"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, task-&gt;pix_width &gt;&gt; </span><span class=cFE>1</span><span class=cF0> - </span><span class=cF7>(</span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>9</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> - task-&gt;scroll_x,
<a name="l286"></a> task-&gt;pix_height &gt;&gt; </span><span class=cFE>1</span><span class=cF0> - </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> - task-&gt;scroll_y, </span><span class=cF6>&quot;Game Over&quot;</span><span class=cF0>);
<a name="l287"></a> }
<a name="l288"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l289"></a>}
<a name="l290"></a>
<a name="l291"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l292"></a>{
<a name="l293"></a> </span><span class=cF9>I64</span><span class=cF0> i, fighter, ship, player, squadron,
<a name="l294"></a> w = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width, h = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height;
<a name="l295"></a> Squadron *tmps;
<a name="l296"></a> Obj *tmpo, *tmpo1;
<a name="l297"></a>
<a name="l298"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;obj_head);
<a name="l299"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;torpedo_head);
<a name="l300"></a>
<a name="l301"></a> next_noise = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l302"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;scroll_x = </span><span class=cFE>0</span><span class=cF0>;
<a name="l303"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;scroll_y = </span><span class=cFE>0</span><span class=cF0>;
<a name="l304"></a> game_speed = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l305"></a> launch_t = return_t = set_theta_t = </span><span class=cFE>0</span><span class=cF0>;
<a name="l306"></a> main_task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l307"></a> num_squadrons = </span><span class=cFE>0</span><span class=cF0>;
<a name="l308"></a> </span><span class=cF1>for</span><span class=cF0> (player = </span><span class=cFE>0</span><span class=cF0>; player &lt; PLAYERS_NUM; player++)
<a name="l309"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l310"></a> num_alive[player] = </span><span class=cFE>0</span><span class=cF0>;
<a name="l311"></a> </span><span class=cF1>for</span><span class=cF0> (ship = </span><span class=cFE>0</span><span class=cF0>; ship &lt; num_cruisers[player]; ship++)
<a name="l312"></a> {
<a name="l313"></a> tmpo1 = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Obj</span><span class=cF7>)</span><span class=cF0>);
<a name="l314"></a> num_alive[player]++;
<a name="l315"></a> tmpo1-&gt;type = OT_CRUISER;
<a name="l316"></a> tmpo1-&gt;player = player;
<a name="l317"></a> tmpo1-&gt;squadron = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l318"></a> tmpo1-&gt;member_num = ship;
<a name="l319"></a> tmpo1-&gt;flags = OF_ACTIVE|OF_SHIP;
<a name="l320"></a> tmpo1-&gt;x = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0> * w * (</span><span class=cF5>Rand</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>) + w &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l321"></a> tmpo1-&gt;y = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0> * h * (</span><span class=cF5>Rand</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>) + h &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l322"></a> tmpo1-&gt;host = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l323"></a> tmpo1-&gt;speed = </span><span class=cFE>35</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l324"></a> tmpo1-&gt;turn_rate = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l325"></a> tmpo1-&gt;theta = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * (</span><span class=cF5>Rand</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>);
<a name="l326"></a> tmpo1-&gt;dtheta = </span><span class=cFE>0</span><span class=cF0>;
<a name="l327"></a> tmpo1-&gt;life_percent = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l328"></a> tmpo1-&gt;fuel = tmpo1-&gt;max_fuel = </span><span class=cFE>100000</span><span class=cF0>;
<a name="l329"></a> tmpo1-&gt;fuel_burn_rate = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l330"></a> tmpo1-&gt;air_guns = </span><span class=cFE>5000</span><span class=cF0>;
<a name="l331"></a> tmpo1-&gt;air_guns_range = </span><span class=cFE>30</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l332"></a> tmpo1-&gt;ship_guns = </span><span class=cFE>10000</span><span class=cF0>;
<a name="l333"></a> tmpo1-&gt;ship_guns_range = </span><span class=cFE>30</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l334"></a> tmpo1-&gt;torpedos = tmpo1-&gt;max_torpedos = </span><span class=cFE>0</span><span class=cF0>;
<a name="l335"></a> tmpo1-&gt;torpedos_range = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l336"></a> tmpo1-&gt;next_action_time = </span><span class=cFE>0</span><span class=cF0>;
<a name="l337"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpo1, obj_head.last);
<a name="l338"></a> }
<a name="l339"></a>
<a name="l340"></a> </span><span class=cF1>for</span><span class=cF0> (ship = </span><span class=cFE>0</span><span class=cF0>; ship &lt; num_carriers[player]; ship++)
<a name="l341"></a> {
<a name="l342"></a> tmpo1 = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Obj</span><span class=cF7>)</span><span class=cF0>);
<a name="l343"></a> num_alive[player]++;
<a name="l344"></a> tmpo1-&gt;type = OT_CARRIER;
<a name="l345"></a> tmpo1-&gt;player = player;
<a name="l346"></a> tmpo1-&gt;squadron = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l347"></a> tmpo1-&gt;member_num = ship;
<a name="l348"></a> tmpo1-&gt;flags = OF_ACTIVE|OF_SHIP;
<a name="l349"></a> tmpo1-&gt;x = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0> * w * (</span><span class=cF5>Rand</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>) + w &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l350"></a> tmpo1-&gt;y = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0> * h * (</span><span class=cF5>Rand</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>) + h &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l351"></a> tmpo1-&gt;host = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l352"></a> tmpo1-&gt;speed = </span><span class=cFE>28</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l353"></a> tmpo1-&gt;turn_rate = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l354"></a> tmpo1-&gt;theta = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * (</span><span class=cF5>Rand</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>);
<a name="l355"></a> tmpo1-&gt;dtheta = </span><span class=cFE>0</span><span class=cF0>;
<a name="l356"></a> tmpo1-&gt;life_percent = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l357"></a> tmpo1-&gt;fuel = tmpo1-&gt;max_fuel = </span><span class=cFE>750000</span><span class=cF0>;
<a name="l358"></a> tmpo1-&gt;fuel_burn_rate = </span><span class=cFE>500</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l359"></a> tmpo1-&gt;air_guns = </span><span class=cFE>5000</span><span class=cF0>;
<a name="l360"></a> tmpo1-&gt;air_guns_range = </span><span class=cFE>20</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l361"></a> tmpo1-&gt;ship_guns = </span><span class=cFE>2000</span><span class=cF0>;
<a name="l362"></a> tmpo1-&gt;ship_guns_range = </span><span class=cFE>30</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l363"></a> tmpo1-&gt;torpedos = tmpo1-&gt;max_torpedos = </span><span class=cFE>0</span><span class=cF0>;
<a name="l364"></a> tmpo1-&gt;torpedos_range = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l365"></a> tmpo1-&gt;next_action_time = </span><span class=cFE>0</span><span class=cF0>;
<a name="l366"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpo1, obj_head.last);
<a name="l367"></a>
<a name="l368"></a> </span><span class=cF1>for</span><span class=cF0> (squadron = </span><span class=cFE>0</span><span class=cF0>; squadron &lt; num_squadrons_per_carrier[player]; squadron++, num_squadrons++)
<a name="l369"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l370"></a> </span><span class=cF1>for</span><span class=cF0> (fighter = </span><span class=cFE>0</span><span class=cF0>; fighter &lt; num_planes_per_squadron[player]; fighter++)
<a name="l371"></a> {
<a name="l372"></a> tmpo = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Obj</span><span class=cF7>)</span><span class=cF0>);
<a name="l373"></a> num_alive[player]++;
<a name="l374"></a> tmpo-&gt;type = OT_FIGHTER;
<a name="l375"></a> tmpo-&gt;player = player;
<a name="l376"></a> tmpo-&gt;squadron = num_squadrons;
<a name="l377"></a> tmpo-&gt;member_num = fighter;
<a name="l378"></a> tmpo-&gt;flags = </span><span class=cFE>0</span><span class=cF0>;
<a name="l379"></a> tmpo-&gt;host = tmpo1;
<a name="l380"></a> tmpo-&gt;speed = </span><span class=cFE>300</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l381"></a> tmpo-&gt;turn_rate = </span><span class=cFE>25</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l382"></a> tmpo-&gt;life_percent = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l383"></a> tmpo-&gt;fuel = tmpo-&gt;max_fuel = </span><span class=cFE>1000</span><span class=cF0>;
<a name="l384"></a> tmpo-&gt;fuel_burn_rate = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l385"></a> tmpo-&gt;air_guns = </span><span class=cFE>35000</span><span class=cF0>;
<a name="l386"></a> tmpo-&gt;air_guns_range = </span><span class=cFE>8</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l387"></a> tmpo-&gt;ship_guns = </span><span class=cFE>0</span><span class=cF0>;
<a name="l388"></a> tmpo-&gt;ship_guns_range = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l389"></a> tmpo-&gt;torpedos = tmpo-&gt;max_torpedos = </span><span class=cFE>1</span><span class=cF0>;
<a name="l390"></a> tmpo-&gt;torpedos_range = </span><span class=cFE>20</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l391"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpo, obj_head.last);
<a name="l392"></a> }
<a name="l393"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l394"></a> }
<a name="l395"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l396"></a> squadrons = </span><span class=cF5>CAlloc</span><span class=cF0>(num_squadrons * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Squadron</span><span class=cF7>)</span><span class=cF0>);
<a name="l397"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>, tmps = squadrons; i &lt; num_squadrons; i++, tmps++)
<a name="l398"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l399"></a> tmps-&gt;next_in_squadron = tmps-&gt;last_in_squadron = tmps;
<a name="l400"></a> tmps-&gt;squadron = i;
<a name="l401"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l402"></a> tmpo = obj_head.next;
<a name="l403"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l404"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l405"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;squadron &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l406"></a> {
<a name="l407"></a> tmps = &amp;squadrons[tmpo-&gt;squadron];
<a name="l408"></a> tmps-&gt;host = tmpo-&gt;host;
<a name="l409"></a> tmps-&gt;player = tmpo-&gt;player;
<a name="l410"></a> tmps-&gt;total_mask = </span><span class=cFE>1</span><span class=cF0> &lt;&lt; num_planes_per_squadron[tmpo-&gt;player] - </span><span class=cFE>1</span><span class=cF0>;
<a name="l411"></a> SquadronIns(tmpo, tmps-&gt;last_in_squadron);
<a name="l412"></a> }
<a name="l413"></a> tmpo = tmpo-&gt;next;
<a name="l414"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l415"></a>}
<a name="l416"></a>
<a name="l417"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l418"></a>{
<a name="l419"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;obj_head, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l420"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&amp;torpedo_head, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l421"></a> </span><span class=cF5>Free</span><span class=cF0>(squadrons);
<a name="l422"></a>}
<a name="l423"></a>
<a name="l424"></a>Obj *ObjLaunch(</span><span class=cF9>I64</span><span class=cF0> player, </span><span class=cF9>I64</span><span class=cF0> squadron=-</span><span class=cFE>1</span><span class=cF0>, Obj *host=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> x=</span><span class=cF3>F64_MAX</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> y=</span><span class=cF3>F64_MAX</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> theta=</span><span class=cF3>F64_MAX</span><span class=cF0>)
<a name="l425"></a>{
<a name="l426"></a> Obj *tmpo;
<a name="l427"></a> </span><span class=cF1>F64</span><span class=cF0> cur_time = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l428"></a>
<a name="l429"></a> </span><span class=cF1>if</span><span class=cF0> (!host)
<a name="l430"></a> host = ObjFind(x, y,,, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; OT_CARRIER, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; player);
<a name="l431"></a> </span><span class=cF1>if</span><span class=cF0> (host &amp;&amp; cur_time&gt;host-&gt;next_action_time)
<a name="l432"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l433"></a> </span><span class=cF1>if</span><span class=cF0> (theta == </span><span class=cF3>F64_MAX</span><span class=cF0>)
<a name="l434"></a> theta = </span><span class=cF5>Arg</span><span class=cF0>(x - host-&gt;x, y - host-&gt;y);
<a name="l435"></a> tmpo = obj_head.next;
<a name="l436"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l437"></a> {
<a name="l438"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;host == host &amp;&amp; </span><span class=cF7>(</span><span class=cF0>squadron &lt; </span><span class=cFE>0</span><span class=cF0> || tmpo-&gt;squadron == squadron</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l439"></a> !</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;flags &amp; OF_ACTIVE</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l440"></a> </span><span class=cF7>(</span><span class=cF0>tmpo-&gt;squadron &lt; </span><span class=cFE>0</span><span class=cF0> || squadrons[tmpo-&gt;squadron].action == SA_PARKED ||
<a name="l441"></a> squadrons[tmpo-&gt;squadron].action == SA_LAUNCHING</span><span class=cF7>)</span><span class=cF0>)
<a name="l442"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l443"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;fuel &lt;= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l444"></a></span><span class=cF2>//When low on fuel, not zero, gets launched and captured.</span><span class=cF0>
<a name="l445"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;squadrons[tmpo-&gt;squadron].dead_mask, tmpo-&gt;member_num);
<a name="l446"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l447"></a> {
<a name="l448"></a> tmpo-&gt;flags = tmpo-&gt;flags &amp; ~OF_RETURNING | OF_ACTIVE;
<a name="l449"></a> tmpo-&gt;theta = host-&gt;theta;
<a name="l450"></a> </span><span class=cF1>if</span><span class=cF0> (x == </span><span class=cF3>F64_MAX</span><span class=cF0> || y == </span><span class=cF3>F64_MAX</span><span class=cF0> || </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>x - host-&gt;x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>y - host-&gt;y</span><span class=cF7>)</span><span class=cF0> &gt; </span><span class=cFE>3</span><span class=cF0> * </span><span class=cFE>3</span><span class=cF0>)
<a name="l451"></a> tmpo-&gt;dtheta = </span><span class=cF5>Wrap</span><span class=cF0>(theta - tmpo-&gt;theta, -</span><span class=cF3>pi</span><span class=cF0>);
<a name="l452"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l453"></a> tmpo-&gt;dtheta = </span><span class=cFE>0</span><span class=cF0>;
<a name="l454"></a> tmpo-&gt;x = host-&gt;x;
<a name="l455"></a> tmpo-&gt;y = host-&gt;y;
<a name="l456"></a> host-&gt;next_action_time = cur_time + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0> / game_speed;
<a name="l457"></a> </span><span class=cF1>return</span><span class=cF0> tmpo;
<a name="l458"></a> }
<a name="l459"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l460"></a> tmpo = tmpo-&gt;next;
<a name="l461"></a> }
<a name="l462"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l463"></a>
<a name="l464"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l465"></a>}
<a name="l466"></a>
<a name="l467"></a>Squadron *SquadronLaunch(</span><span class=cF9>I64</span><span class=cF0> player, </span><span class=cF1>F64</span><span class=cF0> x=</span><span class=cF3>F64_MAX</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> y=</span><span class=cF3>F64_MAX</span><span class=cF0>)
<a name="l468"></a>{
<a name="l469"></a> Squadron *tmps;
<a name="l470"></a> Obj *tmpo;
<a name="l471"></a>
<a name="l472"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo = ObjLaunch</span><span class=cF7>(</span><span class=cF0>player,,, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l473"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l474"></a> </span><span class=cF1>if</span><span class=cF0> (player == </span><span class=cFE>0</span><span class=cF0>)
<a name="l475"></a> {
<a name="l476"></a> launch_unit_x1 = tmpo-&gt;x;
<a name="l477"></a> launch_unit_y1 = tmpo-&gt;y;
<a name="l478"></a> launch_unit_x2 = </span><span class=cFB>mouse</span><span class=cF0>.pos.x - main_task-&gt;pix_left - main_task-&gt;scroll_x;
<a name="l479"></a> launch_unit_y2 = </span><span class=cFB>mouse</span><span class=cF0>.pos.y - main_task-&gt;pix_top - main_task-&gt;scroll_y;
<a name="l480"></a> launch_t = </span><span class=cF5>tS</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l481"></a> }
<a name="l482"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;squadron &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l483"></a> {
<a name="l484"></a> tmps = &amp;squadrons[tmpo-&gt;squadron];
<a name="l485"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;action == SA_PARKED)
<a name="l486"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l487"></a> tmps-&gt;action = SA_LAUNCHING;
<a name="l488"></a> tmps-&gt;theta = tmpo-&gt;theta + tmpo-&gt;dtheta;
<a name="l489"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l490"></a> </span><span class=cF1>return</span><span class=cF0> tmps;
<a name="l491"></a> }
<a name="l492"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l493"></a>
<a name="l494"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l495"></a>}
<a name="l496"></a>
<a name="l497"></a>Obj *ObjReturn(</span><span class=cF9>I64</span><span class=cF0> player, </span><span class=cF1>F64</span><span class=cF0> x, </span><span class=cF1>F64</span><span class=cF0> y)
<a name="l498"></a>{
<a name="l499"></a> Obj *tmpo;
<a name="l500"></a>
<a name="l501"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo = ObjFind</span><span class=cF7>(</span><span class=cF0>x, y, OF_ACTIVE, OF_ACTIVE, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; OT_FIGHTER, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; player</span><span class=cF7>)</span><span class=cF0>)
<a name="l502"></a> tmpo-&gt;flags |= OF_RETURNING;
<a name="l503"></a>
<a name="l504"></a> </span><span class=cF1>return</span><span class=cF0> tmpo;
<a name="l505"></a>}
<a name="l506"></a>
<a name="l507"></a>Squadron *SquadronReturn(</span><span class=cF9>I64</span><span class=cF0> player, </span><span class=cF1>F64</span><span class=cF0> x, </span><span class=cF1>F64</span><span class=cF0> y)
<a name="l508"></a>{
<a name="l509"></a> Squadron *tmps;
<a name="l510"></a> Obj *tmpo;
<a name="l511"></a>
<a name="l512"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo = ObjReturn</span><span class=cF7>(</span><span class=cF0>player, x, y</span><span class=cF7>)</span><span class=cF0>)
<a name="l513"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l514"></a> </span><span class=cF1>if</span><span class=cF0> (player == </span><span class=cFE>0</span><span class=cF0>)
<a name="l515"></a> {
<a name="l516"></a> return_unit_x1 = tmpo-&gt;x;
<a name="l517"></a> return_unit_y1 = tmpo-&gt;y;
<a name="l518"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;host)
<a name="l519"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l520"></a> return_unit_x2 = tmpo-&gt;host-&gt;x;
<a name="l521"></a> return_unit_y2 = tmpo-&gt;host-&gt;y;
<a name="l522"></a> return_t = </span><span class=cF5>tS</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l523"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l524"></a> }
<a name="l525"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;squadron &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l526"></a> {
<a name="l527"></a> tmps = &amp;squadrons[tmpo-&gt;squadron];
<a name="l528"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;action == SA_FLYING)
<a name="l529"></a> tmps-&gt;action = SA_RETURNING;
<a name="l530"></a> </span><span class=cF1>return</span><span class=cF0> tmps;
<a name="l531"></a> }
<a name="l532"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l533"></a>
<a name="l534"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l535"></a>}
<a name="l536"></a>
<a name="l537"></a>Obj *ObjSettheta(</span><span class=cF9>I64</span><span class=cF0> player, </span><span class=cF1>F64</span><span class=cF0> x=</span><span class=cF3>F64_MAX</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> y=</span><span class=cF3>F64_MAX</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> theta=</span><span class=cF3>F64_MAX</span><span class=cF0>)
<a name="l538"></a>{
<a name="l539"></a> Obj *tmpo;
<a name="l540"></a>
<a name="l541"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>tmpo = ObjFind(x, y,,,, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; player)</span><span class=cF7>)</span><span class=cF0> &amp;&amp; tmpo-&gt;flags &amp; OF_ACTIVE &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;flags &amp; OF_RETURNING</span><span class=cF7>)</span><span class=cF0>)
<a name="l542"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l543"></a> </span><span class=cF1>if</span><span class=cF0> (theta == </span><span class=cF3>F64_MAX</span><span class=cF0>)
<a name="l544"></a> theta = </span><span class=cF5>Arg</span><span class=cF0>(x - tmpo-&gt;x, y - tmpo-&gt;y);
<a name="l545"></a> tmpo-&gt;dtheta += </span><span class=cF5>Wrap</span><span class=cF0>(theta - </span><span class=cF7>(</span><span class=cF0>tmpo-&gt;theta + tmpo-&gt;dtheta</span><span class=cF7>)</span><span class=cF0>, -</span><span class=cF3>pi</span><span class=cF0>);
<a name="l546"></a> </span><span class=cF1>return</span><span class=cF0> tmpo;
<a name="l547"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l548"></a>
<a name="l549"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l550"></a>}
<a name="l551"></a>
<a name="l552"></a>Squadron *SquadronSettheta(</span><span class=cF9>I64</span><span class=cF0> player, </span><span class=cF1>F64</span><span class=cF0> x=</span><span class=cF3>F64_MAX</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> y=</span><span class=cF3>F64_MAX</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> theta=</span><span class=cF3>F64_MAX</span><span class=cF0>)
<a name="l553"></a>{
<a name="l554"></a> Squadron *tmps;
<a name="l555"></a> Obj *tmpo;
<a name="l556"></a>
<a name="l557"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo = ObjSettheta</span><span class=cF7>(</span><span class=cF0>player, x, y, theta</span><span class=cF7>)</span><span class=cF0>)
<a name="l558"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l559"></a> </span><span class=cF1>if</span><span class=cF0> (player == </span><span class=cFE>0</span><span class=cF0>)
<a name="l560"></a> {
<a name="l561"></a> set_theta_unit_x1 = tmpo-&gt;x;
<a name="l562"></a> set_theta_unit_y1 = tmpo-&gt;y;
<a name="l563"></a> set_theta_unit_x2 = </span><span class=cFB>mouse</span><span class=cF0>.pos.x - main_task-&gt;pix_left - main_task-&gt;scroll_x;
<a name="l564"></a> set_theta_unit_y2 = </span><span class=cFB>mouse</span><span class=cF0>.pos.y - main_task-&gt;pix_top - main_task-&gt;scroll_y;
<a name="l565"></a> set_theta_t = </span><span class=cF5>tS</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l566"></a> }
<a name="l567"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;squadron &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l568"></a> {
<a name="l569"></a> tmps = &amp;squadrons[tmpo-&gt;squadron];
<a name="l570"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;action == SA_FLYING)
<a name="l571"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l572"></a> tmps-&gt;action = SA_SET_theta;
<a name="l573"></a> tmps-&gt;theta = tmpo-&gt;theta + tmpo-&gt;dtheta;
<a name="l574"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l575"></a> </span><span class=cF1>return</span><span class=cF0> tmps;
<a name="l576"></a> }
<a name="l577"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l578"></a>
<a name="l579"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l580"></a>}
<a name="l581"></a>
<a name="l582"></a></span><span class=cF1>U0</span><span class=cF0> SquadronActions()
<a name="l583"></a>{
<a name="l584"></a> </span><span class=cF9>I64</span><span class=cF0> i, completed_mask;
<a name="l585"></a> Obj *tmpo;
<a name="l586"></a> Squadron *tmps;
<a name="l587"></a>
<a name="l588"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>, tmps = squadrons; i &lt; num_squadrons; i++, tmps++)
<a name="l589"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l590"></a> completed_mask = </span><span class=cFE>0</span><span class=cF0>;
<a name="l591"></a> </span><span class=cF1>switch</span><span class=cF0> (tmps-&gt;action)
<a name="l592"></a> {
<a name="l593"></a> </span><span class=cF1>case</span><span class=cF0> SA_LAUNCHING:
<a name="l594"></a> ObjLaunch(tmps-&gt;player, i, tmps-&gt;host,,, tmps-&gt;theta);
<a name="l595"></a> tmpo = tmps-&gt;next_in_squadron;
<a name="l596"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != tmps)
<a name="l597"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l598"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;completed_mask, tmpo-&gt;member_num, tmpo-&gt;flags &amp; OF_ACTIVE);
<a name="l599"></a> tmpo = tmpo-&gt;next_in_squadron;
<a name="l600"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l601"></a> </span><span class=cF1>if</span><span class=cF0> (completed_mask | tmps-&gt;dead_mask == tmps-&gt;total_mask)
<a name="l602"></a> tmps-&gt;action = SA_FLYING;
<a name="l603"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l604"></a>
<a name="l605"></a> </span><span class=cF1>case</span><span class=cF0> SA_FLYING:
<a name="l606"></a> tmpo = tmps-&gt;next_in_squadron;
<a name="l607"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != tmps)
<a name="l608"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l609"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;completed_mask, tmpo-&gt;member_num, !</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;flags &amp; OF_ACTIVE</span><span class=cF7>)</span><span class=cF0>);
<a name="l610"></a> tmpo = tmpo-&gt;next_in_squadron;
<a name="l611"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l612"></a> </span><span class=cF1>if</span><span class=cF0> (completed_mask | tmps-&gt;dead_mask == tmps-&gt;total_mask)
<a name="l613"></a> tmps-&gt;action = SA_PARKED;
<a name="l614"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l615"></a>
<a name="l616"></a> </span><span class=cF1>case</span><span class=cF0> SA_SET_theta:
<a name="l617"></a> tmpo = tmps-&gt;next_in_squadron;
<a name="l618"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != tmps)
<a name="l619"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l620"></a> tmpo-&gt;dtheta += </span><span class=cF5>Wrap</span><span class=cF0>(tmps-&gt;theta - </span><span class=cF7>(</span><span class=cF0>tmpo-&gt;theta + tmpo-&gt;dtheta</span><span class=cF7>)</span><span class=cF0>, -</span><span class=cF3>pi</span><span class=cF0>);
<a name="l621"></a> tmpo = tmpo-&gt;next_in_squadron;
<a name="l622"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l623"></a> tmps-&gt;action = SA_FLYING;
<a name="l624"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l625"></a>
<a name="l626"></a> </span><span class=cF1>case</span><span class=cF0> SA_RETURNING:
<a name="l627"></a> tmpo = tmps-&gt;next_in_squadron;
<a name="l628"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != tmps)
<a name="l629"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l630"></a> tmpo-&gt;flags |= OF_RETURNING;
<a name="l631"></a> </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;completed_mask, tmpo-&gt;member_num, !</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;flags &amp; OF_ACTIVE</span><span class=cF7>)</span><span class=cF0>);
<a name="l632"></a> tmpo = tmpo-&gt;next_in_squadron;
<a name="l633"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l634"></a> </span><span class=cF1>if</span><span class=cF0> (completed_mask | tmps-&gt;dead_mask == tmps-&gt;total_mask)
<a name="l635"></a> tmps-&gt;action = SA_PARKED;
<a name="l636"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l637"></a> }
<a name="l638"></a> </span><span class=cF1>if</span><span class=cF0> (tmps-&gt;dead_mask == tmps-&gt;total_mask)
<a name="l639"></a> tmps-&gt;action=SA_DEAD;
<a name="l640"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l641"></a>}
<a name="l642"></a>
<a name="l643"></a></span><span class=cF1>U0</span><span class=cF0> AI(</span><span class=cF9>I64</span><span class=cF0> player, </span><span class=cF1>F64</span><span class=cF0> period)
<a name="l644"></a>{
<a name="l645"></a> Obj *tmpo;
<a name="l646"></a>
<a name="l647"></a> tmpo = obj_head.next;
<a name="l648"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l649"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l650"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;player == player)
<a name="l651"></a> {
<a name="l652"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;type == OT_CARRIER &amp;&amp; </span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>5</span><span class=cF0> * period)
<a name="l653"></a> SquadronLaunch(player, tmpo-&gt;x, tmpo-&gt;y);
<a name="l654"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags&amp;OF_ACTIVE &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;flags&amp;OF_RETURNING</span><span class=cF7>)</span><span class=cF0> &amp;&amp; </span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>10</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * period)
<a name="l655"></a> SquadronSettheta(player, tmpo-&gt;x, tmpo-&gt;y, tmpo-&gt;theta + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF7>(</span><span class=cF5>Rand</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF7>)</span><span class=cF0>);
<a name="l656"></a> }
<a name="l657"></a> tmpo = tmpo-&gt;next;
<a name="l658"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l659"></a>}
<a name="l660"></a>
<a name="l661"></a></span><span class=cF1>U0</span><span class=cF0> ShipDamage(Obj *tmpo, </span><span class=cF1>F64</span><span class=cF0> d)
<a name="l662"></a>{
<a name="l663"></a> </span><span class=cF9>I64</span><span class=cF0> i, x = </span><span class=cF5>Rand</span><span class=cF0> * FIRE_WIDTH, y = </span><span class=cF5>Rand</span><span class=cF0> * FIRE_HEIGHT;
<a name="l664"></a>
<a name="l665"></a> tmpo-&gt;life_percent -= d;
<a name="l666"></a> </span><span class=cF1>while</span><span class=cF0> (d &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l667"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l668"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bts</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;fire, y * FIRE_WIDTH + x</span><span class=cF7>)</span><span class=cF0>)
<a name="l669"></a> d -= </span><span class=cFE>500</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (FIRE_WIDTH * FIRE_HEIGHT);
<a name="l670"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l671"></a> d -= </span><span class=cFE>25</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (FIRE_WIDTH * FIRE_HEIGHT);
<a name="l672"></a> i = </span><span class=cF5>RandI16</span><span class=cF0> &amp; </span><span class=cFE>7</span><span class=cF0>;
<a name="l673"></a> x += </span><span class=cFB>gr_x_offsets</span><span class=cF0>[i];
<a name="l674"></a> y += </span><span class=cFB>gr_y_offsets</span><span class=cF0>[i];
<a name="l675"></a> </span><span class=cF1>while</span><span class=cF0> (x &gt;= FIRE_WIDTH)
<a name="l676"></a> x -= FIRE_WIDTH;
<a name="l677"></a>
<a name="l678"></a> </span><span class=cF1>while</span><span class=cF0> (x &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l679"></a> x += FIRE_WIDTH;
<a name="l680"></a>
<a name="l681"></a> </span><span class=cF1>while</span><span class=cF0> (y &gt;= FIRE_HEIGHT)
<a name="l682"></a> y -= FIRE_HEIGHT;
<a name="l683"></a>
<a name="l684"></a> </span><span class=cF1>while</span><span class=cF0> (y &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l685"></a> y += FIRE_HEIGHT;
<a name="l686"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l687"></a>}
<a name="l688"></a>
<a name="l689"></a></span><span class=cF1>U0</span><span class=cF0> ShipFix(Obj *tmpo, </span><span class=cF1>F64</span><span class=cF0> d)
<a name="l690"></a>{
<a name="l691"></a> tmpo-&gt;life_percent += d;
<a name="l692"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;life_percent &gt;= </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l693"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l694"></a> tmpo-&gt;life_percent = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l695"></a> </span><span class=cF5>MemSet</span><span class=cF0>(tmpo-&gt;fire, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Obj.fire</span><span class=cF7>)</span><span class=cF0>);
<a name="l696"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l697"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l698"></a> </span><span class=cF1>while</span><span class=cF0> (d &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l699"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Btr</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;fire, FIRE_WIDTH * FIRE_HEIGHT * </span><span class=cF5>Rand</span><span class=cF7>)</span><span class=cF0>)
<a name="l700"></a> d -= </span><span class=cFE>400</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (FIRE_WIDTH * FIRE_HEIGHT);
<a name="l701"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l702"></a> d -= </span><span class=cFE>20</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / (FIRE_WIDTH * FIRE_HEIGHT);
<a name="l703"></a>}
<a name="l704"></a>
<a name="l705"></a></span><span class=cF1>U0</span><span class=cF0> MyNoise(</span><span class=cF9>I64</span><span class=cF0> mS, </span><span class=cF1>F64</span><span class=cF0> min_ona, </span><span class=cF1>F64</span><span class=cF0> max_ona)
<a name="l706"></a>{</span><span class=cF2>//Make white noise for given number of mS.</span><span class=cF0>
<a name="l707"></a></span><span class=cF2>// See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Sound.CC.html#l432"><span class=cF4>Noise</span></a><span class=cF2>. On bare-metal, Spawn() hogs CPU.</span><span class=cF0>
<a name="l708"></a> </span><span class=cF9>CSoundEffectFrame</span><span class=cF0> *ns;
<a name="l709"></a>
<a name="l710"></a> </span><span class=cF1>if</span><span class=cF0> (mS &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l711"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l712"></a> ns = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CSoundEffectFrame</span><span class=cF7>)</span><span class=cF0>);
<a name="l713"></a> ns-&gt;type = </span><span class=cF3>SE_NOISE</span><span class=cF0>;
<a name="l714"></a> ns-&gt;duration = mS / </span><span class=cFE>1000</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l715"></a> ns-&gt;ona1 = min_ona;
<a name="l716"></a> ns-&gt;ona2 = max_ona;
<a name="l717"></a> </span><span class=cFB>music</span><span class=cF0>.mute++;
<a name="l718"></a> </span><span class=cF5>SoundEffectTask</span><span class=cF0>(ns);
<a name="l719"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l720"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l721"></a>
<a name="l722"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l723"></a>}
<a name="l724"></a>
<a name="l725"></a></span><span class=cF1>U0</span><span class=cF0> Combat(</span><span class=cF1>F64</span><span class=cF0> period)
<a name="l726"></a>{
<a name="l727"></a> </span><span class=cF1>F64</span><span class=cF0> d;
<a name="l728"></a> Obj *tmpo, *tmpo1;
<a name="l729"></a> Torpedo *tmpt;
<a name="l730"></a>
<a name="l731"></a> tmpo = obj_head.next;
<a name="l732"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l733"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l734"></a> tmpo-&gt;flags &amp;= ~OF_SHOOTING;
<a name="l735"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; OF_ACTIVE &amp;&amp;
<a name="l736"></a> </span><span class=cF7>(</span><span class=cF0>tmpo1 = ObjFind(tmpo-&gt;x, tmpo-&gt;y, OF_ACTIVE, OF_ACTIVE,, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF7>(</span><span class=cF0>tmpo-&gt;player ^ </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>, &amp;d)</span><span class=cF7>)</span><span class=cF0>)
<a name="l737"></a> {
<a name="l738"></a> tmpo-&gt;target_x = tmpo1-&gt;x;
<a name="l739"></a> tmpo-&gt;target_y = tmpo1-&gt;y;
<a name="l740"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo1-&gt;flags &amp; OF_SHIP)
<a name="l741"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l742"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;torpedos &amp;&amp; d &lt; tmpo-&gt;torpedos_range &amp;&amp; </span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>125</span><span class=cF0> * period)
<a name="l743"></a> {
<a name="l744"></a> tmpo-&gt;torpedos--;
<a name="l745"></a> tmpt = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Torpedo</span><span class=cF7>)</span><span class=cF0>);
<a name="l746"></a> tmpt-&gt;x = tmpo-&gt;x;
<a name="l747"></a> tmpt-&gt;y = tmpo-&gt;y;
<a name="l748"></a> tmpt-&gt;speed = </span><span class=cFE>100</span><span class=cF0>;
<a name="l749"></a> d /= tmpt-&gt;speed * (GAME_SPEED_SCALE * game_speed);
<a name="l750"></a> tmpo1-&gt;death_time = tmpt-&gt;timeout = </span><span class=cF5>tS</span><span class=cF0> + d;
<a name="l751"></a> tmpt-&gt;target = tmpo1;
<a name="l752"></a> tmpt-&gt;theta = </span><span class=cF5>Arg</span><span class=cF0>(tmpo1-&gt;x - tmpo-&gt;x, tmpo1-&gt;y - tmpo-&gt;y);
<a name="l753"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpt, torpedo_head.last);
<a name="l754"></a> </span><span class=cF5>Sweep</span><span class=cF0>(</span><span class=cFE>2000</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>, </span><span class=cFE>53</span><span class=cF0>);
<a name="l755"></a> }
<a name="l756"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;ship_guns &gt; </span><span class=cFE>0</span><span class=cF0> &amp;&amp; d &lt; tmpo-&gt;ship_guns_range)
<a name="l757"></a> {
<a name="l758"></a> tmpo-&gt;flags |= OF_SHOOTING;
<a name="l759"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>125</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * period)
<a name="l760"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l761"></a> ShipDamage(tmpo1, tmpo-&gt;ship_guns * </span><span class=cF5>Rand</span><span class=cF0> * period);
<a name="l762"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>10</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * period)
<a name="l763"></a> tmpo1-&gt;fuel *= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>75</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0>;
<a name="l764"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l765"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> &gt; next_noise)
<a name="l766"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l767"></a> MyNoise(</span><span class=cFE>100</span><span class=cF0>, </span><span class=cFE>29</span><span class=cF0>, </span><span class=cFE>46</span><span class=cF0>);
<a name="l768"></a> next_noise = </span><span class=cF5>tS</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>;
<a name="l769"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l770"></a> }
<a name="l771"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l772"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l773"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l774"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;air_guns &gt; </span><span class=cFE>0</span><span class=cF0> &amp;&amp; d &lt; tmpo-&gt;air_guns_range)
<a name="l775"></a> {
<a name="l776"></a> tmpo-&gt;flags |= OF_SHOOTING;
<a name="l777"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0>&lt;</span><span class=cFE>125</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * period)
<a name="l778"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l779"></a> tmpo1-&gt;life_percent -= tmpo-&gt;air_guns * </span><span class=cF5>Rand</span><span class=cF0> * period;
<a name="l780"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>10</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * period)
<a name="l781"></a> tmpo1-&gt;fuel *= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>75</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0>;
<a name="l782"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l783"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> &gt; next_noise)
<a name="l784"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l785"></a> MyNoise(</span><span class=cFE>25</span><span class=cF0>, </span><span class=cFE>62</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>);
<a name="l786"></a> next_noise = </span><span class=cF5>tS</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>025</span><span class=cF0>;
<a name="l787"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l788"></a> }
<a name="l789"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l790"></a> }
<a name="l791"></a> tmpo = tmpo-&gt;next;
<a name="l792"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l793"></a> tmpo = obj_head.next;
<a name="l794"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l795"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l796"></a> tmpo1 = tmpo-&gt;next;
<a name="l797"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;type == OT_FIGHTER &amp;&amp;
<a name="l798"></a> </span><span class=cF7>(</span><span class=cF0>tmpo-&gt;life_percent &lt;= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> || tmpo-&gt;flags &amp; OF_ACTIVE &amp;&amp; tmpo-&gt;fuel &lt;= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> || tmpo-&gt;host &amp;&amp;
<a name="l799"></a> !(tmpo-&gt;flags &amp; OF_ACTIVE) &amp;&amp; tmpo-&gt;host-&gt;life_percent &lt;= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l800"></a> ObjDel(tmpo);
<a name="l801"></a> tmpo = tmpo1;
<a name="l802"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l803"></a> tmpo = obj_head.next;
<a name="l804"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l805"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l806"></a> tmpo1 = tmpo-&gt;next;
<a name="l807"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;life_percent &lt;= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l808"></a> ObjDel(tmpo);
<a name="l809"></a> tmpo = tmpo1;
<a name="l810"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l811"></a>}
<a name="l812"></a>
<a name="l813"></a>#</span><span class=cF1>define</span><span class=cF0> ANIMATE_FREQ </span><span class=cFE>50</span><span class=cF0>
<a name="l814"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l815"></a>{
<a name="l816"></a> Obj *tmpo;
<a name="l817"></a> Torpedo *tmpt, *tmpt1;
<a name="l818"></a> </span><span class=cF1>F64</span><span class=cF0> d, period;
<a name="l819"></a>
<a name="l820"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l821"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l822"></a> period = GAME_SPEED_SCALE * game_speed / ANIMATE_FREQ;
<a name="l823"></a> SquadronActions;
<a name="l824"></a>
<a name="l825"></a> tmpo = obj_head.next;
<a name="l826"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l827"></a> {
<a name="l828"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; OF_ACTIVE &amp;&amp; tmpo-&gt;fuel &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l829"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l830"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;dtheta)
<a name="l831"></a> {
<a name="l832"></a> d = tmpo-&gt;dtheta;
<a name="l833"></a> </span><span class=cF1>if</span><span class=cF0> (d &gt; tmpo-&gt;turn_rate * period)
<a name="l834"></a> d = tmpo-&gt;turn_rate * period;
<a name="l835"></a> </span><span class=cF1>if</span><span class=cF0> (d &lt; -tmpo-&gt;turn_rate * period)
<a name="l836"></a> d = -tmpo-&gt;turn_rate * period;
<a name="l837"></a> tmpo-&gt;theta += d;
<a name="l838"></a> tmpo-&gt;dtheta -= d;
<a name="l839"></a> }
<a name="l840"></a> tmpo-&gt;x += tmpo-&gt;speed * </span><span class=cF5>Cos</span><span class=cF0>(tmpo-&gt;theta) * period * tmpo-&gt;life_percent / </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l841"></a> tmpo-&gt;y += tmpo-&gt;speed * </span><span class=cF5>Sin</span><span class=cF0>(tmpo-&gt;theta) * period * tmpo-&gt;life_percent / </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l842"></a> tmpo-&gt;fuel -= tmpo-&gt;speed * tmpo-&gt;fuel_burn_rate * period;
<a name="l843"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l844"></a> tmpo = tmpo-&gt;next;
<a name="l845"></a> }
<a name="l846"></a>
<a name="l847"></a> tmpt = torpedo_head.next;
<a name="l848"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != &amp;torpedo_head)
<a name="l849"></a> {
<a name="l850"></a> tmpt1 = tmpt-&gt;next;
<a name="l851"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> &gt; tmpt-&gt;timeout)
<a name="l852"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l853"></a> tmpo = tmpt-&gt;target;
<a name="l854"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>333333</span><span class=cF0>)
<a name="l855"></a> {
<a name="l856"></a> ShipDamage(tmpo, </span><span class=cFE>150</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0>);
<a name="l857"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>333333</span><span class=cF0>)
<a name="l858"></a> tmpo-&gt;fuel *= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>75</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0> + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0>;
<a name="l859"></a> }
<a name="l860"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpt);
<a name="l861"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpt);
<a name="l862"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l863"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l864"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l865"></a> tmpt-&gt;x += tmpt-&gt;speed * </span><span class=cF5>Cos</span><span class=cF0>(tmpt-&gt;theta) * period;
<a name="l866"></a> tmpt-&gt;y += tmpt-&gt;speed * </span><span class=cF5>Sin</span><span class=cF0>(tmpt-&gt;theta) * period;
<a name="l867"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l868"></a> tmpt = tmpt1;
<a name="l869"></a> }
<a name="l870"></a>
<a name="l871"></a> tmpo = obj_head.next;
<a name="l872"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l873"></a> {
<a name="l874"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;host &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;flags &amp; OF_ACTIVE</span><span class=cF7>)</span><span class=cF0>)
<a name="l875"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l876"></a> tmpo-&gt;x = tmpo-&gt;host-&gt;x;
<a name="l877"></a> tmpo-&gt;y = tmpo-&gt;host-&gt;y;
<a name="l878"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l879"></a> tmpo = tmpo-&gt;next;
<a name="l880"></a> }
<a name="l881"></a>
<a name="l882"></a> tmpo = obj_head.next;
<a name="l883"></a> </span><span class=cF1>while</span><span class=cF0> (tmpo != &amp;obj_head)
<a name="l884"></a> {
<a name="l885"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; OF_ACTIVE)
<a name="l886"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l887"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;host)
<a name="l888"></a> {
<a name="l889"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;x - tmpo-&gt;host-&gt;x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;y - tmpo-&gt;host-&gt;y</span><span class=cF7>)</span><span class=cF0>);
<a name="l890"></a> </span><span class=cF1>if</span><span class=cF0> (d &lt; </span><span class=cFE>8</span><span class=cF0> &amp;&amp; tmpo-&gt;max_fuel - tmpo-&gt;fuel &gt; </span><span class=cFE>30</span><span class=cF0>)
<a name="l891"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l892"></a> tmpo-&gt;life_percent = </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l893"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;host-&gt;fuel &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l894"></a> {
<a name="l895"></a> d = tmpo-&gt;max_fuel - tmpo-&gt;fuel;
<a name="l896"></a> </span><span class=cF1>if</span><span class=cF0> (d &gt; tmpo-&gt;host-&gt;fuel)
<a name="l897"></a> d = tmpo-&gt;host-&gt;fuel;
<a name="l898"></a> tmpo-&gt;host-&gt;fuel -= d;
<a name="l899"></a> tmpo-&gt;fuel += d;
<a name="l900"></a> }
<a name="l901"></a> tmpo-&gt;torpedos = tmpo-&gt;max_torpedos;
<a name="l902"></a> tmpo-&gt;x = tmpo-&gt;host-&gt;x;
<a name="l903"></a> tmpo-&gt;y = tmpo-&gt;host-&gt;y;
<a name="l904"></a> tmpo-&gt;flags &amp;= ~OF_ACTIVE;
<a name="l905"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l906"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (d &gt; tmpo-&gt;fuel - </span><span class=cFE>250</span><span class=cF0>)
<a name="l907"></a> tmpo-&gt;flags |= OF_RETURNING;
<a name="l908"></a> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;flags &amp; OF_RETURNING)
<a name="l909"></a> tmpo-&gt;dtheta += </span><span class=cF5>Wrap</span><span class=cF0>(</span><span class=cF5>Arg</span><span class=cF7>(</span><span class=cF0>tmpo-&gt;host-&gt;x - tmpo-&gt;x, tmpo-&gt;host-&gt;y - tmpo-&gt;y</span><span class=cF7>)</span><span class=cF0> - </span><span class=cF7>(</span><span class=cF0>tmpo-&gt;theta + tmpo-&gt;dtheta</span><span class=cF7>)</span><span class=cF0>, -</span><span class=cF3>pi</span><span class=cF0>);
<a name="l910"></a> }
<a name="l911"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpo-&gt;type == OT_CARRIER)
<a name="l912"></a> ShipFix(tmpo, </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * period);
<a name="l913"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l914"></a> tmpo = tmpo-&gt;next;
<a name="l915"></a> }
<a name="l916"></a>
<a name="l917"></a> AI(</span><span class=cFE>1</span><span class=cF0>, period);
<a name="l918"></a> Combat(period);
<a name="l919"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1000</span><span class=cF0> / ANIMATE_FREQ);
<a name="l920"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l921"></a>}
<a name="l922"></a>
<a name="l923"></a></span><span class=cF1>U0</span><span class=cF0> FlatTops()
<a name="l924"></a>{
<a name="l925"></a> </span><span class=cF9>I64</span><span class=cF0> arg1, arg2;
<a name="l926"></a>
<a name="l927"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l928"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;text_attr = </span><span class=cF3>BLUE</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l929"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l930"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l931"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l932"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l933"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l934"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>&quot;$GREEN${Left-Mouse}$FG$\t\tChange Course\n&quot;</span><span class=cF0>
<a name="l935"></a> </span><span class=cF6>&quot;$GREEN${Right-Mouse}$FG$\t\tLaunch Squadron\n&quot;</span><span class=cF0>
<a name="l936"></a> </span><span class=cF6>&quot;$GREEN${Right-Double-Mouse}$FG$\tReturn Squadron\n&quot;</span><span class=cF0>
<a name="l937"></a> </span><span class=cF6>&quot;$GREEN${Ctrl-Left Grab}$FG$\tScroll Screen\n&quot;</span><span class=cF0>);
<a name="l938"></a>
<a name="l939"></a> </span><span class=cF5>MenuPush</span><span class=cF0>( </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l940"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l941"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l942"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l943"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l944"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l945"></a> </span><span class=cF6>&quot; Faster(,'+');&quot;</span><span class=cF0>
<a name="l946"></a> </span><span class=cF6>&quot; Slower(,'-');&quot;</span><span class=cF0>
<a name="l947"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l948"></a> );
<a name="l949"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit |= </span><span class=cF3>WIF_SELF_MS_L</span><span class=cF0> | </span><span class=cF3>WIF_SELF_MS_R</span><span class=cF0>;
<a name="l950"></a> Init;
<a name="l951"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it = &amp;</span><span class=cF5>DrawIt</span><span class=cF0>;
<a name="l952"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;animate_task = </span><span class=cF5>Spawn</span><span class=cF0>(&amp;AnimateTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>&quot;Animate&quot;</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
<a name="l953"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l954"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l955"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l956"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>MessageGet</span><span class=cF7>(</span><span class=cF0>&amp;arg1, &amp;arg2,
<a name="l957"></a> </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_R_UP</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_R_D_UP</span><span class=cF7>)</span><span class=cF0>)
<a name="l958"></a> {
<a name="l959"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>:
<a name="l960"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1)
<a name="l961"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l962"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l963"></a> CleanUp;
<a name="l964"></a> Init;
<a name="l965"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l966"></a>
<a name="l967"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l968"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l969"></a> </span><span class=cF1>goto</span><span class=cF0> nv_done;
<a name="l970"></a>
<a name="l971"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'+'</span><span class=cF0>:
<a name="l972"></a> game_speed *= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l973"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l974"></a>
<a name="l975"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'-'</span><span class=cF0>:
<a name="l976"></a> game_speed /= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>;
<a name="l977"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l978"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l979"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l980"></a>
<a name="l981"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_UP</span><span class=cF0>:
<a name="l982"></a> SquadronSettheta(</span><span class=cFE>0</span><span class=cF0>, arg1, arg2);
<a name="l983"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l984"></a>
<a name="l985"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_UP</span><span class=cF0>:
<a name="l986"></a> SquadronLaunch(</span><span class=cFE>0</span><span class=cF0>, arg1, arg2);
<a name="l987"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l988"></a>
<a name="l989"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_D_UP</span><span class=cF0>:
<a name="l990"></a> SquadronReturn(</span><span class=cFE>0</span><span class=cF0>, arg1, arg2);
<a name="l991"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l992"></a> }
<a name="l993"></a>nv_done:
<a name="l994"></a> </span><span class=cF5>MessageGet</span><span class=cF0>(,, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
<a name="l995"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l996"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l997"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l998"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l999"></a> CleanUp;
<a name="l1000"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l1001"></a>}
<a name="l1002"></a>
<a name="l1003"></a>FlatTops;
<a name="l1004"></a>
<a name="l1005"></a>
<a name="l1006"></a>
<a name="l1007"></a>
<a name="l1008"></a>
<a name="l1009"></a>
<a name="l1010"></a>
<a name="l1011"></a>
<a name="l1012"></a>
<a name="l1013"></a>
<a name="l1014"></a>
<a name="l1015"></a>
<a name="l1016"></a>
<a name="l1017"></a>
<a name="l1018"></a>
<a name="l1019"></a>
<a name="l1020"></a>
<a name="l1021"></a></span><span class=cF2>//Maybe use this in the future</span><span class=cF0> </span><span class=cFA>&lt;7&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l1022"></a>
<a name="l1023"></a>
<a name="l1024"></a>
<a name="l1025"></a>
<a name="l1026"></a>
<a name="l1027"></a>
<a name="l1028"></a>
<a name="l1029"></a>
<a name="l1030"></a>
<a name="l1031"></a>
<a name="l1032"></a>
<a name="l1033"></a>
<a name="l1034"></a>
<a name="l1035"></a>
<a name="l1036"></a>
<a name="l1037"></a>
</span></pre></body>
</html>