Ejemplo n.º 1
0
 def __init__(self,
              factionname,
              numsystemsaway,
              enemyquantity,
              distance_from_base,
              escape_distance,
              creds,
              defendthis,
              defend_base,
              protectivefactionname='',
              jumps=(),
              var_to_set='',
              dynamic_flightgroup='',
              dynamic_type='',
              dynamic_defend_fg='',
              waves=0,
              greetingText=[
                  'We will defeat your assets in this battle, privateer...',
                  'Have no doubt!'
              ]):
     Director.Mission.__init__(self)
     self.dedicatedattack = vsrandom.randrange(0, 2)
     self.arrived = 0
     self.waves = waves
     self.greetingText = greetingText
     self.protectivefaction = protectivefactionname
     self.var_to_set = var_to_set
     self.quantity = 0
     self.mplay = "all"
     self.defendbase = defend_base
     self.dynatkfg = dynamic_flightgroup
     self.dynatktype = dynamic_type
     self.dyndeffg = dynamic_defend_fg
     self.attackers = []
     self.objective = 0
     self.targetiter = 0
     self.ship_check_count = 0
     self.defend = defendthis
     self.defend_base = defend_base
     self.faction = factionname
     self.escdist = escape_distance
     minsigdist = unit.minimumSigDistApart()
     if (minsigdist * .5 < self.escdist):
         self.escdist = minsigdist
     self.cred = creds
     self.respawn = 0
     self.quantity = enemyquantity
     self.savedquantity = enemyquantity
     self.distance_from_base = distance_from_base
     self.defendee = VS.Unit()
     self.difficulty = 1
     self.you = VS.getPlayer()
     name = self.you.getName()
     self.mplay = universe.getMessagePlayer(self.you)
     self.adjsys = go_to_adjacent_systems(self.you, numsystemsaway, jumps)
     self.adjsys.Print("You are in the %s system,",
                       "Proceed swiftly to %s.",
                       "Your arrival point is %s.", "defend", 1)
     VS.IOmessage(2, "defend", self.mplay,
                  "And there eliminate any %s starships." % self.faction)
Ejemplo n.º 2
0
 def __init__(self,
              numsystemsaway,
              num_significants_to_patrol,
              scan_object_distance,
              creds,
              jumps=(),
              donevar='',
              scan_objects=None):
     Director.Mission.__init__(self)
     if scan_objects is None or type(scan_objects) != dict or len(
             scan_objects) == 0:
         scan_objects = None
     else:
         scan_objects.setdefault("exceptall", [])
         scan_objects.setdefault("except", [])
         scan_objects.setdefault("addall", [])
         scan_objects.setdefault("add", [])
     self.scan_objects = scan_objects  #If not None, do not randomly select significants, instead select them from this dictionary.
     self.donevar = donevar
     self.jnum = 0
     self.cred = creds
     self.patrolpoints = []
     self.objectives = []
     self.distance = scan_object_distance
     self.you = VS.getPlayer()
     self.quantity = num_significants_to_patrol
     name = self.you.getName()
     self.mplay = universe.getMessagePlayer(self.you)
     VS.IOmessage(0, "patrol", self.mplay,
                  "Greetings, %s. You must patrol a system for us :" % name)
     self.adjsys = go_to_adjacent_systems(self.you, numsystemsaway, jumps)
     self.adjsys.Print("From the %s system,", "Carefully go to %s.",
                       "You should shortly arrive in the %s: patrol it.",
                       "patrol", 1)
Ejemplo n.º 3
0
 def dir_privateSetupPlayer(self,cp):
     print("setting up mission")
     print(self.jumps)
     self.arrived=0
     self.wasnull=0
     self.you=VS.getPlayerX(cp)
     self.adjsys=go_to_adjacent_systems(self.you,0,self.jumps)
     self.adjsys.Print("You should start in the system named %s","Then jump to %s","Lastly, jump to %s, your final destination","cargo mission",1)
Ejemplo n.º 4
0
 def dir_privateSetupPlayer(self, cp):
     print("setting up mission")
     print(self.jumps)
     self.arrived = 0
     self.wasnull = 0
     self.you = VS.getPlayerX(cp)
     self.adjsys = go_to_adjacent_systems(self.you, 0, self.jumps)
     self.adjsys.Print("You should start in the system named %s",
                       "Then jump to %s",
                       "Lastly, jump to %s, your final destination",
                       "cargo mission", 1)
Ejemplo n.º 5
0
 def __init__ (self, factionname, missiondifficulty, our_dist_from_jump, dist_from_jump, distance_from_base, creds, enemy_time, numsysaway, jumps=(), var_to_set='', fgname='', dyntype=''):
     Director.Mission.__init__(self);
     self.you = VS.getPlayer();
     self.role= "ESCORTCAP"
     self.gametime=VS.GetGameTime()
     self.adjsys=go_to_adjacent_systems(self.you, numsysaway,jumps)
     self.var_to_set = var_to_set;
     debug.debug("e")
     self.adjsys.Print("You should start in the system named %s","Then jump to %s","Finally, jump to %s, your final destination","escort mission",1)
     debug.debug("f")
     self.distfrombase=distance_from_base
     debug.debug("g")
     self.faction=factionname
     global escort_num
     escort_num+=1
     #self.escortee = launch.launch_wave_around_unit("Escort"+str(escort_num),
     #                                              self.faction,
     #                                              faction_ships.getRandomFighter("merchant"),
     #                                              "default",
     #                                              1,
     #                                              self.you.rSize(),
     #                                              2.0*self.you.rSize(),
     #                                              self.you,
     #                                              "")
     L=launch.Launch()
     if fgname == "":
         L.fg = "Escort"
         L.fgappend = "_"+str(escort_num)
     else:
         L.fg = fgname
         L.fgappend = ""
         L.faction=self.faction
         if (dyntype==''):
             L.type = faction_ships.getRandomFighter("merchant")
         else:
             L.type = dyntype
             L.forcetype=True
         L.dynfg = ""
         L.ai = "default"
         L.num=1
         L.minradius = 2.0*self.you.rSize()
         L.maxradius = 3.0*self.you.rSize()
         self.escortee=L.launch(self.you)
         self.escortee.upgrade("jump_drive",0,0,0,1)
         self.you.SetTarget(self.escortee)
         debug.debug("h")
         self.escortee.setFlightgroupLeader(self.you)
         debug.debug("dd")
         self.difficulty=missiondifficulty
         self.creds = creds
Ejemplo n.º 6
0
 def __init__ (self,numsystemsaway, num_significants_to_patrol, distance_from_base, creds, jumps=(), donevar=''):
     Director.Mission.__init__(self)
     self.donevar=donevar
     self.jnum=0
     self.cred=creds
     self.patrolpoints = []
     self.objectives = []
     self.distance = distance_from_base
     self.you = VS.getPlayer()
     self.quantity=num_significants_to_patrol
     name = self.you.getName ()
     self.mplay=universe.getMessagePlayer(self.you)
     VS.IOmessage (0,"patrol",self.mplay,"You must patrol a system for us :")
     self.adjsys = go_to_adjacent_systems(self.you,numsystemsaway,jumps)
     self.adjsys.Print("From the %s system,","Carefully go to %s.","You should shortly arrive in the %s: patrol it.","patrol",1)
Ejemplo n.º 7
0
 def __init__ (self,factionname,numsystemsaway, enemyquantity, distance_from_base, escape_distance, creds, defendthis, defend_base,protectivefactionname='',jumps=(),var_to_set='',dynamic_flightgroup='',dynamic_type='', dynamic_defend_fg='',waves=0, greetingText=['We will defeat your assets in this battle, privateer...','Have no doubt!']):
     Director.Mission.__init__(self)
     self.dedicatedattack=vsrandom.randrange(0,2)
     self.arrived=0
     self.waves=waves;
     self.greetingText=greetingText
     self.protectivefaction = protectivefactionname
     self.var_to_set=var_to_set
     self.quantity=0
     self.mplay="all"
     self.defendbase = defend_base   
     self.dynatkfg = dynamic_flightgroup     
     self.dynatktype = dynamic_type
     self.dyndeffg = dynamic_defend_fg
     self.attackers = []
     self.objective= 0
     self.targetiter = 0
     self.ship_check_count=0
     self.defend = defendthis
     self.defend_base = defend_base
     self.faction = factionname
     self.escdist = escape_distance
     minsigdist=unit.minimumSigDistApart()
     if (minsigdist*.5<self.escdist):
         self.escdist = minsigdist
     self.cred=creds
     self.respawn=0
     self.quantity=enemyquantity
     self.savedquantity=enemyquantity
     self.distance_from_base=distance_from_base
     self.defendee=VS.Unit()
     self.difficulty=1
     self.you=VS.getPlayer()
     self.younum=VS.getCurrentPlayer()
     name = self.you.getName ()
     self.mplay=universe.getMessagePlayer(self.you)
     self.adjsys = go_to_adjacent_systems(self.you,numsystemsaway,jumps)  
     self.adjsys.Print("You are in the %s system,","Proceed swiftly to %s.","Your arrival point is %s.","defend",1)
     VS.IOmessage (2,"defend",self.mplay,"And there eliminate any %s starships."  % self.faction)
     self.key=str(VS.getCurrentPlayer())+str(factionname)+str(numsystemsaway)+str(enemyquantity)+str(distance_from_base)+str(escape_distance)+str(creds)+str(defendthis)+str(defend_base)+str(protectivefactionname)+str(jumps)+str(var_to_set)+str(dynamic_flightgroup)+str(dynamic_type)+str(dynamic_defend_fg)+str(waves)+str(greetingText);
     global running_defend_missions
     running_defend_missions[self.key]=0
     self.run_def_mis=0
Ejemplo n.º 8
0
 def __init__(self, factionname, numsystemsaway, enemyquantity,  waves, distance_from_base, creds, incoming, protectivefactionname='', jumps=(), var_to_set='', dynamic_attack_fg='', dynamic_type='', dynamic_defend_fg='', dynamic_defend_type='', greetingText=['Escort: give up while you still can...', 'If you let us ravage our target then we grant you passage today.']):
     Director.Mission.__init__(self)
     self.greetingText = greetingText
     self.dedicatedattack = vsrandom.randrange(0, 2)*vsrandom.randrange(0, 2)
     if (VS.GetRelation(factionname, protectivefactionname) >= 0.0):
         self.dedicatedattack = 1
     self.arrived = 0
     self.launchedfriend = 0
     self.protectivefaction = protectivefactionname
     self.var_to_set = var_to_set
     self.quantity = 0
     self.mplay = "all"
     self.gametime = VS.GetGameTime()
     self.waves = waves
     self.incoming = incoming
     self.dynatkfg = dynamic_attack_fg
     self.dynatktype = dynamic_type
     self.dyndeffg = dynamic_defend_fg
     self.dyndeftype = dynamic_defend_type
     self.attackers = []
     self.objective = 0
     self.targetiter = 0
     self.ship_check_count = 0
     self.faction = factionname
     self.jp = VS.Unit()
     self.cred = creds
     self.quantity = enemyquantity
     self.savedquantity = enemyquantity
     self.distance_from_base = distance_from_base
     self.defendee = VS.Unit()
     self.difficulty = 1
     self.you = VS.getPlayer()
     self.respawn = 0
     name = self.you.getName()
     self.successdelay = 0
     self.mplay = universe.getMessagePlayer(self.you)
     self.adjsys = go_to_adjacent_systems(self.you, numsystemsaway, jumps)
     VS.IOmessage(0, "escort mission", self.mplay, 
                 "Good Day, %s. Your mission is as follows:" % name)
     self.adjsys.Print("You are in the %s system,", 
                     "Proceed swiftly to %s.", 
                     "Your arrival point is %s.", 
                     "escort mission", 1)
Ejemplo n.º 9
0
 def __init__ (self,factionname,numsystemsaway, enemyquantity,  waves, distance_from_base, creds, incoming, protectivefactionname='',jumps=(),var_to_set='',dynamic_flightgroup='',dynamic_type='', dynamic_defend_fg='',dynamic_defend_type='',greetingText=['Escort: give up while you still can...','If you let us ravage our target then we grant you passage today.']):
     Director.Mission.__init__(self)
     self.greetingText=greetingText
     self.dedicatedattack=vsrandom.randrange(0,2)*vsrandom.randrange(0,2)
     if (VS.GetRelation(factionname,protectivefactionname)>=0.0):
         self.dedicatedattack=1
     self.arrived=0
     self.todock=VS.Unit()
     self.launchedfriend=0
     self.protectivefaction = protectivefactionname
     self.var_to_set=var_to_set
     self.quantity=0
     self.mplay="all"
     self.gametime=VS.GetGameTime()
     self.waves=waves
     self.incoming=incoming
     self.dynatkfg = dynamic_flightgroup
     self.dynatktype = dynamic_type
     self.dyndeffg = dynamic_defend_fg
     self.dyndeftype = dynamic_defend_type
     self.attackers = []
     self.objective= 0
     self.targetiter = 0
     self.ship_check_count=0
     self.faction = factionname
     self.jp=VS.Unit()
     self.cred=creds
     self.quantity=enemyquantity
     self.savedquantity=enemyquantity
     self.distance_from_base=distance_from_base
     self.defendee=VS.Unit()
     self.difficulty=1
     self.you=VS.getPlayer()
     self.respawn=0
     name = self.you.getName ()
     self.successdelay=0
     self.objectivezero=0
     self.mplay=universe.getMessagePlayer(self.you)
     self.adjsys = go_to_adjacent_systems(self.you,numsystemsaway,jumps)
     VS.IOmessage (0,"escort mission",self.mplay,"Your mission is as follows:")
     self.adjsys.Print("You are in the %s system,","Proceed swiftly to %s.","Your arrival point is %s.","escort mission",1)
Ejemplo n.º 10
0
 def __init__ (self, numsystemsaway, num_significants_to_patrol, scan_object_distance, creds, jumps=(), donevar='', scan_objects=None):
     Director.Mission.__init__(self)
     if scan_objects is None or type(scan_objects) != dict or len(scan_objects) == 0:
         scan_objects = None
     else:
         scan_objects.setdefault("exceptall", [])
         scan_objects.setdefault("except", [])
         scan_objects.setdefault("addall", [])
         scan_objects.setdefault("add", [])
     self.scan_objects = scan_objects #If not None, do not randomly select significants, instead select them from this dictionary.
     self.donevar=donevar
     self.jnum=0
     self.cred=creds
     self.patrolpoints = []
     self.objectives = []
     self.distance = scan_object_distance
     self.you = VS.getPlayer()
     self.quantity=num_significants_to_patrol
     name = self.you.getName ()
     self.mplay=universe.getMessagePlayer(self.you)
     VS.IOmessage (0,"patrol",self.mplay,"Greetings, %s. You must patrol a system for us :" % name)
     self.adjsys = go_to_adjacent_systems(self.you,numsystemsaway,jumps)
     self.adjsys.Print("From the %s system,","Carefully go to %s.","You should shortly arrive in the %s: patrol it.","patrol",1)
Ejemplo n.º 11
0
 def __init__(self,
              numsystemsaway,
              num_significants_to_patrol,
              distance_from_base,
              creds,
              jumps=(),
              donevar=''):
     Director.Mission.__init__(self)
     self.donevar = donevar
     self.jnum = 0
     self.cred = creds
     self.patrolpoints = []
     self.objectives = []
     self.distance = distance_from_base
     self.you = VS.getPlayer()
     self.quantity = num_significants_to_patrol
     name = self.you.getName()
     self.mplay = universe.getMessagePlayer(self.you)
     VS.IOmessage(0, "patrol", self.mplay,
                  "You must patrol a system for us :")
     self.adjsys = go_to_adjacent_systems(self.you, numsystemsaway, jumps)
     self.adjsys.Print("From the %s system,", "Carefully go to %s.",
                       "You should shortly arrive in the %s: patrol it.",
                       "patrol", 1)
    def __init__ (self,factionname, numsystemsaway, cargoquantity, missiondifficulty, creds, launchoncapship, time_to_complete, category,jumps=(),var_to_set=''):
        Director.Mission.__init__(self);
        self.you=VS.Unit()
        self.base=VS.Unit()
        self.role="ESCORTCAP"
        self.arrived=0
        self.var_to_set=var_to_set
        self.mplay="all"
#         self.mission_time=VS.GetGameTime()+time_to_complete*100*float(1+numsystemsaway)
        self.capship= launchoncapship
        self.faction=factionname
        self.cred=creds
        self.difficulty=missiondifficulty
        self.you=VS.getPlayer()
        self.adjsys=go_to_adjacent_systems(self.you,numsystemsaway,jumps)
        self.quantity=cargoquantity
        self.mplay=universe.getMessagePlayer(self.you)
        if (self.quantity<1):
            self.quantity=1
        carg=VS.getRandCargo(self.quantity,category)
        if (carg.GetQuantity()==0 or category==''):
            carg = VS.getRandCargo(self.quantity,"") #oh no... could be starships...
            i=0
            while i<50 and carg.GetCategory()[:10]=="Contraband":
                print "contraband==bad"
                carg = VS.getRandCargo(self.quantity,"")
                i+=1
        tempquantity=self.quantity
        self.cargoname=carg.GetContent()
        name = self.you.getName ()
        carg.SetMissionFlag(1)
        if (not self.you.isNull()):
            tmpcarg=self.you.GetCargo(self.cargoname)
            DoAddCargo=True
            try:
                if VS.loading_active_missions:
                    DoAddCargo=False
            except:
                pass
            if False and tmpcarg.GetMissionFlag() and tmpcarg.GetQuantity()>2:
                quantum=int(tmpcarg.GetQuantity()/3)
                quantum=self.you.removeCargo(carg.GetContent(),quantum,True)#use it if player has it
                carg.SetQuantity(1+quantum)
                self.quantity=self.you.addCargo(carg)
            elif DoAddCargo:
                self.quantity = self.you.addCargo(carg)  #I add some cargo
        else:
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Unable to establish communications. Mission failed.")
            VS.terminateMission (0)
            return
#         creds_deducted = (carg.GetPrice()*float(self.quantity)*vsrandom.random()+1)
#         self.cred += creds_deducted
        if (tempquantity>0):
            self.cred*=float(self.quantity)/float(tempquantity)
        else:
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000You do not have space to add our %s cargo to your ship. Mission failed."%self.cargoname)
            self.aborted=True
            VS.terminateMission(0)
            return

        if (self.quantity==0):
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000You do not have space to add our cargo to the mission. Mission failed.")
            self.aborted=True
            VS.terminateMission(0)
            return

        VS.IOmessage (0,"cargo mission",self.mplay,"Your mission is as follows:" )
        self.adjsys.Print("You should start in the system named %s","Then jump to %s","Finally, jump to %s, your final destination","cargo mission",1)
        VS.IOmessage (2,"cargo mission",self.mplay,"Give the cargo to a %s unit or planet." % (self.faction))
        VS.IOmessage (3,"cargo mission",self.mplay,"You will receive %d of the %s cargo" % (self.quantity,self.cargoname))
#         VS.IOmessage (4,"cargo mission",self.mplay,"We will deduct %.2f credits from your account for the cargo needed." % (creds_deducted))
        VS.IOmessage (4,"cargo mission",self.mplay,"You will earn %.2f credits when you deliver our cargo." % (creds))
        VS.IOmessage (4,"cargo mission",self.mplay,"#00ff00Good luck!")
Ejemplo n.º 13
0
    def __init__(self,
                 factionname,
                 numsystemsaway,
                 cargoquantity,
                 missiondifficulty,
                 creds,
                 launchoncapship,
                 time_to_complete,
                 category,
                 jumps=(),
                 var_to_set=''):
        Director.Mission.__init__(self)
        self.you = VS.Unit()
        self.base = VS.Unit()
        self.role = "ESCORTCAP"
        self.arrived = 0
        self.var_to_set = var_to_set
        self.mplay = "all"
        #         self.mission_time=VS.GetGameTime()+time_to_complete*100*float(1+numsystemsaway)
        self.capship = launchoncapship
        self.faction = factionname
        self.cred = creds
        self.difficulty = missiondifficulty
        self.you = VS.getPlayer()
        self.adjsys = go_to_adjacent_systems(self.you, numsystemsaway, jumps)
        self.quantity = cargoquantity
        self.mplay = universe.getMessagePlayer(self.you)
        if (self.quantity < 1):
            self.quantity = 1
        carg = VS.getRandCargo(self.quantity, category)
        if (carg.GetQuantity() == 0 or category == ''):
            carg = VS.getRandCargo(self.quantity,
                                   "")  #oh no... could be starships...
            i = 0
            while i < 50 and carg.GetCategory()[:10] == "Contraband":
                print "contraband==bad"
                carg = VS.getRandCargo(self.quantity, "")
                i += 1
        tempquantity = self.quantity
        self.cargoname = carg.GetContent()
        name = self.you.getName()
        carg.SetMissionFlag(1)
        if (not self.you.isNull()):
            tmpcarg = self.you.GetCargo(self.cargoname)
            if tmpcarg.GetMissionFlag() and tmpcarg.GetQuantity() > 2:
                quantum = int(tmpcarg.GetQuantity() / 3)
                quantum = self.you.removeCargo(carg.GetContent(), quantum,
                                               True)  #use it if player has it
                carg.SetQuantity(1 + quantum)
                self.quantity = self.you.addCargo(carg)
            else:
                self.quantity = self.you.addCargo(carg)  #I add some cargo
        else:
            VS.IOmessage(
                2, "cargo mission", self.mplay,
                "#ff0000Es ist unmoeglich die Kommunikation aufzubauen. Mission gescheitert."
            )
            VS.terminateMission(0)
            return
#         creds_deducted = (carg.GetPrice()*float(self.quantity)*vsrandom.random()+1)
#         self.cred += creds_deducted
        if (tempquantity > 0):
            self.cred *= float(self.quantity) / float(tempquantity)
        else:
            VS.IOmessage(
                2, "cargo mission", self.mplay,
                "#ff0000Du hast nicht genug Platz, um unsere %s Fracht in Deinem Schiff aufzunehmen. Mission gescheitert."
                % self.cargoname)
            VS.terminateMission(0)
            return

        if (self.quantity == 0):
            VS.IOmessage(
                2, "cargo mission", self.mplay,
                "#ff0000Du hast nicht genug Platz, um unsere Fracht in Deinem Schiff aufzunehmen. Mission gescheitert."
            )
            VS.terminateMission(0)
            return

        VS.IOmessage(0, "cargo mission", self.mplay,
                     "Guten Tag, %s. Deine Mission ist folgende:" % (name))
        self.adjsys.Print(
            "Du solltest in dem System mit dem Namen %s starten,",
            "dann springe nach %s,",
            "Zum Schluss springe nach %s, Deinem Ziel.", "cargo mission", 1)
        VS.IOmessage(
            2, "cargo mission", self.mplay,
            "Uebergebe die Fracht an eine %s-Einheit oder einen %s-Planeten." %
            (self.faction), (self.faction))
        VS.IOmessage(
            3, "cargo mission", self.mplay,
            "Du wirst %d von der %s Fracht erhalten." %
            (self.quantity, self.cargoname))
        #         VS.IOmessage (4,"cargo mission",self.mplay,"We will deduct %.2f credits from your account for the cargo needed." % (creds_deducted))
        VS.IOmessage(
            4, "cargo mission", self.mplay,
            "Du wirst %.2f Kredite verdienen, wenn Du unsere Fracht lieferst."
            % (creds))
        VS.IOmessage(4, "cargo mission", self.mplay, "#00ff00Viel Glueck!")
Ejemplo n.º 14
0
    def __init__ (self,factionname, numsystemsaway, cargoquantity, missiondifficulty, creds, launchoncapship, time_to_complete, category,jumps=(),var_to_set=''):
        Director.Mission.__init__(self);
        self.you=VS.Unit()
        self.base=VS.Unit()
        self.role="ESCORTCAP"
        self.arrived=0
        self.var_to_set=var_to_set
        self.mplay="all"
#         self.mission_time=VS.GetGameTime()+time_to_complete*100*float(1+numsystemsaway)
        self.capship= launchoncapship
        self.faction=factionname
        self.cred=creds
        self.difficulty=missiondifficulty
        self.you=VS.getPlayer()
        self.adjsys=go_to_adjacent_systems(self.you,numsystemsaway,jumps)
        self.quantity=cargoquantity
        self.mplay=universe.getMessagePlayer(self.you)
        if (self.quantity<1):
            self.quantity=1
        tempquantity=self.quantity
        name = self.you.getName ()
        if (not self.you.isNull()):
            j=0
            while j<15:
                #if j>10:
                #    category = ''
                carg = self.GetSomeCargo(category)
                found=False
                for i in range(self.you.numCargo()):
                    tmpcarg=self.you.GetCargoIndex(i)
                    if (tmpcarg.GetCategory()==category and tmpcarg.GetMissionFlag()) or self.cargoname==tmpcarg.GetContent():
                        print category, tmpcarg.GetCategory()
                        found=True
                        break
                if not found:
                    newquantity = self.you.addCargo(carg)  #I add some cargo
                    if newquantity>0:
                        print "It wasnt found %s"%self.cargoname
                        self.quantity=newquantity
                        break
                if found and tmpcarg.GetMissionFlag(): #self.cargoname==tmpcarg.GetContent():
                    self.cargoname=tmpcarg.GetContent()
                    self.quantity=int(tmpcarg.GetQuantity())
                    tempquantity=self.quantity
                    print ("already have "+str(self.quantity)+" cargo of this kind "+self.cargoname)
                    break
                # Else, let's look for another cargo of this kind
                print ("already have "+str(int(tmpcarg.GetQuantity()))+" non-mission cargo of this kind "+self.cargoname)
                
                j+=1
            else: # While loop's condition failed... i.e. j got too big.
                if not category:
                    category='generic'
                VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Unable to find suitable %s cargo that is not already loaded. Mission canceled."%category)
                VS.terminateMission (0)
                return
        else:
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Unable to establish communications. Mission failed.")
            VS.terminateMission (0)
            return
#         creds_deducted = (carg.GetPrice()*float(self.quantity)*vsrandom.random()+1)
#         self.cred += creds_deducted
        if (tempquantity>0):
            self.cred*=float(self.quantity)/float(tempquantity)
        else:
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000You do not have space to add our %s cargo to your ship. Mission failed."%self.cargoname)
            VS.terminateMission(0)
            return

        if (self.quantity==0):
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000You do not have space to add our cargo to the mission. Mission failed.")
            VS.terminateMission(0)
            return

        VS.IOmessage (0,"cargo mission",self.mplay,"Your mission is as follows:" )
        self.adjsys.Print("You should start in the system named %s","Then jump to %s","Finally, jump to %s, your final destination","cargo mission",1)
        VS.IOmessage (2,"cargo mission",self.mplay,"Give the cargo to a %s unit or planet." % (self.faction))
        VS.IOmessage (3,"cargo mission",self.mplay,"You will receive %d of the %s cargo" % (self.quantity,self.cargoname))
#         VS.IOmessage (4,"cargo mission",self.mplay,"We will deduct %.2f credits from your account for the cargo needed." % (creds_deducted))
        VS.IOmessage (4,"cargo mission",self.mplay,"You will earn %.2f credits when you deliver our cargo." % (creds))
        VS.IOmessage (4,"cargo mission",self.mplay,"#00ff00Good luck!")
Ejemplo n.º 15
0
    def __init__(self,
                 factionname,
                 numsystemsaway,
                 cargoquantity,
                 missiondifficulty,
                 creds,
                 launchoncapship,
                 time_to_complete,
                 category,
                 jumps=(),
                 var_to_set=''):
        Director.Mission.__init__(self)
        self.you = VS.Unit()
        self.base = VS.Unit()
        self.role = "ESCORTCAP"
        self.arrived = 0
        self.var_to_set = var_to_set
        self.mplay = "all"
        #         self.mission_time=VS.GetGameTime()+time_to_complete*100*float(1+numsystemsaway)
        self.capship = launchoncapship
        self.faction = factionname
        self.cred = creds
        self.difficulty = missiondifficulty
        self.you = VS.getPlayer()
        self.adjsys = go_to_adjacent_systems(self.you, numsystemsaway, jumps)
        self.quantity = cargoquantity
        self.mplay = universe.getMessagePlayer(self.you)
        if (self.quantity < 1):
            self.quantity = 1
        tempquantity = self.quantity
        name = self.you.getName()
        if (not self.you.isNull()):
            j = 0
            while j < 15:
                #if j>10:
                #    category = ''
                carg = self.GetSomeCargo(category)
                found = False
                for i in range(self.you.numCargo()):
                    tmpcarg = self.you.GetCargoIndex(i)
                    if (tmpcarg.GetCategory() == category
                            and tmpcarg.GetMissionFlag()
                        ) or self.cargoname == tmpcarg.GetContent():
                        print(category, tmpcarg.GetCategory())
                        found = True
                        break
                if not found:
                    newquantity = self.you.addCargo(carg)  #I add some cargo
                    if newquantity > 0:
                        print("It wasnt found %s" % self.cargoname)
                        self.quantity = newquantity
                        break
                if found and tmpcarg.GetMissionFlag(
                ):  #self.cargoname==tmpcarg.GetContent():
                    self.cargoname = tmpcarg.GetContent()
                    self.quantity = int(tmpcarg.GetQuantity())
                    tempquantity = self.quantity
                    print(("already have " + str(self.quantity) +
                           " cargo of this kind " + self.cargoname))
                    break
                # Else, let's look for another cargo of this kind
                print(("already have " + str(int(tmpcarg.GetQuantity())) +
                       " non-mission cargo of this kind " + self.cargoname))

                j += 1
            else:  # While loop's condition failed... i.e. j got too big.
                if not category:
                    category = 'generic'
                VS.IOmessage(
                    2, "cargo mission", self.mplay,
                    "#ff0000Unable to find suitable %s cargo that is not already loaded. Mission canceled."
                    % category)
                VS.terminateMission(0)
                return
        else:
            VS.IOmessage(
                2, "cargo mission", self.mplay,
                "#ff0000Unable to establish communications. Mission failed.")
            VS.terminateMission(0)
            return
#         creds_deducted = (carg.GetPrice()*float(self.quantity)*vsrandom.random()+1)
#         self.cred += creds_deducted
        if (tempquantity > 0):
            self.cred *= float(self.quantity) / float(tempquantity)
        else:
            VS.IOmessage(
                2, "cargo mission", self.mplay,
                "#ff0000You do not have space to add our %s cargo to your ship. Mission failed."
                % self.cargoname)
            VS.terminateMission(0)
            return

        if (self.quantity == 0):
            VS.IOmessage(
                2, "cargo mission", self.mplay,
                "#ff0000You do not have space to add our cargo to the mission. Mission failed."
            )
            VS.terminateMission(0)
            return

        VS.IOmessage(0, "cargo mission", self.mplay,
                     "Your mission is as follows:")
        self.adjsys.Print("You should start in the system named %s",
                          "Then jump to %s",
                          "Finally, jump to %s, your final destination",
                          "cargo mission", 1)
        VS.IOmessage(2, "cargo mission", self.mplay,
                     "Give the cargo to a %s unit or planet." % (self.faction))
        VS.IOmessage(
            3, "cargo mission", self.mplay,
            "You will receive %d of the %s cargo" %
            (self.quantity, self.cargoname))
        #         VS.IOmessage (4,"cargo mission",self.mplay,"We will deduct %.2f credits from your account for the cargo needed." % (creds_deducted))
        VS.IOmessage(
            4, "cargo mission", self.mplay,
            "You will earn %.2f credits when you deliver our cargo." % (creds))
        VS.IOmessage(4, "cargo mission", self.mplay, "#00ff00Good luck!")
Ejemplo n.º 16
0
 def __init__(self,
              factionname,
              numsystemsaway,
              cargoquantity,
              missiondifficulty,
              creds,
              launchoncapship,
              time_to_complete,
              category,
              jumps=(),
              var_to_set=''):
     Director.Mission.__init__(self)
     self.you = VS.Unit()
     self.base = VS.Unit()
     self.role = "ESCORTCAP"
     self.arrived = 0
     self.var_to_set = var_to_set
     self.mplay = "all"
     # self.mission_time=VS.GetGameTime()+time_to_complete*100*float(1+numsystemsaway)
     self.capship = launchoncapship
     self.faction = factionname
     self.cred = creds
     self.difficulty = missiondifficulty
     self.you = VS.getPlayer()
     self.adjsys = go_to_adjacent_systems(self.you, numsystemsaway, jumps)
     self.quantity = cargoquantity
     self.mplay = universe.getMessagePlayer(self.you)
     if (self.quantity < 1):
         self.quantity = 1
     carg = VS.getRandCargo(self.quantity, category)
     if (carg.GetQuantity() == 0 or category == ''):
         carg = VS.getRandCargo(self.quantity,
                                "")  #oh no... could be starships...
         i = 0
         while i < 50 and carg.GetCategory()[:10] == "Contraband":
             debug.info("contraband==bad")
             carg = VS.getRandCargo(self.quantity, "")
             i += 1
     tempquantity = self.quantity
     self.cargoname = carg.GetContent()
     name = self.you.getName()
     carg.SetMissionFlag(1)
     if (not self.you.isNull()):
         tmpcarg = self.you.GetCargo(self.cargoname)
         if tmpcarg.GetMissionFlag() and tmpcarg.GetQuantity() > 2:
             quantum = int(tmpcarg.GetQuantity() / 3)
             quantum = self.you.removeCargo(carg.GetContent(), quantum,
                                            True)  #use it if player has it
             carg.SetQuantity(1 + quantum)
             self.quantity = self.you.addCargo(carg)
         else:
             self.quantity = self.you.addCargo(carg)  #I add some cargo
     else:
         VS.IOmessage(
             2, "cargo mission", self.mplay,
             "#ff0000Unable to establish communications. Mission failed.")
         VS.terminateMission(0)
         return
     # creds_deducted = (carg.GetPrice()*float(self.quantity)*vsrandom.random()+1)
     # self.cred += creds_deducted
     if (tempquantity > 0):
         self.cred *= float(self.quantity) / float(tempquantity)
     else:
         VS.IOmessage(
             2, "cargo mission", self.mplay,
             "#ff0000You do not have space to add our %s cargo to your ship. Mission failed."
             % self.cargoname)
         VS.terminateMission(0)
         return
     if (self.quantity == 0):
         VS.IOmessage(
             2, "cargo mission", self.mplay,
             "#ff0000You do not have space to add our cargo to the mission. Mission failed."
         )
         VS.terminateMission(0)
         return
     VS.IOmessage(0, "cargo mission", self.mplay,
                  "Good Day, %s. Your mission is as follows:" % (name))
     self.adjsys.Print("You should start in the system named %s",
                       "Then jump to %s",
                       "Finally, jump to %s, your final destination",
                       "cargo mission", 1)
     VS.IOmessage(2, "cargo mission", self.mplay,
                  "Give the cargo to a %s unit or planet." % (self.faction))
     VS.IOmessage(
         3, "cargo mission", self.mplay,
         "You will receive %d of the %s cargo" %
         (self.quantity, self.cargoname))
     # VS.IOmessage (4,"cargo mission",self.mplay,"We will deduct %.2f credits from your account for the cargo needed." % (creds_deducted))
     VS.IOmessage(
         4, "cargo mission", self.mplay,
         "You will earn %.2f credits when you deliver our cargo." % (creds))
     VS.IOmessage(4, "cargo mission", self.mplay, "#00ff00Good luck!")
Ejemplo n.º 17
0
    def __init__ (self,factionname, numsystemsaway, cargoquantity, missiondifficulty, creds, launchoncapship, time_to_complete, category,jumps=(),var_to_set=''):
        Director.Mission.__init__(self);
        self.you=VS.Unit()
        self.base=VS.Unit()
        self.role="ESCORTCAP"
        self.arrived=0
        self.var_to_set=var_to_set
        self.mplay="all"
#         self.mission_time=VS.GetGameTime()+time_to_complete*100*float(1+numsystemsaway)
        self.capship= launchoncapship
        self.faction=factionname
        self.cred=creds
        self.difficulty=missiondifficulty
        self.you=VS.getPlayer()
        self.adjsys=go_to_adjacent_systems(self.you,numsystemsaway,jumps)
        self.quantity=cargoquantity
        self.mplay=universe.getMessagePlayer(self.you)
        if (self.quantity<1):
            self.quantity=1
        carg=VS.getRandCargo(self.quantity,category)
        if (carg.GetQuantity()==0 or category==''):
            carg = VS.getRandCargo(self.quantity,"") #oh no... could be starships...
            i=0
            while i<50 and carg.GetCategory()[:10]=="Contraband":
                print "contraband==bad"
                carg = VS.getRandCargo(self.quantity,"")
                i+=1
        tempquantity=self.quantity
        self.cargoname=carg.GetContent()
        name = self.you.getName ()
        carg.SetMissionFlag(1)
        if (not self.you.isNull()):
            tmpcarg=self.you.GetCargo(self.cargoname)
            if tmpcarg.GetMissionFlag() and tmpcarg.GetQuantity()>2:
                quantum=int(tmpcarg.GetQuantity()/3)
                quantum=self.you.removeCargo(carg.GetContent(),quantum,True)#use it if player has it
                carg.SetQuantity(1+quantum)
                self.quantity=self.you.addCargo(carg)
            else:
                self.quantity = self.you.addCargo(carg)  #I add some cargo
        else:
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Es ist unmoeglich die Kommunikation aufzubauen. Mission gescheitert.")
            VS.terminateMission (0)
            return
#         creds_deducted = (carg.GetPrice()*float(self.quantity)*vsrandom.random()+1)
#         self.cred += creds_deducted
        if (tempquantity>0):
            self.cred*=float(self.quantity)/float(tempquantity)
        else:
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Du hast nicht genug Platz, um unsere %s Fracht in Deinem Schiff aufzunehmen. Mission gescheitert."%self.cargoname)
            VS.terminateMission(0)
            return

        if (self.quantity==0):
            VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Du hast nicht genug Platz, um unsere Fracht in Deinem Schiff aufzunehmen. Mission gescheitert.")
            VS.terminateMission(0)
            return

        VS.IOmessage (0,"cargo mission",self.mplay,"Guten Tag, %s. Deine Mission ist folgende:" % (name))
        self.adjsys.Print("Du solltest in dem System mit dem Namen %s starten,","dann springe nach %s,","Zum Schluss springe nach %s, Deinem Ziel.","cargo mission",1)
        VS.IOmessage (2,"cargo mission",self.mplay,"Uebergebe die Fracht an eine %s-Einheit oder einen %s-Planeten." % (self.faction),(self.faction))
        VS.IOmessage (3,"cargo mission",self.mplay,"Du wirst %d von der %s Fracht erhalten." % (self.quantity,self.cargoname))
#         VS.IOmessage (4,"cargo mission",self.mplay,"We will deduct %.2f credits from your account for the cargo needed." % (creds_deducted))
        VS.IOmessage (4,"cargo mission",self.mplay,"Du wirst %.2f Kredite verdienen, wenn Du unsere Fracht lieferst." % (creds))
        VS.IOmessage (4,"cargo mission",self.mplay,"#00ff00Viel Glueck!")