X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Fsst.py;h=7ca3fb7b62a7f2aa7513bce1a56f72dd448a26ab;hb=ca9c535343fcd397a088ed2ae758e23254397ca1;hp=d6359835f6a56874a5419a875d0389341807ed80;hpb=aac79eaf17c9b172154a229baade263832e2df13;p=super-star-trek.git diff --git a/src/sst.py b/src/sst.py index d635983..7ca3fb7 100644 --- a/src/sst.py +++ b/src/sst.py @@ -1276,7 +1276,7 @@ def torpedo(origin, bearing, dispersion, number, nburst): # Loop to move a single torpedo setwnd(message_window) for step in range(1, QUADSIZE*2): - track.next() + if not track.next(): break w = track.sector() if not w.valid_sector(): break @@ -1295,14 +1295,11 @@ def torpedo(origin, bearing, dispersion, number, nburst): newcnd(); # we're blown out of dock if game.landed or game.condition=="docked": return hit # Cheat if on a planet - ang = track.angle + 2.5*(randreal()-0.5) - temp = math.fabs(math.sin(ang)) - if math.fabs(math.cos(ang)) > temp: - temp = math.fabs(math.cos(ang)) - xx = -math.sin(ang)/temp - yy = math.cos(ang)/temp - bumpto.i = int(w.i+xx+0.5) - bumpto.j = int(w.j+yy+0.5) + # In the C/FORTRAN version, dispersion was 2.5 radians, which + # is 143 degrees, which is almost exactly 4.8 clockface units + displacement = course(track.bearing+randreal(-2.4,2.4), distance=2**0.5) + displacement.next() + bumpto = displacement.sector() if not bumpto.valid_sector(): return hit if game.quad[bumpto.i][bumpto.j]==IHBLANK: @@ -1343,15 +1340,9 @@ def torpedo(origin, bearing, dispersion, number, nburst): deadkl(w, iquad, w) return None proutn(crmena(True, iquad, "sector", w)) - # If enemy damaged but not destroyed, try to displace - ang = track.angle + 2.5*(randreal()-0.5) - temp = math.fabs(math.sin(ang)) - if math.fabs(math.cos(ang)) > temp: - temp = math.fabs(math.cos(ang)) - xx = -math.sin(ang)/temp - yy = math.cos(ang)/temp - bumpto.i = int(w.i+xx+0.5) - bumpto.j = int(w.j+yy+0.5) + displacement = course(track.bearing+randreal(-2.4,2.4), distance=2**0.5) + displacement.next() + bumpto = displacement.sector() if not bumpto.valid_sector(): prout(_(" damaged but not destroyed.")) return @@ -2449,7 +2440,7 @@ def events(): supercommander() elif evcode == FDSPROB: # Move deep space probe schedule(FDSPROB, 0.01) - if game.probe.next(grain=QUADSIZE): + if not game.probe.next(): if not game.probe.quadrant().valid_quadrant() or \ game.state.galaxy[game.probe.quadrant().i][game.probe.quadrant().j].supernova: # Left galaxy or ran into supernova @@ -3927,17 +3918,13 @@ class course: self.step = 0 def arrived(self): return self.location.roundtogrid() == self.final - def next(self, grain=1): + def next(self): "Next step on course." self.step += 1 self.nextlocation = self.location + self.increment - oldloc = (self.location/grain).roundtogrid() - newloc = (self.nextlocation/grain).roundtogrid() + samequad = (self.location.quadrant() == self.nextlocation.quadrant()) self.location = self.nextlocation - if newloc != oldloc: - return True - else: - return False + return samequad def quadrant(self): return self.location.quadrant() def sector(self): @@ -5158,11 +5145,8 @@ def status(req=0): if not req or req == 2: if game.condition != "docked": newcnd() - dam = 0 - for t in range(NDEVICES): - if game.damage[t]>0: - dam += 1 - prstat(_("Condition"), _("%s, %i DAMAGES") % (game.condition.upper(), dam)) + prstat(_("Condition"), _("%s, %i DAMAGES") % \ + (game.condition.upper(), sum(map(lambda x: x > 0, game.damage)))) if not req or req == 3: prstat(_("Position"), "%s , %s" % (game.quadrant, game.sector)) if not req or req == 4: