extern void object::Attack( ) { object p; float dist, prox; point nav1, nav2, dest; boolean advance = true; wait(5); while ( true ) { p = radar(WheeledShooter); if ( p == null ) { nav1.x = position.x-5; nav1.y = position.y; nav2.x = position.x+5; nav2.y = position.y; while ( true ) { goto(nav1); p = radar(WheeledShooter); if ( p != null ) break; goto(nav2); p = radar(WheeledShooter); if ( p != null ) break; } } else { dist = distance(p.position, position); if ( dist <= 25 && !advance ) { fire(p.position); advance = true; wait(2); } else { prox = dist-5; if ( prox > 25 ) prox = 25; if ( prox < 15 ) prox = 15; dest.x = (position.x-p.position.x)*prox/dist + p.position.x; dest.y = (position.y-p.position.y)*prox/dist + p.position.y; dest.z = (position.z-p.position.z)*prox/dist + p.position.z; goto(dest); advance = false; } } } }