def Check(self):
     dead=not self.un
     if (not dead):
         dead = self.un.GetHull()<=0
     if (dead):
         debug.debug("Uunit died")
         if (VS.systemInMemory (self.starsystem)):
             if fg_util.RemoveShipFromFG(self.fgname,self.faction,self.type)!=0:
               if (VS.getPlayerX(0)):
                   debug.debug('unit died for real')
                   if (VS.GetRelation(self.faction,VS.getPlayerX(0).getFactionName())>0):
                       dynamic_battle.rescuelist[self.starsystem]=(self.faction,"Shadow",faction_ships.get_enemy_of(self.faction))
                       debug.debug("friend in trouble")
               global dnewsman_
               numships = updatePlayerKillList(0,self.faction)
               debug.debug("num ships killed ")
               debug.debug(numships)
               if ((numships>0 and VS.getPlayer()) or fg_util.NumShipsInFG(self.fgname,self.faction)==0): #generate news here fg killed IRL
                   varList=[str(Director.getSaveData(0,"stardate",0)),dnewsman_.TYPE_DESTROYED,dnewsman_.STAGE_END,"unknown",self.faction,dnewsman_.SUCCESS_WIN,str(dynamic_battle.getImportanceOfType(self.type)),self.starsystem,dnewsman_.KEYWORD_DEFAULT,"unknown","unknown",self.fgname,self.type]
                   if (numships>0 and VS.getPlayer()):
                       varList=[str(Director.getSaveData(0,"stardate",0)),dnewsman_.TYPE_DESTROYED,dnewsman_.STAGE_END,VS.getPlayer().getFactionName(),self.faction,dnewsman_.SUCCESS_WIN,str(dynamic_battle.getImportanceOfType(self.type)),self.starsystem,dnewsman_.KEYWORD_DEFAULT,VS.getPlayer().getFlightgroupName(),VS.getPlayer().getName(),self.fgname,self.type]
                   dnewsman_.writeDynamicString(varList)
                   debug.debug('news about unit dying')
         else:
             fg_util.LandShip(self.fgname,self.faction,self.type)
         return 0
     else:
         sys=self.un.getUnitSystemFile()
         if (len(sys)):
             self.starsystem=sys
     return 1
Esempio n. 2
0
def KillOne (fg,fac,tn,num,enfg,enfac):
    sys = fg_util.FGSystem(fg,fac)
    numkilled= fg_util.RemoveShipFromFG(fg,fac,tn[0],num,1)
    chancetoeject=.25
    global ejectbuildup
    if (ejectbuildup>=(1-chancetoeject)**numkilled):
        global rescuelist
        rescuelist[sys]=(fac,enfg,enfac)
        #debug.debug(rescuelist[sys])
        ejectbuildup=0
    else:
        ejectbuildup+=chancetoeject
    return numkilled