templeos-info/public/Wb/Apps/ToTheFront/AIs/Human.HC.HTML

198 lines
18 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> PlayerIndirect()
<a name="l2"></a>{
<a name="l3"></a> Unit *tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l4"></a> </span><span class=cF9>I64</span><span class=cF0> i,remaining=0,msg_code,arg1,arg2;
<a name="l5"></a> </span><span class=cF1>F64</span><span class=cF0> target_x,target_y;
<a name="l6"></a> ViewPlayerSet(cur_player);
<a name="l7"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;UNITS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l8"></a> tmpu=&amp;units[cur_player][i];
<a name="l9"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu-&gt;life&gt;0 &amp;&amp; tmpu-&gt;indirect_fire)
<a name="l10"></a> remaining++;
<a name="l11"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l12"></a> </span><span class=cF1>while</span><span class=cF0> (remaining) </span><span class=cF7>{</span><span class=cF0>
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (!alive_cnt[0] || !alive_cnt[1])
<a name="l14"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'GameOver'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l15"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&amp;arg1,&amp;arg2,1&lt;&lt;</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>|
<a name="l16"></a> 1&lt;&lt;</span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>);
<a name="l17"></a> </span><span class=cF1>switch</span><span class=cF0> (msg_code) {
<a name="l18"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l19"></a> CharDo(arg1);
<a name="l20"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l21"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l23"></a> arg1-=x0; arg2-=y0;
<a name="l24"></a> CursorUpdate(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2);
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu=UnitFind</span><span class=cF7>(</span><span class=cF0>cursor_row,cursor_col</span><span class=cF7>)</span><span class=cF0>) {
<a name="l26"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu-&gt;player==enemy_player || tmpu-&gt;fired ||
<a name="l27"></a> !tmpu-&gt;indirect_fire)
<a name="l28"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l29"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l30"></a> RowCol2XY(&amp;fire_radius_x,&amp;fire_radius_y,tmpu-&gt;row,tmpu-&gt;col);
<a name="l31"></a> fire_radius=tmpu-&gt;range*2*HEX_RADIUS;
<a name="l32"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l33"></a> }
<a name="l34"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l35"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l36"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>:
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l38"></a> arg1-=x0; arg2-=y0;
<a name="l39"></a> CursorUpdate(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2);
<a name="l40"></a> RowCol2XY(&amp;target_x,&amp;target_y,cursor_row,cursor_col);
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpu)
<a name="l42"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l43"></a> </span><span class=cF1>else</span><span class=cF0> {
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF5>Sqr</span><span class=cF0>(fire_radius_x-target_x)+</span><span class=cF5>Sqr</span><span class=cF0>(fire_radius_y-target_y)</span><span class=cF7>)</span><span class=cF0>&gt;
<a name="l45"></a> fire_radius)
<a name="l46"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l47"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l48"></a> IndirectAdd(tmpu,cursor_row,cursor_col);
<a name="l49"></a> remaining--;
<a name="l50"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l51"></a> }
<a name="l52"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l53"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l54"></a> fire_radius=0;
<a name="l55"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l56"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>:
<a name="l57"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>)
<a name="l58"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'PhaseOvr'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l59"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l60"></a> }
<a name="l61"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l62"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'PhaseOvr'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l63"></a>}
<a name="l64"></a>
<a name="l65"></a></span><span class=cF1>U0</span><span class=cF0> PlayerMove()
<a name="l66"></a>{
<a name="l67"></a> Unit *tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l68"></a> </span><span class=cF9>I64</span><span class=cF0> msg_code,arg1,arg2;
<a name="l69"></a> ViewPlayerSet(cur_player);
<a name="l70"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l71"></a> </span><span class=cF1>if</span><span class=cF0> (!alive_cnt[0] || !alive_cnt[1])
<a name="l72"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'GameOver'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l73"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&amp;arg1,&amp;arg2,1&lt;&lt;</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>|
<a name="l74"></a> 1&lt;&lt;</span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>);
<a name="l75"></a> </span><span class=cF1>switch</span><span class=cF0> (msg_code) {
<a name="l76"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l77"></a> CharDo(arg1);
<a name="l78"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
<a name="l80"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l81"></a> arg1-=x0; arg2-=y0;
<a name="l82"></a> CursorUpdate(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2);
<a name="l83"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu=UnitFind</span><span class=cF7>(</span><span class=cF0>cursor_row,cursor_col</span><span class=cF7>)</span><span class=cF0>) {
<a name="l84"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu-&gt;player==enemy_player || !tmpu-&gt;remaining_movement)
<a name="l85"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l86"></a> }
<a name="l87"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l88"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l89"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>:
<a name="l90"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l91"></a> arg1-=x0; arg2-=y0;
<a name="l92"></a> CursorUpdate(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2);
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpu)
<a name="l94"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l95"></a> </span><span class=cF1>else</span><span class=cF0> {
<a name="l96"></a> UnitMove(tmpu,arg1,arg2);
<a name="l97"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l98"></a> }
<a name="l99"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l100"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l101"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l102"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>:
<a name="l103"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>)
<a name="l104"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'PhaseOvr'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l105"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l106"></a> }
<a name="l107"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l108"></a>}
<a name="l109"></a>
<a name="l110"></a></span><span class=cF1>U0</span><span class=cF0> PlayerDirect()
<a name="l111"></a>{
<a name="l112"></a> Unit *tmpu=</span><span class=cF3>NULL</span><span class=cF0>,*target;
<a name="l113"></a> </span><span class=cF9>I64</span><span class=cF0> msg_code,arg1,arg2;
<a name="l114"></a> ViewPlayerSet(cur_player);
<a name="l115"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l116"></a> </span><span class=cF1>if</span><span class=cF0> (!alive_cnt[0] || !alive_cnt[1])
<a name="l117"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'GameOver'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l118"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&amp;arg1,&amp;arg2,1&lt;&lt;</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>|
<a name="l119"></a> 1&lt;&lt;</span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>);
<a name="l120"></a> </span><span class=cF1>switch</span><span class=cF0> (msg_code) {
<a name="l121"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l122"></a> CharDo(arg1);
<a name="l123"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l124"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
<a name="l125"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l126"></a> arg1-=x0; arg2-=y0;
<a name="l127"></a> CursorUpdate(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2);
<a name="l128"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu=UnitFind</span><span class=cF7>(</span><span class=cF0>cursor_row,cursor_col</span><span class=cF7>)</span><span class=cF0>) {
<a name="l129"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu-&gt;player==enemy_player || tmpu-&gt;fired ||
<a name="l130"></a> tmpu-&gt;indirect_fire)
<a name="l131"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l132"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l133"></a> VRSetUp(cur_player);
<a name="l134"></a> RowCol2XY(&amp;fire_radius_x,&amp;fire_radius_y,tmpu-&gt;row,tmpu-&gt;col);
<a name="l135"></a> fire_radius=tmpu-&gt;range*2*HEX_RADIUS;
<a name="l136"></a> VisRecalc(VR_ONE_FRIENDLY_UNIT,tmpu);
<a name="l137"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l138"></a> }
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l140"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l141"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>:
<a name="l142"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l143"></a> arg1-=x0; arg2-=y0;
<a name="l144"></a> CursorUpdate(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2);
<a name="l145"></a> target=UnitFind(cursor_row,cursor_col);
<a name="l146"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpu)
<a name="l147"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l148"></a> </span><span class=cF1>else</span><span class=cF0> {
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (!target || target-&gt;player!=enemy_player ||
<a name="l150"></a> !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;target-&gt;vis,0</span><span class=cF7>)</span><span class=cF0>)
<a name="l151"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l152"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l153"></a> UnitDirectFire(tmpu,target);
<a name="l154"></a> VisRecalc(VR_UPDATE_FRIENDLY_UNIT,tmpu);
<a name="l155"></a> }
<a name="l156"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l157"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l158"></a> fire_radius=0;
<a name="l159"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l160"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_UP</span><span class=cF0>:
<a name="l161"></a> </span><span class=cF1>if</span><span class=cF0> (CursorInWin</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>,arg1,arg2</span><span class=cF7>)</span><span class=cF0>)
<a name="l162"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'PhaseOvr'</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l163"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l164"></a> }
<a name="l165"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l166"></a>}
</span></pre></body>
</html>