- game.quad[game.sector.x][game.sector.y] = IHDOT
- x = game.sector.x
- y = game.sector.y
- n = int(10.0*game.dist*bigger+0.5)
- if n > 0:
- for m in range(1, n+1):
- x += deltax
- y += deltay
- w.x = int(round(x))
- w.y = int(round(y))
- if not VALID_SECTOR(w.x, w.y):
- # Leaving quadrant -- allow final enemy attack
- # Don't do it if being pushed by Nova
- if len(game.enemies) != 0 and not novapush:
- newcnd()
- for enemy in game.enemies:
- finald = (w - enemy.kloc).distance()
- enemy.kavgd = 0.5 * (finald + enemy.kdist)
- #
- # Stas Sergeev added the condition
- # that attacks only happen if Klingons
- # are present and your skill is good.
- #
- if game.skill > SKILL_GOOD and game.klhere > 0 and not game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova:
- attack(torps_ok=False)
- if game.alldone:
- return
- # compute final position -- new quadrant and sector
- x = (QUADSIZE*game.quadrant.x)+game.sector.x
- y = (QUADSIZE*game.quadrant.y)+game.sector.y
- w.x = int(round(x+10.0*game.dist*bigger*deltax))
- w.y = int(round(y+10.0*game.dist*bigger*deltay))
- # check for edge of galaxy
- kinks = 0
- while True:
- kink = False
- if w.x < 0:
- w.x = -w.x
- kink = True
- if w.y < 0:
- w.y = -w.y
- kink = True
- if w.x >= GALSIZE*QUADSIZE:
- w.x = (GALSIZE*QUADSIZE*2) - w.x
- kink = True
- if w.y >= GALSIZE*QUADSIZE:
- w.y = (GALSIZE*QUADSIZE*2) - w.y
- kink = True
- if kink:
- kinks += 1
- else:
+ game.quad[game.sector.i][game.sector.j] = IHDOT
+ x = game.sector.i
+ y = game.sector.j
+ for m in range(course.moves):
+ x += deltax
+ y += deltay
+ w.i = int(round(x))
+ w.j = int(round(y))
+ if not w.valid_sector():
+ # Leaving quadrant -- allow final enemy attack
+ # Don't do it if being pushed by Nova
+ if len(game.enemies) != 0 and not novapush:
+ newcnd()
+ for enemy in game.enemies:
+ finald = (w - enemy.kloc).distance()
+ enemy.kavgd = 0.5 * (finald + enemy.kdist)
+ #
+ # Stas Sergeev added the condition
+ # that attacks only happen if Klingons
+ # are present and your skill is good.
+ #
+ if game.skill > SKILL_GOOD and game.klhere > 0 and not game.state.galaxy[game.quadrant.i][game.quadrant.j].supernova:
+ attack(torps_ok=False)
+ if game.alldone:
+ return
+ # compute final position -- new quadrant and sector
+ x = (QUADSIZE*game.quadrant.i)+game.sector.i
+ y = (QUADSIZE*game.quadrant.j)+game.sector.j
+ w.i = int(round(x+QUADSIZE*course.distance*bigger*deltax))
+ w.j = int(round(y+QUADSIZE*course.distance*bigger*deltay))
+ # check for edge of galaxy
+ kinks = 0
+ while True:
+ kink = False
+ if w.i < 0:
+ w.i = -w.i
+ kink = True
+ if w.j < 0:
+ w.j = -w.j
+ kink = True
+ if w.i >= GALSIZE*QUADSIZE:
+ w.i = (GALSIZE*QUADSIZE*2) - w.i
+ kink = True
+ if w.j >= GALSIZE*QUADSIZE:
+ w.j = (GALSIZE*QUADSIZE*2) - w.j
+ kink = True
+ if kink:
+ kinks += 1
+ else:
+ break
+ if kinks:
+ game.nkinks += 1
+ if game.nkinks == 3:
+ # Three strikes -- you're out!
+ finish(FNEG3)
+ return
+ skip(1)
+ prout(_("YOU HAVE ATTEMPTED TO CROSS THE NEGATIVE ENERGY BARRIER"))
+ prout(_("AT THE EDGE OF THE GALAXY. THE THIRD TIME YOU TRY THIS,"))
+ prout(_("YOU WILL BE DESTROYED."))
+ # Compute final position in new quadrant
+ if trbeam: # Don't bother if we are to be beamed
+ return
+ game.quadrant.i = w.i/QUADSIZE
+ game.quadrant.j = w.j/QUADSIZE
+ game.sector.i = w.i - (QUADSIZE*game.quadrant.i)
+ game.sector.j = w.j - (QUADSIZE*game.quadrant.j)
+ skip(1)
+ prout(_("Entering Quadrant %s.") % game.quadrant)
+ game.quad[game.sector.i][game.sector.j] = game.ship
+ newqad()
+ if game.skill>SKILL_NOVICE:
+ attack(torps_ok=False)
+ return
+ iquad = game.quad[w.i][w.j]
+ if iquad != IHDOT:
+ # object encountered in flight path
+ stopegy = 50.0*course.dist/game.optime
+ course.distance = (game.sector - w).distance() / (QUADSIZE * 1.0)
+ if iquad in (IHT, IHK, IHC, IHS, IHR, IHQUEST):
+ game.sector = w
+ for enemy in game.enemies:
+ if enemy.kloc == game.sector: