+ // auto always shoots in Tux's direction
+ if( autotarget ){
+ if( sprite->animation_done()) {
+ sprite->set_action(dir == LEFT ? "working-left" : "working-right");
+ swivel = false;
+ }
+
+ Player* player = this->get_nearest_player();
+ if( player && !swivel ){
+ Direction targetdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
+ if( dir != targetdir ){ // no target: swivel cannon
+ swivel = true;
+ dir = targetdir;
+ sprite->set_action(dir == LEFT ? "swivel-left" : "swivel-right", 1);
+ } else { // tux in sight: shoot
+ launch_badguy();
+ }
+ }
+ } else {
+ launch_badguy();
+ }