def publishNews(text): # publishes the news text with star date player = VS.getPlayer().isPlayerStarship() STARDATE_TEXT = "\\\\\This story was first broadcast on: " datetext = stardate.formatStarDate("confed",VS.getStarTime()) newstext = "#" + text + STARDATE_TEXT + datetext + "\\GINA - Galactic Independent News Association" Director.pushSaveString(player,"dynamic_news",newstext)
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
def _RemoveFGFromFactionList (fgname,faction): key = MakeFactionKey(faction) leg=Director.getSaveStringLength(ccp,key) for index in xrange(leg): if Director.getSaveString(ccp,key,index) == fgname: Director.eraseSaveString(ccp,key,index) return 1
def removeQuest (playernum,questname,value=1): print "removing quest" mylen=Director.getSaveDataLength(int(playernum),str(questname)) if (mylen>0): Director.putSaveData(int(playernum),str(questname),0,float(value)) else: Director.pushSaveData(int(playernum),str(questname),float(value))
def Execute (self): sys=VS.getSystemFile() plyr=VS.getPlayerX(self.playernum) if not plyr: return 1 if (sys==self.sysfile): if quest.findQuest(self.playernum,(self.sysfile+"_nav"),1): if self.notcreatedyet==0: self.navpoint=VS.launch("Base","navpoint","neutral","unit","sitting_duck",1,1,(861946880,2132313,31337),"") self.notcreatedyet=1 elif self.notcreatedyet==1 and self.navpoint and VS.getPlayerX(self.playernum).getDistance(self.navpoint)<=2000: # VS.IOmessage(0,'game','all','[Computer] Energy source identified as a jump point, destination: unknown') self.createjumppoint(True) self.navpoint.Kill() Director.putSaveData(self.playernum,(self.sysfile+"_nav"),0,2) # elif (sys==self.newsys): # if not (quest.checkSaveValue(self.playernum,self.newsys+'_navpoint',0)): # print "ret0becausenewsys+_navpoint==0!!!!!!!!!!!" # return 1 # if plyr!=self.you: # if self.notcreatedyet==5: # VS.LoadMission('patrol/explore.mission') # self.you=plyr # if quest.findQuest(self.playernum,(self.sysfile+"_nav"),2): # VS.LoadMission('patrol/explore.mission') # self.notcreatedyet=5 # Director.putSaveData(self.playernum,(self.sysfile+"_nav"),0,3) # elif self.notcreatedyet!=5 and quest.findQuest(self.playernum,(self.sysfile+"_nav"),3): # VS.LoadMission('patrol/explore.mission') # self.notcreatedyet=5 return 1
def CreateGuildMissions(guildname,nummissions,accepttypes): plr=VS.getPlayer().isPlayerStarship() goodlist=[] for indx in range(Director.getSaveStringLength(plr, "mission_scripts")): script=Director.getSaveString(plr,"mission_scripts",indx) if script.find("#G#")!=-1: missiontype=script[3:script.find('#',3)] if missiontype in accepttypes: goodlist.append(indx) if len(goodlist)<nummissions: nummissions=len(goodlist) delit=[] for missionnum in range(0,nummissions): goodi=vsrandom.randrange(len(goodlist)) i=goodlist[goodi] which=guildname+'/'+str(missionnum) script=Director.getSaveString(plr,"mission_scripts",i) desc=Director.getSaveString(plr,"mission_descriptions",i) delit.append(i) last_constructor[which]=None last_args[which]=script last_briefing[0][which]=desc last_briefing[1][which]='' goodlist.pop(goodi) delit.sort() delit.reverse() for i in delit: Director.eraseSaveString(plr,"misson_scripts",i) Director.eraseSaveString(plr,"misson_descriptions",i) Director.eraseSaveString(plr,"misson_names",i) return nummissions
def RandomFlightgroup (faction): key = MakeFactionKey(faction) i = Director.getSaveStringLength(ccp,MakeFactionKey(faction)) if (i==0): return '' import vsrandom return Director.getSaveString(ccp,key,vsrandom.randrange(0,i))
def Check(self): import fg_util dead=not self.un if (not dead): dead = self.un.GetHull()<=0 if (dead): debug.debug("Uunit died") if (VS.systemInMemory (self.starsystem)): import dynamic_battle 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): import faction_ships dynamic_battle.rescuelist[self.starsystem]=(self.faction,"Shadow",faction_ships.get_enemy_of(self.faction)) debug.debug("friend in trouble") global dnewsman_ import dynamic_battle 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
def removeQuest(playernum, questname, value=1): print("removing quest") mylen = Director.getSaveDataLength(int(playernum), str(questname)) if (mylen > 0): Director.putSaveData(int(playernum), str(questname), 0, float(value)) else: Director.pushSaveData(int(playernum), str(questname), float(value))
class GameApp(): def __init__(self): self.director = Director() def run(self): self.director.loop() pygame.quit()
def interactWithJenek(ref="Root"): """Iterates the conversation, allowing for extra events to be launched during the conversation.""" if ref == "nojump" or ref == "rejectdrive": Director.eraseSaveData(VS.getPlayer().isPlayerStarship(),TRIGGER_SAVE,0) Director.pushSaveData(VS.getPlayer().isPlayerStarship(),TRIGGER_SAVE,REFUSED_VALUE) getJenekConversation().iterate(ref)
def writeDynamicString(self, varlist): """Stores a news story list into the \"dynamic news\" key in the save game.""" # debug.debug('Dynamic news Event') varlist = string.join([str(vsrandom.randrange(0,4194304))]+varlist,',') import Director Director.pushSaveString(0,"dynamic_news",varlist)
def _RemoveFGFromSystem (fgname,faction,starsystem): key = MakeStarSystemFactionFGKey(starsystem,faction) leg = Director.getSaveStringLength(ccp,key) for index in xrange(leg): if Director.getSaveString(ccp,key,index) == fgname: Director.eraseSaveString(ccp,key,index) break
def setCurrentNode(self,room,newnodenum): debug.warn('*** Going to branch number '+str(newnodenum)) import VS import Director plr = VS.getCurrentPlayer() if not self.checkPlayer(plr): return ["failure","player %d not initialized yet!"%plr] player = self.players[plr] if newnodenum>=0: if newnodenum>=len(player.current.subnodes): debug.debug('Error: cannot go to node '+str(newnodenum)) debug.debug('Failed node has text:') debug.debug(str(player.current.text)) return ["failure", "Attempt to go to an invalid subnode"] player.current=player.current.subnodes[newnodenum] player.savegame.append(newnodenum) Director.pushSaveData(VS.getCurrentPlayer(),self.name,float(newnodenum)) elif newnodenum==-2: if not player.current.contingency: debug.debug('Error: cannot go to contingency node!') debug.debug('Failed node has text:') debug.debug(str(player.current.text)) return ["failure", "Failed attempt to go to contingency"] debug.debug('*** Going to contingency!!!') player.current=player.current.contingency player.savegame.append(-2) Director.pushSaveData(VS.getCurrentPlayer(),self.name,float(-2)) if VS.isserver(): self.sendGotoMessage(newnodenum) if player.current.acceptClientInput() or not VS.networked(): if newnodenum != -1: player.current.evaluate(room) return ["success"]
def publishNews(text): # publishes the news text with star date player = VS.getPlayer().isPlayerStarship() STARDATE_TEXT = "\\\\\This story was first broadcast on: " datetext = stardate.formatStarDate("confed", VS.getStarTime()) newstext = "#" + text + STARDATE_TEXT + datetext + "\\GINA - Galactic Independent News Association" Director.pushSaveString(player, "dynamic_news", newstext)
def writeDynamicString(self, varlist): """Stores a news story list into the \"dynamic news\" key in the save game.""" varlist = string.join([str(vsrandom.randrange(0, 4194304))] + varlist, ',') import Director Director.pushSaveString(0, "dynamic_news", varlist)
def LookForTrouble (faction): global lftiter key = fg_util.MakeFactionKey(faction) numfg=Director.getSaveStringLength(fg_util.ccp,key) if (lftiter>=numfg): lftiter=0 if (0 and numfg): AddFighterTo(Director.getSaveString(fg_util.ccp,key,vsrandom.randrange(0,numfg)),faction,False) if faction in faction_ships.fighterProductionRate: AddFighterTo("Alpha",faction,True) return 0 i = Director.getSaveString(fg_util.ccp,key,lftiter) lftiter+=1 sys = fg_util.FGSystem (i,faction) citizen=VS.isCitizen(faction) if (sys!='nil'): if not citizen: enfac = faction_ships.get_enemy_of(faction) foundanyone=0 l=fg_util.AllFGsInSystem(enfac,sys) j=vsrandom.randrange(0,len(l)+3) if (j<len(l)): foundanyone=1 #FIXME include some sort of measure "can I win" if (vsrandom.randrange(0,5)==0): initiateAttack(i,faction,sys,l[j],enfac) elif (vsrandom.randrange(0,3)==0): randomMovement (i,faction) elif (vsrandom.randrange(0,3)==0): randomMovement (i,faction) return 1
def readPositionFromSavegame(self, savegamelist=None): import VS import Director plr=VS.getCurrentPlayer() self.InitPlayer(plr) player = self.players[plr] player.savegame=[] player.current=self.root if savegamelist: length=len(savegamelist) else: length=Director.getSaveDataLength(plr,self.name) for i in range(length): if savegamelist: newnodenum=int(savegamelist[i]) else: newnodenum=int(Director.getSaveData(plr,self.name,i)) if newnodenum>=0: if newnodenum>=len(player.current.subnodes): debug.debug(str(player.savegame)+': current has '+str(player.current.subnodes)) debug.warn('Error: save game index out of bounds: '+str(newnodenum)) return player.current=player.current.subnodes[newnodenum] elif newnodenum==-2: if not player.current.contingency: debug.debug(str(player.savegame)) debug.warn('Error: save game moves to invalid contengency node!') return player.current=player.current.contingency player.savegame.append(newnodenum) if VS.isserver(): custom.run("campaign", [self.name, "setsavegame"] + player.savegame, None) debug.debug('*** read position from save game: for '+self.name+': '+str(player.savegame)) debug.debug(player.current)
def RandomShipIn (fg,fac): key = MakeFGKey(fg,fac) len = Director.getSaveStringLength(ccp,key)-ShipListOffset() len = int(len/PerShipDataSize()) if (len>0): return Director.getSaveString(ccp,key,ShipListOffset()+PerShipDataSize()*vsrandom.randrange(0,len)) return ''
def LaunchLandShip(fgname,faction,typ,numlaunched=1): key = MakeFGKey (fgname,faction) ships=ReadStringList (ccp,key) debug.debug('LaunchLandShip: fg:%s fac:%s typ:%s, num:%s', fgname, faction, typ, numlaunched) for num in xrange (ShipListOffset(),len(ships),PerShipDataSize()): if (typ == ships[num]): try: ntobegin=int(ships[num+1]) nactive=int(ships[num+2]) debug.debug("attempting launch for ship %s, begin %s, act %s)", typ, ntobegin, nactive) nactive-=numlaunched # Happens regularly -Patrick # In the first system, nactive seems to always be 0 for all ships. # In other systems, this isn't always true. # This doesn't really seem to matter, though. # Klauss: turned debug.error into debug.debug if it happens so often # to clean up non-debug logs if (nactive<0): nactive=0 debug.debug('error more ships launched than in FG %s', fgname) if (nactive>ntobegin): nactive=ntobegin debug.debug('error ships %s landed that never launched', typ) Director.putSaveString(ccp,key,num+2,str(nactive)) except: debug.error('error in FG data (str->int)')
def exploremission(part,filename,sysfile,creditnum): fixers.DestroyActiveButtons () if part==1: plyr=VS.getPlayer().isPlayerStarship() if quest.findQuest(plyr,(sysfile+"_nav"),1) or quest.findQuest(plyr,(sysfile+"_nav"),2): part=3 if part==1: fixers.CreateChoiceButtons(Base.GetCurRoom(),[ fixers.Choice("bases/fixers/yes.spr",filename,"Accept This Mission"), fixers.Choice("bases/fixers/no.spr","bases/fixers/no.py","Decline This Mission")]) Base.Message("""Hi. Our researchers have found a new signal similar to that of a jump point coming from an area in the #55ffff%s#000000 system. This mission will require that you own a jump drive. We hope that you will accept this mission. You will earn %.2f credits when you explore the area."""%(sysfile.split('/')[-1],creditnum)) elif part==2: Base.Message("""Excellent! Go to the unknown energy source that we have uploaded to your ship computer as a navpoint in #55ffff%s#000000. Once next to the energy source, jump into the energy source and get close to all of the planets in the connecting system."""%sysfile.split('/')[-1]) Base.EnqueueMessage("""You will earn %.2f credits when this is completed"""%creditnum) plyr=VS.getPlayer().isPlayerStarship() if Director.getSaveDataLength(plyr,(sysfile+"_nav"))==0: Director.pushSaveData(plyr,(sysfile+"_nav"),1) else: Director.putSaveData(plyr,(sysfile+"_nav"),0,1) else: Base.Message("""Go to the unknown energy source that we have uploaded to your ship computer as a navpoint in #55ffff%s#000000. Once next to the energy source, jump into the energy source and get close to all of the planets in the connecting system."""%sysfile.split('/')[-1])
def __init__(self): self.playa = VS.getPlayer() self.jps = list() self.refreshJumpPoints() Director.eraseSaveData(self.playa.isPlayerStarship(), TRIGGER_SAVE, 0) Director.pushSaveData(self.playa.isPlayerStarship(), TRIGGER_SAVE, DEFAULT_VALUE)
def CreateGuildMissions(guildname, nummissions, accepttypes): plr = VS.getPlayer().isPlayerStarship() goodlist = [] for indx in range(Director.getSaveStringLength(plr, "mission_scripts")): script = Director.getSaveString(plr, "mission_scripts", indx) if script.find("#G#") != -1: missiontype = script[3:script.find('#', 3)] if missiontype in accepttypes: goodlist.append(indx) if len(goodlist) < nummissions: nummissions = len(goodlist) delit = [] for missionnum in range(0, nummissions): goodi = vsrandom.randrange(len(goodlist)) i = goodlist[goodi] which = guildname + '/' + str(missionnum) script = Director.getSaveString(plr, "mission_scripts", i) desc = Director.getSaveString(plr, "mission_descriptions", i) delit.append(i) last_constructor[which] = None last_args[which] = script last_briefing[0][which] = desc last_briefing[1][which] = '' goodlist.pop(goodi) delit.sort() delit.reverse() for i in delit: Director.eraseSaveString(plr, "misson_scripts", i) Director.eraseSaveString(plr, "misson_descriptions", i) Director.eraseSaveString(plr, "misson_names", i) return nummissions
def __call__(self,room,subnodes): Script.__call__(self,room,subnodes) import Director import VS cp=VS.getCurrentPlayer() key=self.faction+"_relation_stack" Director.pushSaveData(cp,key,VS.GetRelation(self.faction,"privateer"))
def __init__ (self,you, numsystemsaway,jumps=(),preffaction=''): self.arrivedsys=0 self.jumps=() self.destination="" self.obj=0 self.com=0 self.you = you sys=VS.getSystemFile() if len(jumps)>0: sys=jumps[-1] (self.destination,self.jumps)=universe.getAdjacentSystems(sys,numsystemsaway,jumps,preffaction) for i in self.jumps: key = "visited_"+i leng=Director.getSaveDataLength(VS.getCurrentPlayer(),key) if leng==0: Director.pushSaveData(VS.getCurrentPlayer(),key,float(2)) if (len(self.jumps)>0): self.obj=VS.addObjective("") self.com=(1.0/float(len(self.jumps))) VS.setCompleteness(self.obj,0) if (self.you): VS.setOwner(self.obj,self.you) self.ChangeObjective(0) else: self.arrivedsys=1
def __init__(self, you, numsystemsaway, jumps=(), preffaction=''): self.arrivedsys = 0 self.jumps = () self.destination = "" self.obj = 0 self.com = 0 self.you = you sys = VS.getSystemFile() if len(jumps) > 0: sys = jumps[-1] (self.destination, self.jumps) = universe.getAdjacentSystems(sys, numsystemsaway, jumps, preffaction) for i in self.jumps: key = "visited_" + i leng = Director.getSaveDataLength(VS.getCurrentPlayer(), key) if leng == 0: Director.pushSaveData(VS.getCurrentPlayer(), key, float(2)) if (len(self.jumps) > 0): self.obj = VS.addObjective("") self.com = (1.0 / float(len(self.jumps))) VS.setCompleteness(self.obj, 0) if (self.you): VS.setOwner(self.obj, self.you) self.ChangeObjective(0) else: self.arrivedsys = 1
def CapshipInFG(fg,fac): key = MakeFGKey(fg,fac) for num in xrange(ShipListOffset(),Director.getSaveStringLength(ccp,key),PerShipDataSize()): import faction_ships shipinquestion=Director.getSaveString(ccp,key,num) if (faction_ships.isCapital(shipinquestion)): return shipinquestion return None
def TransferFG (fgname,faction,tosys): key = MakeFGKey(fgname,faction) len = Director.getSaveStringLength(ccp,key) if (len>1): starsystem=Director.getSaveString(ccp,key,1) _RemoveFGFromSystem(fgname,faction,starsystem) _AddFGToSystem(fgname,faction,tosys) Director.putSaveString(ccp,key,1,tosys)
def DeleteFG(fgname,faction): key = MakeFGKey (fgname,faction) len = Director.getSaveStringLength (ccp,key) if (len>=ShipListOffset()): starsystem=Director.getSaveString(ccp,key,1) _RemoveFGFromSystem(fgname,faction,starsystem) _RemoveFGFromFactionList(fgname,faction) WriteStringList (ccp,MakeFGKey(fgname,faction),[] )
def DeleteFG(fgname, faction): key = MakeFGKey(fgname, faction) len = Director.getSaveStringLength(ccp, key) if (len >= ShipListOffset()): starsystem = Director.getSaveString(ccp, key, 1) _RemoveFGFromSystem(fgname, faction, starsystem) _RemoveFGFromFactionList(fgname, faction) WriteStringList(ccp, MakeFGKey(fgname, faction), [])
def FGSystem (fgname,faction): key = MakeFGKey(fgname,faction) len = Director.getSaveStringLength(ccp,key) if (len>1): return Director.getSaveString(ccp,key,1) else: debug.debug('%r for %r already died, in no system', fgname, faction) return 'nil'
def _RemoveFGFromFactionList (fgname,faction): key = MakeFactionKey(faction) lun=Director.getSaveStringLength(ccp,key) for i in range (lun): if (Director.getSaveString(ccp,key,i)==fgname): Director.eraseSaveString(ccp,key,i) return 1 return 0
def FGSystem (fgname,faction): key = MakeFGKey(fgname,faction) len = Director.getSaveStringLength(ccp,key) if (len>1): return Director.getSaveString(ccp,key,1) else: #print fgname+' for '+faction+' already died, in no system' return 'nil'
def incSaveValue(playernum,name): import Director mylen = Director.getSaveDataLength(int(playernum),str(name)) val=0 if (mylen>0): val=Director.getSaveData(int(playernum),str(name),mylen-1) val+=1 setSaveValue(playernum,name,val)
def _RemoveFGFromFactionList(fgname, faction): key = MakeFactionKey(faction) lun = Director.getSaveStringLength(ccp, key) for i in range(lun): if (Director.getSaveString(ccp, key, i) == fgname): Director.eraseSaveString(ccp, key, i) return 1 return 0
def getCFixerIndex(playernum, name): mylen=Director.getSaveStringLength(int(playernum),"CFixers") index = -1 for i in range(mylen): if name == Director.getSaveString(playernum,"CFixers",i).split('|')[0]: index = i break return index
def __call__(self,room,subnodes): Script.__call__(self,room,subnodes) import Director import VS if VS.networked(): return True cp=VS.getCurrentPlayer() Director.pushSaveString(cp,"dynamic_news",'#'+self.story)
def get_relations_text(player): str_relations = "Cash: %s\n\nKill breakdown:\n" % (int( player.getCredits())) # length of faction_kills = VS.GetNumFactions() + 1 # could the last entry be the total? or maybe the number of times the user has died? faction_kills = [] for i in range(Director.getSaveDataLength(VS.getCurrentPlayer(), 'kills')): faction_kills.append( Director.getSaveData(VS.getCurrentPlayer(), 'kills', i)) displayed_factions = [ 'confed', 'kilrathi', 'merchant', 'retro', 'pirates', 'hunter', 'militia' ] for i in range(VS.GetNumFactions()): # VS.GetFactionIndex(s) expects a string # VS.GetFactionIndex(s) expects a name faction = VS.GetFactionName(i) if faction in displayed_factions: # note: the following calls do not always return equal values: # VS.GetRelation(a, b) # VS.GetRelation(b, a) relation = int( VS.GetRelation(faction, player.getFactionName()) * 100) if relation > 100: relation = 100 elif relation < -100: relation = -100 # not sure if the AI or Friend/Foe radar agree with these figures, but this ought to work, mostly if relation > 20: str_relation = "friendly" elif relation < -20: str_relation = "hostile" else: str_relation = "neutral" try: kills = int(faction_kills[i]) except: kills = 0 # try to pad the columns # (this doesn't work perfectly, since we're using a variable-width font) str_pad = " " int_pad_len = len(str_pad) - len(str(kills)) if int_pad_len < 1: str_pad = "" else: str_pad = str_pad[:int_pad_len] # add current faction to the output string str_relations = str_relations + "%s%s %s\t(%s: %s)\n" % ( str_pad, kills, faction.capitalize(), str_relation, relation) return str_relations
def eraseNewsItem(plr,item): """removes the first news item matching the given item from plr's "dynamic_news" save variable""" # debug.debug("FIXME: someone please write a function to this spec! Every thing I try seems to produce some random result :-/") for i in range (Director.getSaveStringLength(plr,"dynamic_news")): noos=Director.getSaveString(plr,"dynamic_news",i) if noos == item: Director.eraseSaveString(plr,"dynamic_news",i) return
def __call__(self,room,subnodes): Script.__call__(self,room,subnodes) import Director import VS cp=VS.getCurrentPlayer() key=self.faction+"_relation_stack" length=Director.getSaveDataLength(cp,key) ClearFactionRecord(self.faction,Director.getSaveData(cp,key,length-1))(room,subnodes) Director.eraseSaveData(cp,key,length-1);
def writemissionname(name, path, isfixer): if (isfixer == 0): if path[-1] == VS.getSystemFile(): name = "In_System_" + name global insysMissionNumber insysMissionNumber += 1 else: global totalMissionNumber totalMissionNumber += 1 Director.pushSaveString(plr, "mission_names", name)
def checkSaveValue(playernum, questname, value=1): mylen = Director.getSaveDataLength(playernum, questname) # print mylen if (mylen > 0): myfloat = Director.getSaveData(playernum, questname, 0) else: myfloat = 0 if (myfloat == value): return 1 return 0
def StartMission(self, lastsector, cursector, mission): debug.info("current sector:" + cursector) save_util.saveStringList(0, "wc1sector", (cursector, )) if (Director.getSaveDataLength(0, "wc1mission") > 0): Director.putSaveData(0, "wc1mission", 0, mission) else: Director.pushSaveData(0, "wc1mission", mission) self.wfm = cursector if (lastsector != cursector): self.JumpTo(cursector)
def checkSaveValue(playernum,questname,value=1): mylen=Director.getSaveDataLength(playernum,questname) debug.debug("mylen: %d" % (mylen)) if (mylen>0): myfloat=Director.getSaveData(playernum,questname,0) else: myfloat=0 if (myfloat==value): return 1 return 0
def NumShipsInFG (fgname,faction): key = MakeFGKey (fgname,faction) len = Director.getSaveStringLength (ccp,key) if (len==0): return 0 else: try: return int(Director.getSaveString(ccp,key,0)) except: debug.debug("fatal: flightgroup without size") return 0
def GetDamageInFGPool (fgname,faction): key = MakeFGKey (fgname,faction) len = Director.getSaveStringLength (ccp,key) if (len<3): return 0 else: try: return int(Director.getSaveString(ccp,key,2)) except: debug.debug("nonfatal: flightgroup without size") return 0