rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
dd = cur.detection_distance
dd = self.cur.detection_distance
def AsteroidNear (unit, how): num_ships=0 count=0 un = VS.getUnit (count) while (un): dd = cur.detection_distance if (unit.getSignificantDistance(un,unit)<how): if (unit.isAsteroid (un)): _io.printf ("asty near") return 1 count=count+1 if (un): un = _unit.getUnit(count) return 0
_io.printf ("asty near")
print "asty near"
def AsteroidNear (unit, how): num_ships=0 count=0 un = VS.getUnit (count) while (un): dd = cur.detection_distance if (unit.getSignificantDistance(un,unit)<how): if (unit.isAsteroid (un)): _io.printf ("asty near") return 1 count=count+1 if (un): un = _unit.getUnit(count) return 0
un = _unit.getUnit(count)
un = VS.getUnit(count)
def AsteroidNear (unit, how): num_ships=0 count=0 un = VS.getUnit (count) while (un): dd = cur.detection_distance if (unit.getSignificantDistance(un,unit)<how): if (unit.isAsteroid (un)): _io.printf ("asty near") return 1 count=count+1 if (un): un = _unit.getUnit(count) return 0
def launch_near (un):
def launch_near (self,un):
def launch_near (un): numfactions=VS.GetNumFactions() if (numfactions==0): sys.stderr.write('warning: no factions\n') numfactions=1 sysfile = _std.getSystemFile() for i in range(0,numfactions): localfaction = _std.getGalaxyProperty(sysfile,"faction") if (random.random() < enprob): localfaction = faction_ships.get_enemy...
numfactions=1 sysfile = _std.getSystemFile()
return sysfile = VS.getSystemFile()
def launch_near (un): numfactions=VS.GetNumFactions() if (numfactions==0): sys.stderr.write('warning: no factions\n') numfactions=1 sysfile = _std.getSystemFile() for i in range(0,numfactions): localfaction = _std.getGalaxyProperty(sysfile,"faction") if (random.random() < enprob): localfaction = faction_ships.get_enemy...
det_distance = cur.detection_distance
det_distance = self.cur.detection_distance
def launch_near (un): numfactions=VS.GetNumFactions() if (numfactions==0): sys.stderr.write('warning: no factions\n') numfactions=1 sysfile = _std.getSystemFile() for i in range(0,numfactions): localfaction = _std.getGalaxyProperty(sysfile,"faction") if (random.random() < enprob): localfaction = faction_ships.get_enemy...
if (AsteroidNear (un,cur.significant_distance)):
if (AsteroidNear (un,self.cur.significant_distance)):
def launch_near (un): numfactions=VS.GetNumFactions() if (numfactions==0): sys.stderr.write('warning: no factions\n') numfactions=1 sysfile = _std.getSystemFile() for i in range(0,numfactions): localfaction = _std.getGalaxyProperty(sysfile,"faction") if (random.random() < enprob): localfaction = faction_ships.get_enemy...
def test_atLeastNInsignificantUnitsNear (unit, n): num_ships=0 count=0 un = VS.getUnit (count) while (un): dd = cur.detection_distance if (unit.getSignificantDistance(un,unit)<dd): if ((not un.isSignificant()) and (not un.isSun())): print "unit not sig %d %s %s" % (num_ships,un.getFgName(),un.getName()) num_ships+=1 if...
def atLeastNInsignificantUnitsNear (self,uni, n):
def test_atLeastNInsignificantUnitsNear (unit, n): num_ships=0 count=0 un = VS.getUnit (count) while (un): dd = cur.detection_distance if (unit.getSignificantDistance(un,unit)<dd): if ((not un.isSignificant()) and (not un.isSun())): print "unit not sig %d %s %s" % (num_ships,un.getFgName(),un.getName()) num_ships+=1 if...
dd = cur.detection_distance
dd = self.cur.detection_distance
def atLeastNInsignificantUnitsNear (uni, n): num_ships=0 count=0 leadah = uni.getFgLeader () un = VS.getUnit (count) dd = cur.detection_distance while (un): if (uni.getSignificantDistance(un)<dd*1.6): if ((not un.isSignificant()) and (not un.isSun())): unleadah = un.getFgLeader () if (leadah!=unleadah): num_ships+=1 co...
def SetModeZero(): cur.last_ship=0 cur.curmode=0 cur.sig_container.setNull() def SetModeOne (significant): cur[0]=0 cur[1]=1 cur[4]=significant cursys = VS.getSystemFile() lastsys = cur[3] oldsys = lastsys==cursys cur[3]=cursys
def SetModeZero(self): self.cur.last_ship=0 self.cur.curmode=0 self.cur.sig_container.setNull() def SetModeOne (self,significant): self.cur.last_ship=0 self.cur.curmode=1 self.cur.sig_container=significant self.cursys = VS.getSystemFile() oldsys = self.cur.lastsys==cursys self.cur.lastsys=cursys
def SetModeZero(): # last_ship=0 cur.last_ship=0 cur.curmode=0 # curmode=0 cur.sig_container.setNull()
CalculateSignificantDistance() def HaveWeSignificant (): significant_unit=cur.sig_container return significant_unit def decideMode(): if (cur.this_unit.isNull()):
self.CalculateSignificantDistance() def decideMode(self): myunit=VS.getPlayerX(self.cur.playernum) if (myunit.isNull()):
def SetModeOne (significant): cur[0]=0 #curmode=1 cur[1]=1 cur[4]=significant cursys = VS.getSystemFile() lastsys = cur[3] oldsys = lastsys==cursys cur[3]=cursys if (not oldsys): CalculateSignificantDistance()
return cur.this_unit significant_unit = HaveWeSignificant()
return myunit significant_unit = self.cur.sig_container()
def decideMode(): if (cur.this_unit.isNull()): SetModeZero() return cur.this_unit significant_unit = HaveWeSignificant() if (significant_unit.isNull()): un=VS.getUnit(cur.last_ship) if (un.isNull ()): SetModeZero() else: sd = cur.significant_distance if ((un.getSignificantDistance(cur.this_unit)<sd) and (un.isSignifica...
un=VS.getUnit(cur.last_ship)
un=VS.getUnit(self.cur.last_ship)
def decideMode(): if (cur.this_unit.isNull()): SetModeZero() return cur.this_unit significant_unit = HaveWeSignificant() if (significant_unit.isNull()): un=VS.getUnit(cur.last_ship) if (un.isNull ()): SetModeZero() else: sd = cur.significant_distance if ((un.getSignificantDistance(cur.this_unit)<sd) and (un.isSignifica...
sd = cur.significant_distance if ((un.getSignificantDistance(cur.this_unit)<sd) and (un.isSignificant())):
sd = self.cur.significant_distance if ((un.getSignificantDistance(myunit)<sd) and (un.isSignificant())):
def decideMode(): if (cur.this_unit.isNull()): SetModeZero() return cur.this_unit significant_unit = HaveWeSignificant() if (significant_unit.isNull()): un=VS.getUnit(cur.last_ship) if (un.isNull ()): SetModeZero() else: sd = cur.significant_distance if ((un.getSignificantDistance(cur.this_unit)<sd) and (un.isSignifica...
cur.last_ship+=1 return Unit()
self.cur.last_ship+=1 return VS.Unit()
def decideMode(): if (cur.this_unit.isNull()): SetModeZero() return cur.this_unit significant_unit = HaveWeSignificant() if (significant_unit.isNull()): un=VS.getUnit(cur.last_ship) if (un.isNull ()): SetModeZero() else: sd = cur.significant_distance if ((un.getSignificantDistance(cur.this_unit)<sd) and (un.isSignifica...
if (cursys== cur.lastsys): dd = cur.detection_distance if (cur.this_unit.getSignificantDistance (significant_unit)>dd): SetModeZero ()
if (cursys== self.cur.lastsys): dd = self.cur.detection_distance if (self.cur.myunit.getSignificantDistance (significant_unit)>dd): self.SetModeZero ()
def decideMode(): if (cur.this_unit.isNull()): SetModeZero() return cur.this_unit significant_unit = HaveWeSignificant() if (significant_unit.isNull()): un=VS.getUnit(cur.last_ship) if (un.isNull ()): SetModeZero() else: sd = cur.significant_distance if ((un.getSignificantDistance(cur.this_unit)<sd) and (un.isSignifica...
cur.lastsys=cursys SetModeZero()
self.cur.lastsys=cursys self.SetModeZero()
def decideMode(): if (cur.this_unit.isNull()): SetModeZero() return cur.this_unit significant_unit = HaveWeSignificant() if (significant_unit.isNull()): un=VS.getUnit(cur.last_ship) if (un.isNull ()): SetModeZero() else: sd = cur.significant_distance if ((un.getSignificantDistance(cur.this_unit)<sd) and (un.isSignifica...
def initbriefing():
def initbriefing(self):
def initbriefing(): print "ending briefing"
def loopbriefing():
def loopbriefing(self):
def loopbriefing(): print "loop briefing" Briefing.terminate();
def endbriefing():
def endbriefing(self):
def endbriefing(): print "ending briefing"
pass
if len(path)<=1: name+=" - In System" Director.pushSaveSting(plr, "mission_names", name)
def writemissionname(name,path): pass
pass
Director.pushSaveSting(plr, "mission_descriptions", name)
def writedescription(name): pass
pass
Director.pushSaveSting(plr, "mission_scripts", name) def eraseExtras(): import sys len=Director.getSaveStringLength(plr, "mission_scripts") if (len!=Director.getSaveStringLength(plr, "mission_names") or len!=Director.getSaveStringLength(plr, "mission_descriptions")): sys.stdout.write("Warning: Number of mission descs....
def writemissionsavegame (name): pass
if (rnd<.18):
if (rnd<.45):
def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta...
elif (rnd<.41):
elif (rnd<.9):
def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=thisfaction#try to sta...
def Check():
def Check(self):
def Check(): if (not un): if (VS.systemInMemory (self.starsystem)): RemoveShipFromFG(self.fgname,self.faction,self.type) else: LandShip(self.fgname,self.faction,self.type) return 0 else: sys=un.getUnitSystemFile() if (len(sys)): self.starsystem=sys return 1
,"neutral" : [(0.8,"all","Attempted VAR_aggressor_nicks attack backfires\\The VAR_aggressor_nicks VAR_aggressor_FG squadron engaged VAR_defender_nicks forces today. Utterly without a plan, their attack backfired as the VAR_defender_FG squad of VAR_defender_FGtype ships looped around and closed for the kill. What is s...
,"neutral" : [(0.8,"all","Attempted VAR_aggressor_nicks attack backfires\\The VAR_aggressor_nicks VAR_aggressor_FG squadron engaged VAR_defender_nicks forces today. Utterly without a plan, their attack backfired as the VAR_defender_FG squad of VAR_defender_FGtype ships looped around and closed for the kill. What is s...
def allNews():
,"bad" : [(0.8,"all","VAR_aggressor_nickp and VAR_defender_nickp eradicate each other in VAR_system_system\\In a sudden strike by the VAR_aggressor_nick VAR_aggressor_FG fleet, a well planned strategic missile assault went astray and both sides ended up fighting in a close, brutal beam battle. No starships were left i...
,"bad" : [(0.8,"all","VAR_aggressor_nickp and VAR_defender_nickp eradicate each other in VAR_system_system\\In a sudden strike by the VAR_aggressor_nicks VAR_aggressor_FG fleet, a well planned strategic missile assault went astray and both sides ended up fighting in a close, brutal beam battle. No starships were left ...
def allNews():
VS.IOmessage (4,"game","all","
VS.IOmessage (4,"cargo mission",self.mplay,"
def __init__ (self,factionname, numsystemsaway, cargoquantity, missiondifficulty, creds, launchoncapship, time_to_complete, category): Director.Mission.__init__(self); self.you=VS.Unit() self.base=VS.Unit() self.arrived=0 self.mplay="all"
intseed = ( intseed * 1103515245 + 12345) intseed = intseed %RAND_MAX
intseed = long( long(intseed) * long(1103515245) + long(12345)) intseed = long(intseed) %long(RAND_MAX)
def rands(intseed): global RAND_MAX intseed = ( intseed * 1103515245 + 12345) intseed = intseed %RAND_MAX try: intseed=int(intseed) except: return intseed return intseed
for i in range (Director.getSaveStringLength (ccp,key)):
len=Director.getSaveStringLength (ccp,key) i=0 while i<len:
def PurgeZeroShips (faction): key=MakeFactionKey(faction) for i in range (Director.getSaveStringLength (ccp,key)): curfg=Director.getSaveString(ccp,key,i) CheckFG (curfg,faction) numships=NumShipsInFG(curfg,faction) if (numships==0): DeleteFG(curfg,faction)
self.diff+=[newdiff]
print "done director" self.diff+=[newdiff] print "set diff start"
def __init__(self,credsMax): print "init diff" self.diff=[] self.creds=[] self.credsToMax=credsMax un=VS.getPlayerX(0) self.i=0 while (un): newdiff=0 if (Director.getSaveDataLength(self.i,_key)): newdiff=Director.getSaveData(self.i,_key,0) else: newdiff=VS.GetDifficulty() Director.pushSaveData(self.i,_key,newdiff) self...
persystemattacklist {}
def __init__(self,fgname,faction): self.fg=fgname self.fac=fact
global persystemattacklist global attacklist persystemattacklist = {}
def SimulateBattles(): deadbattles=[] for ally in attacklist: enemy = attacklist[ally] if (not attackFlightgroup (ally.fg,ally.fac,enemy.fg,enemy.fac)): deadbattles+=[ally] for i in deadbattles: stopAttack(i)
def BattlesInSystem(): if sys in persystemattacklist: return persystemattacklist[sys] return []
def SimulateBattles(): deadbattles=[] for ally in attacklist: enemy = attacklist[ally] if (not attackFlightgroup (ally.fg,ally.fac,enemy.fg,enemy.fac)): deadbattles+=[ally] for i in deadbattles: stopAttack(i)
Director.Mission.__init__ ()
Director.Mission.__init__ (self)
def __init__ (self,minnumsystemsaway, maxnumsystemsaway, creds, run_away, shipdifficulty, tempfaction): Director.Mission.__init__ () self.newship="" self.mplay="all" self.istarget=0 self.obj=0 self.curiter=0 self.arrived=0 self.faction = tempfaction self.difficulty = shipdifficulty self.runaway=run_away self.cred=creds...
if (you): VS.IOmessage (0,"bounty mission",self.mplay,"Good Day, %s. Your mission is as follows:" % (you.getName()))
if (self.you): VS.IOmessage (0,"bounty mission",self.mplay,"Good Day, %s. Your mission is as follows:" % (self.you.getName()))
def __init__ (self,minnumsystemsaway, maxnumsystemsaway, creds, run_away, shipdifficulty, tempfaction): Director.Mission.__init__ () self.newship="" self.mplay="all" self.istarget=0 self.obj=0 self.curiter=0 self.arrived=0 self.faction = tempfaction self.difficulty = shipdifficulty self.runaway=run_away self.cred=creds...
VS.IOmessage (2,"bounty mission",self.mplay,"Once there, you must destroy a %s unit." % (faction))
VS.IOmessage (2,"bounty mission",self.mplay,"Once there, you must destroy a %s unit." % (self.faction))
def __init__ (self,minnumsystemsaway, maxnumsystemsaway, creds, run_away, shipdifficulty, tempfaction): Director.Mission.__init__ () self.newship="" self.mplay="all" self.istarget=0 self.obj=0 self.curiter=0 self.arrived=0 self.faction = tempfaction self.difficulty = shipdifficulty self.runaway=run_away self.cred=creds...
def loop (self):
def Execute (self):
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
if (you.isNull()): self.Lose(1) return
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
self.Win(you,1)
self.Win(self.you,1)
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
Lose(1)
self.Lose(1)
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
Win(you,1)
self.Win(self.you,1)
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
if (you.getSignificantDistance(significant)<10000.0):
if (self.you.getSignificantDistance(significant)<10000.0):
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
if (runaway): self.enemy.setTarget(significant)
if (self.runaway): self.enemy.SetTarget(significant)
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
self.newship=faction_ships.getRandomFighter(faction)
self.newship=faction_ships.getRandomFighter(self.faction)
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
if (runaway):
if (self.runaway):
def loop (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): if (not self.istarget): curun=VS.getUnit(self.curiter) if (self.enemy): if (curun==self.enemy): self.enemy.setTarget(self.you) self.curiter+=1 if (you.isNull()): self.Lose(1) return if (self.enemy.isNull()): self.Win(you,1) retu...
self.escortee = launch.launch_wave_around_unit("Escort",
global escort_num escort_num+=1 self.escortee = launch.launch_wave_around_unit("Escort"+str(escort_num),
def __init__ (self,factionname, missiondifficulty, our_dist_from_jump, dist_from_jump, distance_from_base, creds, enemy_time, numsysaway,jumps=(),var_to_set=''): Director.Mission.__init__(self); self.you = VS.getPlayer(); self.adjsys=go_to_adjacent_systems(self.you, numsysaway,jumps) self.var_to_set = var_to_set; print...
self.you.setFlightgroupLeader(self.you)
self.escortee.setFlightgroupLeader(self.you)
def Execute (self): self.escortee.setFgDirective('F') if self.you.isNull(): VS.IOmessage (0,"escort",self.mplay,"#ff0000You were to protect your escort. Mission failed.") VS.terminateMission(0) return self.you.setFlightgroupLeader(self.you) if (self.escortee.isNull()): VS.IOmessage (0,"escort",self.mplay,"#ff0000You we...
,"draw" : {"good" : [(0.8,"all","draw is good") ,(0.8, ]
,"draw" : {"good" : [(0.8,"all","draw is good")]
def allNews():
if len(shipext)>0:
if len(shipext)>1:
def formatShipName(string): """formats a standard ship name (ie firefly.blank) to something more natural (ie basic Firefly)""" shipext = string.split('.') extension = "millspec"; if len(shipext)>0: extension = shipext[1]; ship = shipext[0]; if extension == "blank": return "basic" + formatProperTitle(ship) elif extensio...
return pickle.dumps(self.pickil)
return pickle.dumps(self.diffcls)
def Pickle (self): return pickle.dumps(self.pickil)
def UnPickle (self): return pickle.loads(self.pickil)
def UnPickle (self,fil): self.diffcls=pickle.loads(fil) VS.SetDifficulty(self.diffcls.diff)
def UnPickle (self): return pickle.loads(self.pickil)
ret=0.0 if (playa): temp = VS.getSaveData (playa,"31337ness") if (len(temp)>0): ret = temp[0] return ret
return self.diffcls.diff
def getPlayerDifficulty (self,playa): ret=0.0 if (playa): temp = VS.getSaveData (playa,"31337ness") #??? if (len(temp)>0):
player = _unit.getPlayerX(playeriterator)
player = VS.getPlayerX(playeriterator)
def Execute (self): player = _unit.getPlayerX(playeriterator) if (player): oldcreds = creds[playeriterator] newcreds = _unit.getCredits (player) if (newcreds!=oldcreds):
newcreds = _unit.getCredits (player)
newcreds = player.getCredits ()
def Execute (self): player = _unit.getPlayerX(playeriterator) if (player): oldcreds = creds[playeriterator] newcreds = _unit.getCredits (player) if (newcreds!=oldcreds):
save = VS.getSaveData (player,"31337ness") if (len(save)>0): difficulty = save[0] else: difficulty = VS.GetDifficulty() difficulty+=((newcreds-oldcreds)/credsToMax) if (difficulty>0.99999): difficulty=0.99999 SetDiff(difficulty)
difficulty=self.diffcls.diff difficulty+=((newcreds-oldcreds)/credsToMax)/len(creds) if (difficulty>0.999999): difficulty=0.999999
def Execute (self): player = _unit.getPlayerX(playeriterator) if (player): oldcreds = creds[playeriterator] newcreds = _unit.getCredits (player) if (newcreds!=oldcreds):
return string.join(ls,',')
return string.join([str(vsrandom.randrange(0,4194304))]+ls,',')
def makeVarList(ls): """formats a list of variables to be stored in a save game for later reference""" return string.join(ls,',')
return getClosestScaleNews([(scale,"all","ERROR!\\Invalid news variables:\\(" + makeVarList([faction_base,type_event,stage_event,success,pov,str(scale),keyword]) + ")\\A suitable news story for this event could not be found.\\This is a placeholder error message.\\\\Contact the help-desk for any queries:\\dandandaman@us...
return getClosestScaleNews([(scale,"all","ERROR!\\Invalid news variables:\\(" + string.join([faction_base,type_event,stage_event,success,pov,str(scale),keyword],',') + ")\\A suitable news story for this event could not be found.\\This is a placeholder error message.\\\\Contact the help-desk for any queries:\\dandandama...
def getNewsItem(faction_base,type_event,stage_event,success,pov,scale,keyword,randint): """finds a suitable news string from the dynamic_news_content.allNews() dictionary""" faction = validateNewsItem(faction_base,type_event,stage_event,success,pov,keyword) if faction == "barf": print "Error: A suitable news story does...
return finallist[randint][2]
return finallist[randint%len(finallist)][2]
def getClosestScaleNews(listof,scale,randint): """returns the closest scaled news item from a list of news items""" valtable = [] for i in range (len(listof)): valtable.append(listof[i] + (abs(scale - listof[i][0]),)) finallist = [valtable[0]] for i in range (1,len(valtable)): if finallist[0][3] > valtable[i][3]: final...
def checkVarListRelevant(newslist):
def checkVarListRelevant(newslist,randint):
def checkVarListRelevant(newslist): """returns true only if the newslist is relevant (major or close to home)""" if (not (newslist[0] in minorNewsTypes())): return 1 if (newslist[0] in minorNewsTypes()) and (checkSystemRelevant(newslist[6])): return 1
Base.Message ("You conspirator! I should have realized you were a kepitalizt pig when I first smelled our foul stench! You probably got paid to destroy our vessel. If I shared in your lack of honor I would kill you where you stand. But instead I shall ask my operatives to rid you of your ship. The next time any of us ...
Base.Message ("You conspirator! I should have realized you were a kepitalizt pig when I first smelled your foul stench! You probably got paid to destroy our vessel. If I shared in your lack of honor I would kill you where you stand. But instead I shall ask my operatives to rid you of your ship. The next time any of us...
def AssignMission (): fixers.DestroyActiveButtons () fixers.CreateChoiceButtons(Base.GetCurRoom(),[ fixers.Choice("bases/fixers/yes.spr","bases/fixers/iso_mission.py","Accept This Agreement"), fixers.Choice("bases/fixers/no.spr","bases/fixers/iso_decline.py","Decline This Agreement")])
diff=[] creds=[] credsToMax=1 i=0
def SetDiff(diff): if (diff>VS.GetDifficulty()): VS.SetDifficulty(diff)
self.diff+=[newdiff]
def __init__(self,credsMax): self.credsToMax=credsMax un=VS.getPlayerX(0) self.i=0 while (un): newdiff=0 if (Director.getSaveDataLength(self.i,_key)): newdiff=Director.getSaveData(self.i,_key,0) self.diff+=[newdiff] else: newdiff=VS.GetDifficulty() self.diff+=[newdiff] Director.pushSaveData(self.i,_key,newdiff) SetDiff...
if (len(self.creds)<=0): if (self.i!=-1): self.i=-1 raise IndexError("Empty creds and diff arrays in difficulty module\nUnable to find any players...") return if (self.i>=len(self.creds)): self.i=0
if (self.i>=len(self.creds)): self.i=0 else:
def Execute(self):
newcreds=un.getCredits() if (self.creds[self.i]!=newcreds): if (self.creds[self.i]>newcreds): newdiff=((newcreds-self.creds[self.i])/self.credsToMax) Director.putSaveData(self.i,_key,0,newdiff) SetDiff(newdiff) self.creds[self.i]=newcreds self.i+=1
if (un): newcreds=un.getCredits() if (self.creds[self.i]!=newcreds): if (self.creds[self.i]<newcreds): newdiff=self.getPlayerDifficulty(i)+((newcreds-self.creds[self.i])/self.credsToMax) if (newdiff>.999): newdiff=.999 Director.putSaveData(self.i,_key,0,newdiff) SetDiff(newdiff) self.creds[self.i]=newcreds self.i+=1
def Execute(self):
,"bad" : [(0.3,"all","VAR_defender_possessive VAR_defender_FGtype Defence Force Fired Upon!\\ VAR_aggressor_FGtype’s fired upon VAR_defender_FGtype ships in an unprovoked attack only hours ago! Casualties are currently unknown, but VAR_defender_possessive reinforcements are being rushed to the battle site even now.\\T...
,"bad" : [(0.3,"all","VAR_defender_possessive VAR_defender_FGtype Defence Force Fired Upon!\\ VAR_aggressor_FGtype’s fired upon VAR_defender_FGtype cruisers in an unprovoked attack only hours ago! Casualties are currently unknown, but VAR_defender_possessive reinforcements are being rushed to the battle site even now....
def allNews():
return 'FG:'+str(VS.GetFactionIndex(faction))
return 'FF:'+str(VS.GetFactionIndex(faction))
def MakeFactionKey (faction): return 'FG:'+str(VS.GetFactionIndex(faction))
return 'FG:'+str(starsystem)
return 'SS:'+str(starsystem)
def MakeStarSystemFGKey (starsystem): return 'FG:'+str(starsystem)
for i in range (len(tup)-1):
for i in range (1,len(tup)):
def ListToPipe (tup): fina='' if (len(tup)): fina=tup[0] for i in range (len(tup)-1): fina+='|'+tup[i] return fina
curun=VS.getUnit(curiter) if (enemy):
curun=VS.getUnit(self.curiter) if (not enemy.isNull()):
def loop (self): isSig=0 enemy=VS.Unit() if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): enemy=self.enemy if (not self.istarget): curun=VS.getUnit(curiter) if (enemy): if (curun==enemy): enemy.setTarget(you) curiter+=1 if (you.isNull()): Lose(1) return if (enemy.isNull()): Win(you,1) return elif (sel...
curiter+=1
self.curiter+=1
def loop (self): isSig=0 enemy=VS.Unit() if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): enemy=self.enemy if (not self.istarget): curun=VS.getUnit(curiter) if (enemy): if (curun==enemy): enemy.setTarget(you) curiter+=1 if (you.isNull()): Lose(1) return if (enemy.isNull()): Win(you,1) return elif (sel...
Lose(1)
self.Lose(1)
def loop (self): isSig=0 enemy=VS.Unit() if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): enemy=self.enemy if (not self.istarget): curun=VS.getUnit(curiter) if (enemy): if (curun==enemy): enemy.setTarget(you) curiter+=1 if (you.isNull()): Lose(1) return if (enemy.isNull()): Win(you,1) return elif (sel...
Win(you,1)
self.Win(you,1)
def loop (self): isSig=0 enemy=VS.Unit() if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): enemy=self.enemy if (not self.istarget): curun=VS.getUnit(curiter) if (enemy): if (curun==enemy): enemy.setTarget(you) curiter+=1 if (you.isNull()): Lose(1) return if (enemy.isNull()): Win(you,1) return elif (sel...
if (VS.getSystemFile()==destination):
if (VS.getSystemFile()==self.adjsys.DestinationSystem()):
def loop (self): isSig=0 enemy=VS.Unit() if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): enemy=self.enemy if (not self.istarget): curun=VS.getUnit(curiter) if (enemy): if (curun==enemy): enemy.setTarget(you) curiter+=1 if (you.isNull()): Lose(1) return if (enemy.isNull()): Win(you,1) return elif (sel...
intseed = ( intseed * 1103515245 + 12345); intseed %= RAND_MAX; return intseed;
intseed = ( intseed * 1103515245 + 12345) intseed = intseed %RAND_MAX try: intseed=int(intseed) except: return intseed return intseed
def rands(intseed): global RAND_MAX intseed = ( intseed * 1103515245 + 12345); intseed %= RAND_MAX; return intseed;
def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' while len(enemies): index=vsrandom.randrange(0,len(enemies)) script=contractMissionForTo(fac,enemies[index],minsysaway,maxsysaway) if (script): return script del enemies[index] re...
def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac]) script='' while len(enemies): index=vsrandom.randrange(0,len(enemies)) script=contractMissionForTo(fac,enemies[index],minsysaway,maxsysaway) if (script): return script del enemies[index] re...
generateEscortMission l = universe.getAdjacentSystemList(i)
l = universe.getAdjacentSystemList(i)
def getSystemsKAwayNoFaction( start, k ): set = [start]#set of systems that have been visited pathset = [[start]]#parallel data structure to set, but with paths pathtor = [[start]]#parallel data structure to raw return systems with path r = [start] #raw data structure containing systems n away where n<=k for n in range...
def generateEscortMission (path):
def generateEscortMission (path,fg,fac):
def generateEscortMission (path): ###
def generateBountyMission (path):
def generateBountyMission (path,fg,fac):
def generateBountyMission (path): ###
def generateDefendMission (path):
def generateDefendMission (path,defendfg,defendfac, attackfg,attackfac):
def generateDefendMission (path): ###
def contractMissionForTo (fac,enemy,minsysaway,maxsysaway): """Creates a mission for faction `fac' and against `enemy'"""
def contractMissionsFor(fac,minsysaway,maxsysaway): fac=faction_ships.intToFaction(fac) enemies = list(faction_ships.enemies[fac])
def contractMissionForTo (fac,enemy,minsysaway,maxsysaway): """Creates a mission for faction `fac' and against `enemy'""" script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=fac#try to stay in this territo...
preferredfaction=fac
preferredfaction=thisfaction
def contractMissionForTo (fac,enemy,minsysaway,maxsysaway): """Creates a mission for faction `fac' and against `enemy'""" script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=fac#try to stay in this territo...
l.append(getSystemsNAway(cursystem,i,preferredfaction)): maxmissions=vsrandom.randrange(1,30) for cur in range(0,maxmissions): rnd=vsrandom.random() if (rnd<.5): dist=0 path=[] else: dist=vsrandom.randrange(maxsysaway+1-minsysaway) path=l[dist][len(l[dist])]
for j in getSystemsNAway(cursystem,i,preferredfaction): import dynamic_battle try: l = dynamic_battle.persystemattacklist except: l= [] for k in l: if (VS.GetRelation(fac,l[1][1])>0): generateDefendMission(j,l[1][0],l[1][1],l[0][0],l[0][1]) for k in range(vsrandom.randrange(1,4)): pass
def contractMissionForTo (fac,enemy,minsysaway,maxsysaway): """Creates a mission for faction `fac' and against `enemy'""" script='' cursystem = VS.getSystemFile() thisfaction = VS.GetGalaxyFaction (cursystem) preferredfaction=None if (VS.GetRelation (fac,thisfaction)>0): preferredfaction=fac#try to stay in this territo...
return 2003
if faction == "confed": return 2403 else: return 2403
def getZeroYear(faction): return 2003 #FIXME: make faction dependent
rad=_unit.getRSize (un)
rad=_unit.rSize (un)
def NextPos (un, pos): rad=_unit.getRSize (un) whichcoord = random.random(0,2) x = _olist.at (pos,whichcoord) x=x+3.0*rad _olist.set (pos,whichcoord,x)
x = _olist.at (pos,whichcoord)
x = pos[whichcoord] pos = [pos[0],pos[1],pos[2]]
def NextPos (un, pos): rad=_unit.getRSize (un) whichcoord = random.random(0,2) x = _olist.at (pos,whichcoord) x=x+3.0*rad _olist.set (pos,whichcoord,x)
_olist.set (pos,whichcoord,x)
pos[whichcoord]=x return (pos[0],pos[1],pos[2])
def NextPos (un, pos): rad=_unit.getRSize (un) whichcoord = random.random(0,2) x = _olist.at (pos,whichcoord) x=x+3.0*rad _olist.set (pos,whichcoord,x)
NextPos (un,where)
return NextPos (un,where)
def move_to (un, where): un.setPosition(where) un.setTarget (VS.Unit()) NextPos (un,where)
pos=(pos[0]+rsize*random.randomsign() pos[1]+rsize*random.randomsign() pos[2]+rsize*random.randomsign()) return pos
return (pos[0]+rsize*random.randomsign() pos[1]+rsize*random.randomsign() pos[2]+rsize*random.randomsign())
def whereTo (radius, launch_around): pos = launch_around.getPosition () rsize = ((launch_around.rSize())*2.0)+radius pos=(pos[0]+rsize*random.randomsign() pos[1]+rsize*random.randomsign() pos[2]+rsize*random.randomsign()) return pos
move_to (un,pos)
pos=move_to (un,pos)
def look_for (fg, faction, numships,myunit, pos, gcd): i=0 un = VS.getUnit (i) while (un): i+=1 un = VS.getUnit (i) i-=1 #now our i is on the last value while ((i>=0)&&(numships>0)): un = VS.getUnit (i) if (un):
return numships
return (numships,pos)
def look_for (fg, faction, numships,myunit, pos, gcd): i=0 un = VS.getUnit (i) while (un): i+=1 un = VS.getUnit (i) i-=1 #now our i is on the last value while ((i>=0)&&(numships>0)): un = VS.getUnit (i) if (un):
rad=_unit.getRSize (newship)
rad=unit.rSize (newship)
def LaunchNext (fg, fac, type, ai, pos, logo): newship = launch.launch (fg,fac,type,ai,1,1,pos,logo) rad=_unit.getRSize (newship) VS.playAnimation ("warp.ani",pos,(3.0*rad)) NextPos (newship,pos)
NextPos (newship,pos)
return NextPos (newship,pos)
def LaunchNext (fg, fac, type, ai, pos, logo): newship = launch.launch (fg,fac,type,ai,1,1,pos,logo) rad=_unit.getRSize (newship) VS.playAnimation ("warp.ani",pos,(3.0*rad)) NextPos (newship,pos)
LaunchNext (fg,faction,type, ai, pos,logo)
pos = LaunchNext (fg,faction,type, ai, pos,logo)
def launch_wave_around ( fg, faction, ai, nr_ships, capship, radius, myunit, garbage_collection_distance,logo): pos = whereTo(radius, myunit) nr_ships = look_for (fg,faction,nr_ships,myunit,pos,garbage_collection_distance) while (nr_ships>0): type="" if (capship):
Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",0),("iso_mission2",1)],"bases/fixers/iso.spr","bases/fixers/iso.py")
Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",0),("iso_mission2",1)],"bases/fixers/iso.spr","bases/fixers/iso.py"), Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",0),("iso_mission2",-1)],"bases/fixers/iso.spr","bases/fixers/iso.py")
def drawobjs(self,room,x,y,wid,hei): Base.Texture(room,self.name,self.image,x+(wid/2),y+(hei/2)) Base.Python(room,self.name,x,y,wid,hei,self.text,self.choices,True)
Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",1)],"bases/fixers/iso.spr","bases/fixers/iso.py")
Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",1)],"bases/fixers/iso.spr","bases/fixers/iso.py"), Fixer ("rowenna","Speak with Rowenna",[("decided_iso_evil",0),("iso_mission3",-1)],"bases/fixers/iso.spr","bases/fixers/iso.py")
def drawobjs(self,room,x,y,wid,hei): Base.Texture(room,self.name,self.image,x+(wid/2),y+(hei/2)) Base.Python(room,self.name,x,y,wid,hei,self.text,self.choices,True)
num=0
num=long(0)
def seedstring (stru): num=0 l=len (stru) for i in range(l): global totalnormchar,RAND_MAX num+=getNumFromChar(stru[l-i-1]) num*=totalnormchar; num = num % RAND_MAX try: num = int(num) except: print 'warning' return num
num+=getNumFromChar(stru[l-i-1]) num*=totalnormchar; num = num % RAND_MAX try: num = int(num) except: print 'warning'
num+=long(getNumFromChar(stru[l-i-1])) num*=long(totalnormchar); num = (num % long(RAND_MAX)) try: num = int(num) except: print 'warning'
def seedstring (stru): num=0 l=len (stru) for i in range(l): global totalnormchar,RAND_MAX num+=getNumFromChar(stru[l-i-1]) num*=totalnormchar; num = num % RAND_MAX try: num = int(num) except: print 'warning' return num
,"loss" : {"good" : [(0.5,"player","Tragic skirmish in VAR_system_system\\A small skirmish in VAR_system_system resulted in the defeat of the VAR_aggressor_nickp starship, type VAR_aggressor_FGtype. Authorities viewed the small skirmish as a sad but isolated case and state that this skirmish in no way should indicate...
,"loss" : {"good" : [(0.8,"all","VAR_aggressor_dnicks attack repelled by valorous VAR_system_system - based VAR_defender_FG\\The resourceful and potent VAR_defender_nickp squadran was assaulted by the deceitful VAR_aggressor_nicks flightgroup of VAR_aggressor_FGtype starships. Far from running, the VAR_defender_nicks ...
def allNews():