Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.05 KB | None | 0 0
  1. def process_missile_event(target, gunner, origin, destination, missile, acrrng, intel, ecm, eccm):
  2.  
  3.     range, orange = 0.0, 0.0
  4.     tecm, tecm, hit, roll, dskill, lskill = 0, 0, 0, 0
  5.  
  6.     # Where is the target now?
  7.     orange = dsDistance(orgin, target.coords())
  8.     range = dsDistance(destination, target.coords())
  9.  
  10.     if _DEBUG_SPACE
  11.         cemit("debug", "Range: %2.2f  acrrng: %2.2f", (range, acrrng))
  12.  
  13.     if orange > missle.maxrange():
  14.         # Missile has expended it's fuel before reaching the target.
  15.         dsNotifyAllShips(target, "Missile %s from %d has missed." % (missile.id, launcher))
  16.         dsNotifyConsoles(launcher, "The missile targeting %s has missed." % target, mode=_CM_HELM)
  17.         dsNotifyOfFire(launcher, target, 10, 50, _WM_MISSILE, 0)
  18.         return
  19.  
  20.     if range > acrrng:
  21.         dsNotifyConsoles(target, "Missile %d from %s has missed." % (missile.id, launcher))
  22.         dsNotifyOfFire(launcher, target, 10, 50, _WM_MISSILE, 0)
  23.         dsNotifyConsoles(launcher, "The missile you launched on %s has missed." % target)
  24.         return
  25.  
  26.     # We might have a hit here!
  27.  
  28.     if target.checkflag("EWON"):
  29.         #launcher vs target.
  30.         tecm = target.helm.ecm
  31.     else:
  32.         tecm = 0
  33.  
  34.     if launcher.checkflag("EWON"):
  35.         teccm = launcher.helm.eccm + eccm
  36.     else:
  37.         teccm = eccm
  38.  
  39.     if _DEBUG_SPACE:
  40.         cemit("debug", "tecm: %d teccm: %d" % (tecm, teccm))
  41.  
  42.     # Give interceptor batteries a chance to take out any incomming missiles/torpedos
  43.     if target.checkflag("INTERON"):
  44.         if handle_interceptor(target, launcher, missile, teccm, tecm, destination):
  45.             return
  46.  
  47.     hit = 50 + teccm - tecm + (intel - 50) + lskill - dskill
  48.     roll = dsRandom() % 100
  49.     roll++
  50.  
  51.     if _DEBUG_SPACE
  52.         cemit("debug", "hit: %d roll: %d" % (hit, roll))
  53.  
  54.     if roll < hit:
  55.         # a hit!
  56.         if (!target.checkflag("DEAD"):
  57.             dsNotifyAllShips(target,  "Missile %d from %s has hit %s.", (missile.id, launcher, target))
  58.             dsNotifyConsoles(launcher, "The missile you launched on %d has hit." % target, mode=_CM_HELM)
  59.  
  60.             dsShipNotifyOfFire(launcher, target, 10, 50, _WM_MISSILE, 1)
  61.             if (missile.checkflag("STASIS"):
  62.                 target.take_damage(missle.damage, 2, dsGetArc(launcher, target))
  63.             else:
  64.                 target.take_damage(missle.damage, 1, dsGetArc(launcher, target))
  65.             if (missile.checkflag("AOE"):
  66.                 target.take_aoe_damage(missile)
  67.         else:
  68.             dsNotifyConsoles(launcher, "The ship your missle was targetting has been destroyed.", mode=_CM_HELM)
  69.    else:
  70.        if !target.checkflag("DEAD"):
  71.            dsNotifyConsoles(target, "Missle from %d has missed." % launcher)
  72.            dsShipNotifyOfFire(launcher, target, 10, 50, _WM_MISSILE, 0)
  73.            dsNotifyConsoles(launcher, "The missile you launched on %s has missed." % target, mode=_CM_HELM)
  74.        else:
  75.            dsNotifyConsoles(launcher, "The ship your missle was targetting has been destroyed.", mode=_CM_HELM)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement