| 86 | | // TODO maxcount wird beim Flug durch EMP-Nebel falsch interpretiert |
|---|
| 87 | | |
|---|
| 88 | | int oldMaxCount = maxcount; |
|---|
| 89 | | Ship.MovementStatus result = Ship.MovementStatus.SUCCESS; |
|---|
| 90 | | |
|---|
| 91 | | while( true ) { |
|---|
| 92 | | int deltax = target.getX()-ship.getX(); |
|---|
| 93 | | int deltay = target.getY()-ship.getY(); |
|---|
| 94 | | |
|---|
| 95 | | if( (deltax == 0) && (deltay == 0) ) { |
|---|
| 96 | | scriptparser.log("Zielposition bereits erreicht!\n\n"); |
|---|
| 97 | | return CONTINUE; |
|---|
| 98 | | } |
|---|
| 99 | | |
|---|
| 100 | | if( ship.getHeat() > 100 ) { |
|---|
| 101 | | scriptparser.log("Ausfuehrung bis zum naechsten Tick angehalten\n\n"); |
|---|
| 102 | | return STOP; |
|---|
| 103 | | } |
|---|
| 104 | | |
|---|
| 105 | | RouteFactory router = new RouteFactory(); |
|---|
| 106 | | List<Waypoint> route = router.findRoute(ship.getLocation(), target, maxcount); |
|---|
| 107 | | |
|---|
| 108 | | result = ship.move(route, true, false); |
|---|
| 109 | | scriptparser.log(Common._stripHTML(Ship.MESSAGE.getMessage())); |
|---|
| 110 | | scriptparser.setShip(ship); |
|---|
| 111 | | |
|---|
| 112 | | if( result == Ship.MovementStatus.BLOCKED_BY_EMP ) { |
|---|
| 113 | | maxcount = 1; |
|---|
| 114 | | continue; |
|---|
| 115 | | } |
|---|
| 116 | | else if( result != Ship.MovementStatus.SUCCESS ) { |
|---|
| 117 | | scriptparser.log("Ausfuehrung bis zum naechsten Tick angehalten\n\n"); |
|---|
| 118 | | return STOP; |
|---|
| 119 | | } |
|---|
| 120 | | // Nach einem Flug durch einen EMP-Nebel den Flug normal weiterfuehren |
|---|
| 121 | | else if( oldMaxCount != maxcount ) { |
|---|
| 122 | | maxcount = oldMaxCount; |
|---|
| 123 | | |
|---|
| 124 | | continue; |
|---|
| 125 | | } |
|---|
| 126 | | else { |
|---|
| 127 | | break; |
|---|
| 128 | | } |
|---|
| 129 | | } |
|---|
| 130 | | |
|---|
| 131 | | if( !ship.getLocation().equals(target) ) { |
|---|
| 132 | | scriptparser.log("Position nicht korrekt - Ausfuehrung bis zum naechsten Tick angehalten\n\n"); |
|---|
| 133 | | return STOP; |
|---|
| 134 | | } |
|---|
| | 85 | if( !ShipUtils.move(ship, target, maxcount) ) { |
|---|
| | 86 | scriptparser.log(ShipUtils.MESSAGE.getMessage()); |
|---|
| | 87 | return STOP; |
|---|
| | 88 | } |
|---|
| | 89 | |
|---|
| | 90 | scriptparser.log(ShipUtils.MESSAGE.getMessage()); |
|---|