2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=US-ASCII" >
2021-12-31 03:21:33 +00:00
< meta name = "generator" content = "ZealOS V1.08" >
2021-07-03 05:07:57 +01:00
< style type = "text/css" >
2021-10-08 07:06:11 +01:00
body {background-color:#1f1f1f;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
2021-07-03 05:07:57 +01:00
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = "font-family:monospace;font-size:12pt" >
2021-07-03 05:07:57 +01:00
< a name = "l1" > < / a > < span class = cF0 > Unit *UnitNearestFind(< / span > < span class = cF9 > I64< / span > < span class = cF0 > row, < / span > < span class = cF9 > I64< / span > < span class = cF0 > col, < / span > < span class = cF9 > I64< / span > < span class = cF0 > player, < / span > < span class = cF1 > Bool< / span > < span class = cF0 > in_LOS, < / span > < span class = cF1 > F64< / span > < span class = cF0 > range=-< / span > < span class = cFE > 1< / span > < span class = cF0 > )
< a name = "l2" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l3" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
< a name = "l4" > < / a > < / span > < span class = cF1 > F64< / span > < span class = cF0 > dd, best_dd = < / span > < span class = cF3 > F64_MAX< / span > < span class = cF0 > , x1, y1, x2, y2;
< a name = "l5" > < / a > Unit *best = < / span > < span class = cF3 > NULL< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l6" > < / a >
2021-07-26 20:29:49 +01:00
< a name = "l7" > < / a > < / span > < span class = cF2 > //< / span > < a href = "https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l84" > < span class = cF4 > Sqrt< / span > < / a > < span class = cF2 > () is slow, so work with squared distances.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l8" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (range < < / span > < span class = cFE > 0< / span > < span class = cF0 > )
< a name = "l9" > < / a > range = < / span > < span class = cF3 > F64_MAX< / span > < span class = cF0 > ;
< a name = "l10" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l11" > < / a > range *= range;
< a name = "l12" > < / a > RowCol2XY(& x1, & y1, row, col);
< a name = "l13" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < UNITS_NUM; i++)
< a name = "l14" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (units[player][i].life > < / span > < span class = cFE > 0< / span > < span class = cF0 > )
< a name = "l15" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l16" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!in_LOS || LOS< / span > < span class = cF7 > (< / span > < span class = cF0 > row, col, units[player][i].row, units[player][i].col< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l17" > < / a > {
< a name = "l18" > < / a > RowCol2XY(& x2, & y2, units[player][i].row, units[player][i].col);
< a name = "l19" > < / a > dd = < / span > < span class = cF5 > Sqr< / span > < span class = cF0 > (x2 - x1) + < / span > < span class = cF5 > Sqr< / span > < span class = cF0 > (y2 - y1);
< a name = "l20" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (dd < = range & & dd < best_dd)
< a name = "l21" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l22" > < / a > best = & units[player][i];
< a name = "l23" > < / a > best_dd = dd;
< a name = "l24" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l25" > < / a > }
< a name = "l26" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l27" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l28" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > best;
2021-07-03 05:07:57 +01:00
< a name = "l29" > < / a > }
< a name = "l30" > < / a >
< a name = "l31" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > PlayerIndirect()
< a name = "l32" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l33" > < / a > Unit *target, *tmpu;
< a name = "l34" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
2021-07-03 05:07:57 +01:00
< a name = "l35" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l36" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < UNITS_NUM; i++)
< a name = "l37" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l38" > < / a > UserCheck;
< a name = "l39" > < / a > tmpu = & units[cur_player][i];
< a name = "l40" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > ( tmpu-> life > < / span > < span class = cFE > 0< / span > < span class = cF0 > & & tmpu-> indirect_fire & &
< a name = "l41" > < / a > < / span > < span class = cF7 > (< / span > < span class = cF0 > target = UnitNearestFind(tmpu-> row, tmpu-> col, enemy_player, < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > , tmpu-> range * < / span > < span class = cFE > 2< / span > < span class = cF0 > * HEX_RADIUS)< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l42" > < / a > IndirectAdd(tmpu, target-> row, target-> col);
< a name = "l43" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l44" > < / 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 > );
2021-07-03 05:07:57 +01:00
< a name = "l45" > < / a > }
< a name = "l46" > < / a >
< a name = "l47" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > PlayerMove()
< a name = "l48" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l49" > < / a > Unit *target, *tmpu;
< a name = "l50" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
< a name = "l51" > < / a > < / span > < span class = cF1 > F64< / span > < span class = cF0 > x, y;
2021-07-03 05:07:57 +01:00
< a name = "l52" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l53" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < UNITS_NUM; i++)
< a name = "l54" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l55" > < / a > UserCheck;
< a name = "l56" > < / a > tmpu = & units[cur_player][i];
< a name = "l57" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tmpu-> life> < / span > < span class = cFE > 0< / span > < span class = cF0 > )
< a name = "l58" > < / a > {
< a name = "l59" > < / a > < / span > < span class = cF2 > //Cheats because it violates Line-of-Sight< / span > < span class = cF0 >
< a name = "l60" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (target = UnitNearestFind< / span > < span class = cF7 > (< / span > < span class = cF0 > tmpu-> row, tmpu-> col, enemy_player, < / span > < span class = cF3 > FALSE< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l61" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l62" > < / a > RowCol2XY(& x, & y, target-> row, target-> col);
< a name = "l63" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!UnitMove< / span > < span class = cF7 > (< / span > < span class = cF0 > tmpu, x, y< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l64" > < / a > {
< a name = "l65" > < / a > RowCol2XY(& x, & y, tmpu-> row, tmpu-> col);
< a name = "l66" > < / a > UnitMove(tmpu, x + < / span > < span class = cF5 > RandI16< / span > < span class = cF0 > , y + < / span > < span class = cF5 > RandI16< / span > < span class = cF0 > );
< a name = "l67" > < / a > }
< a name = "l68" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l69" > < / a > }
< a name = "l70" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l71" > < / 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 > );
2021-07-03 05:07:57 +01:00
< a name = "l72" > < / a > }
< a name = "l73" > < / a >
< a name = "l74" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > PlayerDirect()
< a name = "l75" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l76" > < / a > Unit *target, *tmpu;
< a name = "l77" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
2021-07-03 05:07:57 +01:00
< a name = "l78" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l79" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < UNITS_NUM; i++)
< a name = "l80" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l81" > < / a > UserCheck;
< a name = "l82" > < / a > tmpu = & units[cur_player][i];
< a name = "l83" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tmpu-> life > < / span > < span class = cFE > 0< / span > < span class = cF0 > & & !tmpu-> indirect_fire & &
< a name = "l84" > < / a > < / span > < span class = cF7 > (< / span > < span class = cF0 > target = UnitNearestFind(tmpu-> row, tmpu-> col, enemy_player, < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > , tmpu-> range * < / span > < span class = cFE > 2< / span > < span class = cF0 > * HEX_RADIUS)< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l85" > < / a > {
< a name = "l86" > < / a > UnitDirectFire(tmpu, target);
< a name = "l87" > < / a > < / span > < span class = cF5 > Sleep< / span > < span class = cF0 > (< / span > < span class = cFE > 250< / span > < span class = cF0 > * animation_delay);
< a name = "l88" > < / a > }
< a name = "l89" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l90" > < / 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 > );
2021-07-03 05:07:57 +01:00
< a name = "l91" > < / a > }
< a name = "l92" > < / a >
< / span > < / pre > < / body >
< / html >