def getPriceModifier(isUncapped): import difficulty if (not difficulty.usingDifficulty()): return 1.0 if (isUncapped): return getMissionDifficulty() / .5 + .9 return VS.GetDifficulty() / .5 + .9
def launch(fgname, faction, type, ai, nr_ships, nr_waves, vec, logo='', useani=1): debug.debug("fgname: %s, faction %s" % (fgname, faction)) debug.debug("type: %s" % (type)) debug.debug("ai: %s, nr_ships: %d, nr_waves: %d" % (ai, nr_ships, nr_waves)) debug.debug("vec: %s, logo: %s, useani: %d" % (vec, logo, useani)) #debug.debug('log'+ str( logo) + ' useani '+ str(useani)) use_diff = usingDifficulty() # if useani: # VS.playAnimation ("warp.ani",vec,300.0) if isinstance(type, list) or isinstance(type, tuple): debug.debug("inside isinstance conditional (type is list or tuple)") for t in type: if t.endswith(".blank"): isblank = True break else: isblank = type.endswith(".blank") debug.debug("isblank = %s" % (isblank)) # originally, this was # if (not diff or not isblank) # which effectively always ignored isblank, since diff is almost never false if (not isblank): debug.info("Launching non-blank ship(s)") ret = VS.launch(fgname, type, faction, "unit", ai, nr_ships, nr_waves, VS.SafeEntrancePoint(vec, 40), logo) ship_upgrades.adjust_upgrades(ret) dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE) else: # only upgrade blank ships (for now) debug.info("Launching blank ship(s)") rsize = 0.0 diffic = VS.GetDifficulty() #debug.debug("VS.Unit #1") ret = VS.Unit() for i in range(nr_ships): mynew = VS.launch(fgname, type, faction, "unit", ai, 1, nr_waves, VS.SafeEntrancePoint(vec, 40), logo) if (i == 0): ret = mynew rsize = mynew.rSize() * 1.75 debug.debug("upgradeUnit '%s' using difficulty %.2f ..." % (mynew.getName(), float(diffic))) ship_upgrades.upgradeUnit(mynew, diffic) debug.debug( "'- Done upgrading unit '%s' using difficulty %.2f ..." % (mynew.getName(), float(diffic))) vec = ( vec[0] - rsize, vec[1], #-rsize vec[2] - rsize) dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE) return ret
def DefaultNumShips(): import vsrandom diff=VS.GetDifficulty() if (diff>.9): return vsrandom.randrange(1,5) if (diff>.5): return vsrandom.randrange(1,4) if (diff>.2): return vsrandom.randrange(1,3) if (vsrandom.randrange(0,4)==0): return 2 return 1
def DefaultNumShips(): """Get number of (opponent) ships to launch based on the difficulty level.""" diff = VS.GetDifficulty() if (diff > .9): return vsrandom.randrange(1, 5) if (diff > .5): return vsrandom.randrange(1, 4) if (diff > .2): return vsrandom.randrange(1, 3) if (vsrandom.randrange(0, 4) == 0): return 2 return 1
def __init__(self,credsMax): # print "init diff" global unbounddiff self.diff=[] unbounddiff=[] self.creds=[] self.credsToMax=credsMax # print "unlogical start" un=VS.getPlayerX(0) # print "unlogical end" self.i=0 while (not un.isNull()): newunbounddiff=0 newdiff=0 # print "get save data length" # (open ("/tmp/vswroteship","w")).close() diffsavelen=Director.getSaveDataLength(self.i,_key) if (diffsavelen): # (open ("/tmp/vsgotdata","w")).close() # print "get save dat" newdiff=Director.getSaveData(self.i,_key,0) if (diffsavelen>1): newunbounddiff=Director.getSaveData(self.i,_key,1) else: newunbounddiff=newdiff Director.pushSaveData(self.i,_key,newunbounddiff) # print "get save end" else: # (open ("/tmp/vsmakedata","w")).close() # print "get difficulty start" newdiff=VS.GetDifficulty() # print "get diff done" Director.pushSaveData(self.i,_key,newdiff) newunbounddiff=newdiff Director.pushSaveData(self.i,_key,newunbounddiff) # print "done director" # (open ("/tmp/vsdonedir","w")).close() # (open ("/tmp/vssetdifficulty","w")).close() self.diff.append(newdiff) unbounddiff.append(newunbounddiff) # print "set diff start" SetDiff(newdiff) # print "set diff end" self.creds+=[un.getCredits()] self.i+=1 # print "save unit" un=VS.getPlayerX(self.i)
def launch(fgname, faction, type, ai, nr_ships, nr_waves, vec, logo='', useani=1, skipdj=0): # print 'log'+ str( logo) + ' useani '+ str(useani) diff = usingDifficulty() # if useani: # VS.playAnimation ("warp.ani",vec,300.0) if (not diff or (type.find(".blank") == -1 and -1 == type.find(".stock"))): for i in range(nr_ships): ret = VS.launch(fgname, type, faction, "unit", ai, 1, nr_waves, VS.SafeEntrancePoint(vec, 40), logo) unit.moveOutOfPlayerPath(ret) if (not skipdj): dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE) return ret rsize = 0.0 diffic = VS.GetDifficulty() ret = VS.Unit() for i in range(nr_ships): mynew = VS.launch(fgname, type, faction, "unit", ai, 1, nr_waves, VS.SafeEntrancePoint(vec, 40), logo) unit.moveOutOfPlayerPath(mynew) if (i == 0): ret = mynew rsize = mynew.rSize() * 1.75 ship_upgrades.upgradeUnit(mynew, diffic) vec = ( vec[0] - rsize, vec[1], #-rsize vec[2] - rsize) if (not skipdj): dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE) return ret
def usingDifficulty (self): return (VS.GetDifficulty()!=1.0)
def SetDiff(diff): if (diff>VS.GetDifficulty()): VS.SetDifficulty(diff)
def adjustQuantityDifficulty(max): return 3 + int((max - 3) * VS.GetDifficulty())