def OnServerInitComplete(self): if ((not len(PtGetPlayerList())) and xxConfig.isOnline()): dnitime = PtGetDniTime() month = int(time.strftime('%m', time.gmtime(dnitime))) winter = [1, 2, 12] summer = [6, 7, 8] if (month in winter): chance = xRandom.randint(70, 90) elif (month in summer): chance = xRandom.randint(10, 30) else: chance = xRandom.randint(40, 60) cur_chance = xRandom.randint(0, 100) snow = 0 if (cur_chance <= chance): snow = 1 ageSDL = PtGetAgeSDL() cur_snow = ageSDL['dlnWinterVis'][0] print ('EderDelin.OnServerInitComplete(): month = %d, chance value = %d, chance roll = %d, snow = %d, current snow = %d' % (month, chance, cur_chance, snow, cur_snow)) if (cur_snow != snow): ageSDL['dlnWinterVis'] = (snow,)
def OnTimer(self, id): PtDebugPrint(('%s: OnTimer: object = %s' % (self.me, self.sceneobject.getName()))) if (id == kTimerID): if boolRepeat.value: fluTime = intFluctuate.value if (fluTime > intTime.value): fluTime = intTime.value minTime = (intTime.value - fluTime) maxTime = (intTime.value + fluTime) newTime = xRandom.randint(minTime, maxTime) print (' - New interval for timer = %d' % newTime) PtAtTimeCallback(self.key, newTime, kTimerID) if (getSDL and (SDLvalue != intRunState.value)): print (' - SDL value %d does not match, abort chance roll' % SDLvalue) return cur_chance = xRandom.randint(0, 100) print (' - Chance value = %d, Local chance roll = %d' % (intChance.value, cur_chance)) if (cur_chance <= intChance.value): # Responders are netpropagated by default which means that every player will see/hear them. # We want the responder to be in synch for all players but letting everyone run them messes # up the chance rolls. So only one player must run the responder! # This should be the game owner, whom we can find with: self.sceneobject.isLocallyOwned() # If we are not repeating the event though, everyone who links in should be able to run it. if (self.sceneobject.isLocallyOwned() or (not boolRepeat.value)): print (' - Running responder from %s' % self.sceneobject.getName()) respRandom.run(self.key)
def OnServerInitComplete(self): xRandom.seed((PtGetDniTime() % 256)) x = 1 for resp in RespFishPaths: randPath = xRandom.randint(0, (len(listPaths) - 1)) initPath = listPaths[randPath] print 'lakiCreatures.OnAgeDataInitialized(): fish #', print x, print ' starts with path: ', print initPath resp.run(self.key, state=('%s' % initPath)) x += 1 x = 1 for fish in RespFishBehs: randBeh = xRandom.randint(0, (len(listBehs) - 1)) initBeh = listBehs[randBeh] print 'lakiCreatures.OnAgeDataInitialized(): fish #', print x, print ' starts with beh: ', print initBeh fish.run(self.key, state=('%s' % initBeh)) x += 1 # force the bird over the network, to make sure it's ok to everyone soBird.value.netForce(1)
def IPickEderGlass(self,eder): print "nb01EmgrPhase0.IPickEderGlass()" newGlass = 0 if eder == 2: newGlass = xRandom.randint(1,3) elif eder == 3: newGlass = xRandom.randint(4,6) ageSDL = PtGetAgeSDL() ageSDL[sdlEderGlass] = (newGlass, )
def CreateBahroCaveSolution(self): bahroSolList = [3,2,5,0] cleftSolList = [3,2,5,0] while self.AreListsEquiv(bahroSolList, cleftSolList): bahroSolList = [] while len(bahroSolList) < 4: newint = xRandom.randint(0,6) if not newint in bahroSolList: bahroSolList.append(newint) vault = ptVault() entry = vault.findChronicleEntry("BahroCave") if entry is None: #PtDebugPrint("DEBUG: psnlBahroPoles.OnServerInitComplete: Did not find BahroCave chronicle...creating") vault.addChronicleEntry("BahroCave",0,"0") agelist = ["Teledahn", "Garden", "Garrison", "Kadish"] PtDebugPrint("creating BahroCave solution in the chronicle...") for v in range(len(agelist)): newnode = ptVaultChronicleNode(0) newnode.chronicleSetName(agelist[v]) newnode.chronicleSetValue("0," + str(bahroSolList[v]) + ",0") entry = vault.findChronicleEntry("BahroCave") entry.addNode(newnode) PtDebugPrint("new bahro cave solution = ",self.GetBahroCaveSolution())
def IDoScores(self): if self._pellet < 0: self._kiPoints = 0 self._lakePoints = (self._pellet/5) if self._lakePoints < -70: self._lakePoints = -70 elif self._pellet > 200: self._kiPoints = (self._pellet - ((self._pellet-200) * 4)) self._lakePoints = (self._pellet - ((self._pellet-200) * 4)) if self._kiPoints < 0: self._kiPoints = 0 if self._lakePoints < -200: self._lakePoints = -200 else: self._kiPoints = self._pellet self._lakePoints = self._pellet self._kiPoints = int(round(self._kiPoints * ((xRandom.randint(1,25) / 100.0) + 4.75))) self._lakePoints = int(round(self._lakePoints)) print "ErcanaCitySilo.IDoScores(): this pellet drop is worth %d KI points!" % (self._kiPoints) print "ErcanaCitySilo.IDoScores(): and %d lake points!" % (self._lakePoints) # Try to find the needed scores... # The magic will happen in OnGameScoreMsg() ptGameScore.findPlayerScores(kPlayerDropScore, self.key) ptGameScore.findPlayerScores(kPlayerTotalScore, self.key) ptGameScore.findGlobalScores(kGlobalScore, self.key)
def IDoScores(self): if self._pellet < 0: self._kiPoints = 0 self._lakePoints = (self._pellet / 5) if self._lakePoints < -70: self._lakePoints = -70 elif self._pellet > 200: self._kiPoints = (self._pellet - ((self._pellet - 200) * 4)) self._lakePoints = (self._pellet - ((self._pellet - 200) * 4)) if self._kiPoints < 0: self._kiPoints = 0 if self._lakePoints < -200: self._lakePoints = -200 else: self._kiPoints = self._pellet self._lakePoints = self._pellet self._kiPoints = int( round(self._kiPoints * ((xRandom.randint(1, 25) / 100.0) + 4.75))) self._lakePoints = int(round(self._lakePoints)) PtDebugPrint( "ErcanaCitySilo.IDoScores(): this pellet drop is worth %d KI points!" % (self._kiPoints)) PtDebugPrint("ErcanaCitySilo.IDoScores(): and %d lake points!" % (self._lakePoints)) # Try to find the needed scores... # The magic will happen in OnGameScoreMsg() ptGameScore.findPlayerScores(kPlayerDropScore, self.key) ptGameScore.findPlayerScores(kPlayerTotalScore, self.key) ptGameScore.findGlobalScores(kGlobalScore, self.key)
def CreateBahroCaveSolution(self): bahroSolList = [3,2,5,0] cleftSolList = [3,2,5,0] while self.AreListsEquiv(bahroSolList, cleftSolList): bahroSolList = [] while len(bahroSolList) < 4: newint = xRandom.randint(0,6) if not newint in bahroSolList: bahroSolList.append(newint) vault = ptVault() entry = vault.findChronicleEntry("BahroCave") if type(entry) == type(None): #PtDebugPrint("DEBUG: psnlBahroPoles.OnServerInitComplete: Did not find BahroCave chronicle...creating") vault.addChronicleEntry("BahroCave",0,"0") agelist = ["Teledahn", "Garden", "Garrison", "Kadish"] print "creating BahroCave solution in the chronicle..." for v in range(len(agelist)): newnode = ptVaultChronicleNode(0) newnode.chronicleSetName(agelist[v]) newnode.chronicleSetValue("0," + str(bahroSolList[v]) + ",0") entry = vault.findChronicleEntry("BahroCave") entry.addNode(newnode) print "new bahro cave solution = ",self.GetBahroCaveSolution()
def GenerateCleftSolution(args): import Plasma import xRandom solutionlist = [3,2,5,0] cleftSolList = [3,2,5,0] while _AreListsEquiv(solutionlist, cleftSolList): solutionlist = [] while len(solutionlist) < 4: newint = xRandom.randint(0,6) if not newint in solutionlist: solutionlist.append(newint) vault = Plasma.ptVault() entry = vault.findChronicleEntry("BahroCave") entry.removeAllNodes() if entry != None: agelist = ["Teledahn", "Garrison", "Garden", "Kadish"] for v in range(len(agelist)): newnode = Plasma.ptVaultChronicleNode(0) newnode.chronicleSetName(agelist[v]) ageVal = str(solutionlist[v]) newnode.chronicleSetValue("1," + ageVal + "," + str(v + 1)) #newnode.chronicleSetValue("1," + str(solutionlist[v]) + "," + str(v + 1)) entry.addNode(newnode) print "%s solution is %s" % (agelist[v], ageVal)
def OnServerInitComplete(self): ageSDL = PtGetAgeSDL() ageSDL.setFlags(strVarName.value,1,1) ageSDL.sendToClients(strVarName.value) ageSDL.setFlags(strProximityVar.value,1,1) ageSDL.sendToClients(strProximityVar.value) try: ageSDL.setNotify(self.key,strEnabledVar.value,0.0) except: PtDebugPrint("ERROR: xRandomBoolChange.OnServerInitComplete():\tERROR accessing ageSDL on %s" % self.sceneobject.getName()) return try: visible = ageSDL[strVarName.value][0] enabled = ageSDL[strEnabledVar.value][0] chance = ageSDL[strChanceVar.value][0] except: PtDebugPrint("ERROR: xRandomBoolChange.OnServerInitComplete():\tERROR accessing ageSDL on %s. Using default." % self.sceneobject.getName()) visible = boolDefault.value enabled = boolDefault.value chance = boolDefault.value PtDebugPrint("xRandomBoolChange.OnServerInitComplete():\t attached to sceneobject: %s" % self.sceneobject.getName()) PtDebugPrint("xRandomBoolChange.OnServerInitComplete():\t SDL for proximity var: %s" % strProximityVar.value) try: nearby = ageSDL[strProximityVar.value][0] # if I'm the only one in here then make sure the proximity setting is 0 if len(PtGetPlayerList()) == 0 and nearby: ageSDL[strProximityVar.value] = (0,) nearby = 0 except: PtDebugPrint("ERROR: xRandomBoolChange.OnServerInitComplete():\tERROR accessing nearby ageSDL on %s. Using default." % self.sceneobject.getName()) nearby = 0 print "RandomBoolChange script on object " + self.sceneobject.getName() print "Visible:" + str(visible) print "Enabled:" + str(enabled) print "Chance :" + str(chance) print "Nearby :" + str(nearby) # check if the object is enabled if enabled: if not nearby: rint = xRandom.randint(0, 100) print "Random int:" + str(rint) if rint <= chance: # we passed so take appropriate action if visible: print "Passed! Setting variable to 0" ageSDL[strVarName.value] = (0,) else: print "Passed! Setting variable to 1" ageSDL[strVarName.value] = (1,) else: if visible: print "Object not enabled, turning off" ageSDL[strVarName.value] = (0,)
def CreatePelletCaveSolution(self): PtDebugPrint("psnlBahroPoles.CreatePelletCaveSolution(): creating pellet cave solution...") bahroSolList = self.GetBahroCaveSolution() cleftSolList = [3,2,5,0] pelletSolList = [3,2,5,0] while self.AreListsEquiv(pelletSolList, cleftSolList) or self.AreListsEquiv(pelletSolList, bahroSolList): pelletSolList = [] while len(pelletSolList) < 4: newint = xRandom.randint(0,6) if not newint in pelletSolList: pelletSolList.append(newint) PtDebugPrint("pellet cave solution = ",pelletSolList) return pelletSolList
def OnTimer(self, id): ageSDL = PtGetAgeSDL() if id == TimerID.TurnOn: try: chanceval = ageSDL[ScreamChanceVar][0] cur_chance = xRandom.randint(0, 100) print "RandomBahroScream: Chance val - %d, Cur Chance - %d" % (chanceval, cur_chance) if cur_chance <= chanceval: # turn on print "RandomBahroScream: turning on" respScream.run(self.key) except: print "RandomBahroScream: could not find SDL for %s in %s" % (ScreamChanceVar,AgeStartedIn) PtAtTimeCallback(self.key, 600, TimerID.TurnOn)
def OnTimer(self, id): ageSDL = PtGetAgeSDL() if id == TimerID.TurnOn: try: chanceval = ageSDL[ScreamChanceVar][0] cur_chance = xRandom.randint(0, 100) PtDebugPrint("RandomBahroScream: Chance val - %d, Cur Chance - %d" % (chanceval, cur_chance)) if cur_chance <= chanceval: # turn on PtDebugPrint("RandomBahroScream: turning on") respScream.run(self.key) except: PtDebugPrint("RandomBahroScream: could not find SDL for %s in %s" % (ScreamChanceVar,AgeStartedIn)) PtAtTimeCallback(self.key, 600, TimerID.TurnOn)
def CreatePelletCaveSolution(self): print "psnlBahroPoles.CreatePelletCaveSolution(): creating pellet cave solution..." bahroSolList = self.GetBahroCaveSolution() cleftSolList = [3,2,5,0] pelletSolList = [3,2,5,0] while self.AreListsEquiv(pelletSolList, cleftSolList) or self.AreListsEquiv(pelletSolList, bahroSolList): pelletSolList = [] while len(pelletSolList) < 4: newint = xRandom.randint(0,6) if not newint in pelletSolList: pelletSolList.append(newint) print "pellet cave solution = ",pelletSolList return pelletSolList
def OnTimer(self, id): global hairColor # are we trying to enable item? if id == kEnableClothingTimer: self.IEnableClothing() # we need to grab the hair color elif id == kGetHairColorTimer: hairColor = self.IGetHairColor() # we need to roll dice to show the object elif id == kRollDiceTimer: rint = xRandom.randint(1, 100) PtDebugPrint("DEBUG: xTakableClothing.OnTimer(): Rolled a %d against a DC of %d on %s, success on <=" % (rint,self.chanceAppearing,self.sceneobject.getName())) if rint <= self.chanceAppearing: ageSDL = PtGetAgeSDL() # show the object ageSDL[stringVarName.value] = (boolShowOnTrue.value, ) self.IEnableClothing()
def OnTimer(self, id): global hairColor if (id == kEnableClothingTimer): self.IEnableClothing() elif (id == kDisableClothingTimer): self.IDisableClothing() elif (id == kGetHairColorTimer): hairColor = self.IGetHairColor() elif (id == kRollDiceTimer): rint = xRandom.randint(1, 100) PtDebugPrint(( 'DEBUG: xTakableClothing.OnTimer(): Rolled a %d against a DC of %d on %s, success on <=' % (rint, self.chanceAppearing, self.sceneobject.getName()))) if (rint <= self.chanceAppearing): ageSDL = PtGetAgeSDL() ageSDL[stringVarName.value] = (boolShowOnTrue.value, ) self.IEnableClothing()
def CreateSolution(self): solutionlist = [3, 2, 5, 0] cleftSolList = [3, 2, 5, 0] while self.AreListsEquiv(solutionlist, cleftSolList): solutionlist = [] while (len(solutionlist) < 4): newint = xRandom.randint(0, 6) if (not ((newint in solutionlist))): solutionlist.append(newint) vault = ptVault() entry = vault.findChronicleEntry('BahroCave') if (entry != None): agelist = ['Teledahn', 'Garrison', 'Garden', 'Kadish'] for v in range(len(agelist)): newnode = ptVaultChronicleNode(0) newnode.chronicleSetName(agelist[v]) newnode.chronicleSetValue((('0,' + str(solutionlist[v])) + ',0')) entry.addNode(newnode)
def OnTimer(self, id): global hairColor # are we trying to enable or disable the item? if id == kEnableClothingTimer: self.IEnableClothing() elif id == kDisableClothingTimer: self.IDisableClothing() # we need to grab the hair color elif id == kGetHairColorTimer: hairColor = self.IGetHairColor() # we need to roll dice to show the object elif id == kRollDiceTimer: rint = xRandom.randint(1, 100) PtDebugPrint("DEBUG: xTakableClothing.OnTimer(): Rolled a %d against a DC of %d on %s, success on <=" % (rint,self.chanceAppearing,self.sceneobject.getName())) if rint <= self.chanceAppearing: ageSDL = PtGetAgeSDL() # show the object ageSDL[stringVarName.value] = (boolShowOnTrue.value, ) self.IEnableClothing()
def OnServerInitComplete(self): global byteEderToggle global byteEderGlass global byteGZGlass if AgeStartedIn == PtGetAgeName(): ageSDL = PtGetAgeSDL() ageSDL.setFlags(sdlEderToggle, 1, 1) ageSDL.sendToClients(sdlEderToggle) ageSDL.setNotify(self.key, sdlEderToggle, 0.0) byteEderToggle = ageSDL[sdlEderToggle][0] print "nb01EmgrPhase0.OnServerInitComplete(): byteEderToggle = ", byteEderToggle ageSDL.setFlags(sdlEderGlass, 1, 1) ageSDL.sendToClients(sdlEderGlass) ageSDL.setNotify(self.key, sdlEderGlass, 0.0) byteEderGlass = ageSDL[sdlEderGlass][0] print "nb01EmgrPhase0.OnServerInitComplete(): byteEderGlass = ", byteEderGlass ageSDL.setFlags(sdlGZGlass, 1, 1) ageSDL.sendToClients(sdlGZGlass) ageSDL.setNotify(self.key, sdlGZGlass, 0.0) byteGZGlass = ageSDL[sdlGZGlass][0] print "nb01EmgrPhase0.OnServerInitComplete(): byteGZGlass = ", byteGZGlass if self.sceneobject.isLocallyOwned(): print "nb01EmgrPhase0.OnServerInitComplete(): will check the Eder Delin/Tsogal book and its stained glass..." self.IManageEders() if (byteGZGlass > numGZGlasses) and self.sceneobject.isLocallyOwned(): newGlass = xRandom.randint(1, numGZGlasses) print "nb01EmgrPhase0.OnServerInitComplete(): GZ stained glass randomly picked to be #: ", newGlass ageSDL = PtGetAgeSDL() ageSDL[sdlGZGlass] = (newGlass, ) for variable in BooleanVARs: ageSDL.setNotify(self.key, variable, 0.0) self.IManageBOOLs(variable, "") for variable in StateVARs: ageSDL.setNotify(self.key, variable, 0.0) StateVARs[variable](variable, ageSDL[variable][0])
def OnServerInitComplete(self): global byteEderToggle global byteEderGlass global byteGZGlass if AgeStartedIn == PtGetAgeName(): ageSDL = PtGetAgeSDL() ageSDL.setFlags(sdlEderToggle,1,1) ageSDL.sendToClients(sdlEderToggle) ageSDL.setNotify(self.key,sdlEderToggle,0.0) byteEderToggle = ageSDL[sdlEderToggle][0] print "nb01EmgrPhase0.OnServerInitComplete(): byteEderToggle = ",byteEderToggle ageSDL.setFlags(sdlEderGlass,1,1) ageSDL.sendToClients(sdlEderGlass) ageSDL.setNotify(self.key,sdlEderGlass,0.0) byteEderGlass = ageSDL[sdlEderGlass][0] print "nb01EmgrPhase0.OnServerInitComplete(): byteEderGlass = ",byteEderGlass ageSDL.setFlags(sdlGZGlass,1,1) ageSDL.sendToClients(sdlGZGlass) ageSDL.setNotify(self.key,sdlGZGlass,0.0) byteGZGlass = ageSDL[sdlGZGlass][0] print "nb01EmgrPhase0.OnServerInitComplete(): byteGZGlass = ",byteGZGlass if self.sceneobject.isLocallyOwned(): print "nb01EmgrPhase0.OnServerInitComplete(): will check the Eder Delin/Tsogal book and its stained glass..." self.IManageEders() if (byteGZGlass > numGZGlasses) and self.sceneobject.isLocallyOwned(): newGlass = xRandom.randint(1,numGZGlasses) print "nb01EmgrPhase0.OnServerInitComplete(): GZ stained glass randomly picked to be #: ",newGlass ageSDL = PtGetAgeSDL() ageSDL[sdlGZGlass] = (newGlass, ) for variable in BooleanVARs: ageSDL.setNotify(self.key,variable,0.0) self.IManageBOOLs(variable, "") for variable in StateVARs: ageSDL.setNotify(self.key,variable,0.0) StateVARs[variable](variable,ageSDL[variable][0])
def CreateSolution(self): #~ solutionlist = [4,3,6,1] #~ cleftSolList = [4,3,6,1] solutionlist = [3,2,5,0] cleftSolList = [3,2,5,0] while self.AreListsEquiv(solutionlist, cleftSolList): solutionlist = [] while len(solutionlist) < 4: newint = xRandom.randint(0,6) if not newint in solutionlist: solutionlist.append(newint) vault = ptVault() entry = vault.findChronicleEntry("BahroCave") if entry != None: agelist = ["Teledahn", "Garden", "Garrison", "Kadish"] for v in range(len(agelist)): newnode = ptVaultChronicleNode(0) newnode.chronicleSetName(agelist[v]) newnode.chronicleSetValue("0," + str(solutionlist[v]) + ",0") entry.addNode(newnode)
def RandomBahroSounds(self): whichsound = xRandom.random.randint(1, 4) PtDebugPrint("whichsound = ", whichsound) if whichsound == 1: PlayBahro01.run(self.key) elif whichsound == 2: PlayBahro02.run(self.key) elif whichsound == 3: PlayBahro03.run(self.key) elif whichsound == 4: PlayBahro04.run(self.key) wingflap = xRandom.randint(1, 2) if wingflap > 1: #whichflap = xRandom.random.randint(1, 4) whichflap = whichsound PtDebugPrint("whichflap = ", whichflap) if whichflap == 1: BahroWing01.run(self.key) elif whichflap == 2: BahroWing02.run(self.key) elif whichflap == 3: BahroWing03.run(self.key) elif whichflap == 4: BahroWing04.run(self.key) else: PtDebugPrint("no wingflap is heard.")
def RandomBahroSounds(self): whichsound = xRandom.random.randint(1, 4) print "whichsound = ", whichsound if whichsound == 1: PlayBahro01.run(self.key) elif whichsound == 2: PlayBahro02.run(self.key) elif whichsound == 3: PlayBahro03.run(self.key) elif whichsound == 4: PlayBahro04.run(self.key) wingflap = xRandom.randint(1, 2) if wingflap > 1: #whichflap = xRandom.random.randint(1, 4) whichflap = whichsound print "whichflap = ", whichflap if whichflap == 1: BahroWing01.run(self.key) elif whichflap == 2: BahroWing02.run(self.key) elif whichflap == 3: BahroWing03.run(self.key) elif whichflap == 4: BahroWing04.run(self.key) else: print "no wingflap is heard."
def AutoColumns(self,mode,preset=None): PtDebugPrint("jlakField.AutoColumns(): requested all columns move using mode: ",mode) if boolGUILock: PtDebugPrint("jlakField.AutoColumns(): but a previous move is currently in-progress... so it's DENIED!") return anythingMoved = 0 if mode == 0: #lowest newPos = kMinPos elif mode == 1: #mid newPos = kInitPos elif mode == 2: #highest newPos = kMaxPos elif mode == 3: #mild random lowPos = kInitPos-5 highPos = kInitPos+5 anythingMoved = 1 elif mode == 4: #extreme random lowPos = kMinPos highPos = kMaxPos anythingMoved = 1 elif mode == 5: # experimental 'preset' mode if preset == None: PtDebugPrint("no preset, ignoring") return else: PtDebugPrint("running preset...") pass #Tye's Note: had to make this code work in two phases for SFX. #The first phase creates the movement, analyzes it in the process, and prepares the SFX accordingly. #The second phase actually moves the columns. #The problem is that the SFX needs to prepare for any bulk movments before the movements happen. #Unfortunately this makes the code less efficient.... but I've tried to optimize where possible i = 0 maxDist = -1 newColumns = [] for col in listObjCols: if mode in (0,1,2): newColumns.append(newPos) if byteColumns[i] != newPos: maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) anythingMoved = 1 elif mode in (3,4): newPos = byteColumns[i] while newPos == byteColumns[i]: newPos = xRandom.randint(lowPos,highPos) maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) newColumns.append(newPos) elif mode == 5: newPos = preset[i] if newPos < 0 or newPos > 19: newPos = 9 newColumns.append(newPos) if byteColumns[i] != newPos: maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) anythingMoved = 1 i += 1 #Determine what type of SFX to play (i.e. the note will disable individual SFX while enabling bulk SFX) if anythingMoved and maxDist > 0: #Send a note to start movement SFX! notify = ptNotify(self.key) notify.clearReceivers() notify.addReceiver(self.key) notify.netPropagate(1) notify.netForce(1) notify.setActivate(1.0) notify.addVarNumber(kBulkMoveVar, maxDist) notify.send() #Now finally start the movement.... i = 0 for col in listObjCols: if newColumns[i] != byteColumns[i]: self.MoveColumn(i,newColumns[i]) i += 1
def OnServerInitComplete(self): global LocalAvatar global listObjCols global listSfxCols global kZeroed global listWarpPlayers global byteStartPt global boolWall global byteSphere global byteLilBox global byteBigBox global byteRamp global byteRect global byteColumns global boolGUILock global warpWidgets LocalAvatar = PtGetLocalAvatar() ageSDL = PtGetAgeSDL() ageSDL.setFlags(sdlStartPt,1,1) ageSDL.setFlags(sdlWall,1,1) ageSDL.setFlags(sdlSphere,1,1) ageSDL.setFlags(sdlLilBox,1,1) ageSDL.setFlags(sdlBigBox,1,1) ageSDL.setFlags(sdlRamp,1,1) ageSDL.setFlags(sdlRect,1,1) ageSDL.setFlags(sdlGUILock,1,1) ageSDL.sendToClients(sdlStartPt) ageSDL.sendToClients(sdlWall) ageSDL.sendToClients(sdlSphere) ageSDL.sendToClients(sdlLilBox) ageSDL.sendToClients(sdlBigBox) ageSDL.sendToClients(sdlRamp) ageSDL.sendToClients(sdlRect) ageSDL.sendToClients(sdlGUILock) ageSDL.setNotify(self.key,sdlStartPt,0.0) ageSDL.setNotify(self.key,sdlWall,0.0) ageSDL.setNotify(self.key,sdlSphere,0.0) ageSDL.setNotify(self.key,sdlLilBox,0.0) ageSDL.setNotify(self.key,sdlBigBox,0.0) ageSDL.setNotify(self.key,sdlRamp,0.0) ageSDL.setNotify(self.key,sdlRect,0.0) ageSDL.setNotify(self.key,sdlGUILock,0.0) byteStartPt = ageSDL[sdlStartPt][0] boolWall = ageSDL[sdlWall][0] byteSphere = ageSDL[sdlSphere][0] byteLilBox = ageSDL[sdlLilBox][0] byteBigBox = ageSDL[sdlBigBox][0] byteRamp = ageSDL[sdlRamp][0] byteRect = ageSDL[sdlRect][0] #If the last person links out while a bulk move is being performed the SDL gets stuck! #So we'll reset it only if we're the first person entering the age.... if len(PtGetPlayerList()) == 0: PtDebugPrint("jlakField.OnServerInitComplete():\tResetting GUI lock as we're the only ones here!") ageSDL[sdlGUILock] = (0,) boolGUILock = 0 else: boolGUILock = ageSDL[sdlGUILock][0] PtDebugPrint("jlakField.OnServerInitComplete(): byteStartPt = ",byteStartPt) PtDebugPrint("jlakField.OnServerInitComplete(): boolWall = ",boolWall) PtDebugPrint("jlakField.OnServerInitComplete(): byteSphere = ",byteSphere) PtDebugPrint("jlakField.OnServerInitComplete(): byteLilBox = ",byteLilBox) PtDebugPrint("jlakField.OnServerInitComplete(): byteBigBox = ",byteBigBox) PtDebugPrint("jlakField.OnServerInitComplete(): byteRamp = ",byteRamp) PtDebugPrint("jlakField.OnServerInitComplete(): byteRect = ",byteRect) PtDebugPrint("jlakField.OnServerInitComplete(): boolGUILock = ",boolGUILock) for sdl in sdlColumns: ageSDL.setFlags(sdl,1,1) ageSDL.sendToClients(sdl) ageSDL.setNotify(self.key,sdl,0.0) val = ageSDL[sdl][0] byteColumns.append(val) PtDebugPrint("jlakField.OnServerInitComplete(): byteColumns = ",byteColumns) kZeroed = ptVector3(0,0,0) for objCol in objColumns.value: obj = objCol.getName() listObjCols.append(obj) PtDebugPrint("listObjCols = ",listObjCols) if len(clkColumnUp.value) != len(listObjCols): PtDebugPrint("error! not enough up clickables") elif len(clkColumnDn.value) != len(listObjCols): PtDebugPrint("error! not enough down clickables") for resp in respSfxColumn.value: aResp = resp.getName() listSfxCols.append(aResp) #PtDebugPrint("listSfxCols = ",listSfxCols) for warp in warpPlayers.value: pt = warp.getName() listWarpPlayers.append(pt) #PtDebugPrint("listWarpPlayers = ",listWarpPlayers) if not len(PtGetPlayerList()): PtDebugPrint("jlakField.OnServerInitComplete(): on link-in, am only player here. Will reset player start point") newPoint = byteStartPt while newPoint == byteStartPt: newPoint = xRandom.randint(0,len(listWarpPlayers)-1) byteStartPt = newPoint # make sure any widgets that are supposed to be 'home' are really there if byteSphere == len(objSpheres.value): self.WarpWidgetsHome(0) if byteLilBox == len(objLilBoxes.value): self.WarpWidgetsHome(1) if byteBigBox == len(objBigBoxes.value): self.WarpWidgetsHome(2) if byteRamp == len(objRamps.value): self.WarpWidgetsHome(3) if byteRect == len(objRects.value): self.WarpWidgetsHome(4) elif len(PtGetPlayerList()) == 1: PtDebugPrint("jlakField.OnServerInitComplete(): on link-in, 1 player already here. Will warp 2 points away (across from previous point)") byteStartPt = byteStartPt+2 if byteStartPt == 4: byteStartPt = 0 elif byteStartPt >= 5: # greater than 5 shouldn't be possible, but as a safety... byteStartPt = 1 else: PtDebugPrint("jlakField.OnServerInitComplete(): on link-in, 2 or more players already here. Will warp to next point") if byteStartPt == 0: byteStartPt = 2 elif byteStartPt == 1: byteStartPt = 0 elif byteStartPt == 2: byteStartPt = 3 elif byteStartPt == 3: byteStartPt = 1 PtDebugPrint("jlakField.OnServerInitComplete(): player start point = ",byteStartPt) onInit = 1 i = 0 for pos in byteColumns: if pos != 0: self.MoveColumn(i,pos,onInit) i += 1 warpWidgets = warpWidgetsPlay.value[0].getKey() warpPt = warpPlayers.value[byteStartPt].getKey() LocalAvatar.physics.warpObj(warpPt) ageSDL[sdlStartPt] = (byteStartPt,) # vault = ptVault() # if not vault.amOwnerOfCurrentAge(): # return if boolWall: respWallToggle.run(self.key,state="on",fastforward=1,netPropagate=0) self.DoWallSensors(1) else: respWallToggle.run(self.key,state="off",fastforward=1,netPropagate=0) self.DoWallSensors(0) if PtGetLocalKILevel() < 2: PtDebugPrint("jlakField.OnServerInitComplete(): KI level too low, columns will not be clickable") for up in clkColumnUp.value: up.disable() for dn in clkColumnDn.value: dn.disable()
def AutoColumns(self, mode, preset=None): print 'jlakField.AutoColumns(): requested all columns move using mode: ', print mode if boolGUILock: print "jlakField.AutoColumns(): but a previous move is currently in-progress... so it's DENIED!" return anythingMoved = 0 if (mode == 0): newPos = kMinPos elif (mode == 1): newPos = kInitPos elif (mode == 2): newPos = kMaxPos elif (mode == 3): lowPos = (kInitPos - 5) highPos = (kInitPos + 5) anythingMoved = 1 elif (mode == 4): lowPos = kMinPos highPos = kMaxPos anythingMoved = 1 elif (mode == 5): if (preset == None): print 'no preset, ignoring' return else: print 'running preset...' i = 0 maxDist = -1 newColumns = [] for col in listObjCols: if (mode in (0, 1, 2)): newColumns.append(newPos) if (byteColumns[i] != newPos): maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) anythingMoved = 1 elif (mode in (3, 4)): newPos = byteColumns[i] while (newPos == byteColumns[i]): newPos = xRandom.randint(lowPos, highPos) maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) newColumns.append(newPos) elif (mode == 5): newPos = preset[i] if ((newPos < 0) or (newPos > 19)): newPos = 9 newColumns.append(newPos) if (byteColumns[i] != newPos): maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) anythingMoved = 1 i += 1 if (anythingMoved and (maxDist > 0)): notify = ptNotify(self.key) notify.clearReceivers() notify.addReceiver(self.key) notify.netPropagate(1) notify.netForce(1) notify.setActivate(1.0) notify.addVarNumber(kBulkMoveVar, maxDist) notify.send() i = 0 for col in listObjCols: if (newColumns[i] != byteColumns[i]): self.MoveColumn(i, newColumns[i]) i += 1
def AutoColumns(self,mode,preset=None): print "jlakField.AutoColumns(): requested all columns move using mode: ",mode if boolGUILock: print "jlakField.AutoColumns(): but a previous move is currently in-progress... so it's DENIED!" return anythingMoved = 0 if mode == 0: #lowest newPos = kMinPos elif mode == 1: #mid newPos = kInitPos elif mode == 2: #highest newPos = kMaxPos elif mode == 3: #mild random lowPos = kInitPos-5 highPos = kInitPos+5 anythingMoved = 1 elif mode == 4: #extreme random lowPos = kMinPos highPos = kMaxPos anythingMoved = 1 elif mode == 5: # experimental 'preset' mode if preset == None: print "no preset, ignoring" return else: print "running preset..." pass #Tye's Note: had to make this code work in two phases for SFX. #The first phase creates the movement, analyzes it in the process, and prepares the SFX accordingly. #The second phase actually moves the columns. #The problem is that the SFX needs to prepare for any bulk movments before the movements happen. #Unfortunately this makes the code less efficient.... but I've tried to optimize where possible i = 0 maxDist = -1 newColumns = [] for col in listObjCols: if mode in (0,1,2): newColumns.append(newPos) if byteColumns[i] != newPos: maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) anythingMoved = 1 elif mode in (3,4): newPos = byteColumns[i] while newPos == byteColumns[i]: newPos = xRandom.randint(lowPos,highPos) maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) newColumns.append(newPos) elif mode == 5: newPos = preset[i] if newPos < 0 or newPos > 19: newPos = 9 newColumns.append(newPos) if byteColumns[i] != newPos: maxDist = self.getMaxDist(maxDist, byteColumns[i], newPos) anythingMoved = 1 i += 1 #Determine what type of SFX to play (i.e. the note will disable individual SFX while enabling bulk SFX) if anythingMoved and maxDist > 0: #Send a note to start movement SFX! notify = ptNotify(self.key) notify.clearReceivers() notify.addReceiver(self.key) notify.netPropagate(1) notify.netForce(1) notify.setActivate(1.0) notify.addVarNumber(kBulkMoveVar, maxDist) notify.send() #Now finally start the movement.... i = 0 for col in listObjCols: if newColumns[i] != byteColumns[i]: self.MoveColumn(i,newColumns[i]) i += 1
def OnServerInitComplete(self): global LocalAvatar global listObjCols global listSfxCols global kZeroed global listWarpPlayers global byteStartPt global boolWall global byteSphere global byteLilBox global byteBigBox global byteRamp global byteRect global byteColumns global boolGUILock global warpWidgets LocalAvatar = PtGetLocalAvatar() ageSDL = PtGetAgeSDL() ageSDL.setFlags(sdlStartPt,1,1) ageSDL.setFlags(sdlWall,1,1) ageSDL.setFlags(sdlSphere,1,1) ageSDL.setFlags(sdlLilBox,1,1) ageSDL.setFlags(sdlBigBox,1,1) ageSDL.setFlags(sdlRamp,1,1) ageSDL.setFlags(sdlRect,1,1) ageSDL.setFlags(sdlGUILock,1,1) ageSDL.sendToClients(sdlStartPt) ageSDL.sendToClients(sdlWall) ageSDL.sendToClients(sdlSphere) ageSDL.sendToClients(sdlLilBox) ageSDL.sendToClients(sdlBigBox) ageSDL.sendToClients(sdlRamp) ageSDL.sendToClients(sdlRect) ageSDL.sendToClients(sdlGUILock) ageSDL.setNotify(self.key,sdlStartPt,0.0) ageSDL.setNotify(self.key,sdlWall,0.0) ageSDL.setNotify(self.key,sdlSphere,0.0) ageSDL.setNotify(self.key,sdlLilBox,0.0) ageSDL.setNotify(self.key,sdlBigBox,0.0) ageSDL.setNotify(self.key,sdlRamp,0.0) ageSDL.setNotify(self.key,sdlRect,0.0) ageSDL.setNotify(self.key,sdlGUILock,0.0) byteStartPt = ageSDL[sdlStartPt][0] boolWall = ageSDL[sdlWall][0] byteSphere = ageSDL[sdlSphere][0] byteLilBox = ageSDL[sdlLilBox][0] byteBigBox = ageSDL[sdlBigBox][0] byteRamp = ageSDL[sdlRamp][0] byteRect = ageSDL[sdlRect][0] #If the last person links out while a bulk move is being performed the SDL gets stuck! #So we'll reset it only if we're the first person entering the age.... if len(PtGetPlayerList()) == 0: PtDebugPrint("jlakField.OnServerInitComplete():\tResetting GUI lock as we're the only ones here!") ageSDL[sdlGUILock] = (0,) boolGUILock = 0 else: boolGUILock = ageSDL[sdlGUILock][0] print "jlakField.OnServerInitComplete(): byteStartPt = ",byteStartPt print "jlakField.OnServerInitComplete(): boolWall = ",boolWall print "jlakField.OnServerInitComplete(): byteSphere = ",byteSphere print "jlakField.OnServerInitComplete(): byteLilBox = ",byteLilBox print "jlakField.OnServerInitComplete(): byteBigBox = ",byteBigBox print "jlakField.OnServerInitComplete(): byteRamp = ",byteRamp print "jlakField.OnServerInitComplete(): byteRect = ",byteRect print "jlakField.OnServerInitComplete(): boolGUILock = ",boolGUILock for sdl in sdlColumns: ageSDL.setFlags(sdl,1,1) ageSDL.sendToClients(sdl) ageSDL.setNotify(self.key,sdl,0.0) val = ageSDL[sdl][0] byteColumns.append(val) print "jlakField.OnServerInitComplete(): byteColumns = ",byteColumns kZeroed = ptVector3(0,0,0) for objCol in objColumns.value: obj = objCol.getName() listObjCols.append(obj) print "listObjCols = ",listObjCols if len(clkColumnUp.value) != len(listObjCols): print "error! not enough up clickables" elif len(clkColumnDn.value) != len(listObjCols): print "error! not enough down clickables" for resp in respSfxColumn.value: aResp = resp.getName() listSfxCols.append(aResp) #print "listSfxCols = ",listSfxCols for warp in warpPlayers.value: pt = warp.getName() listWarpPlayers.append(pt) #print "listWarpPlayers = ",listWarpPlayers if not len(PtGetPlayerList()): print "jlakField.OnServerInitComplete(): on link-in, am only player here. Will reset player start point" newPoint = byteStartPt while newPoint == byteStartPt: newPoint = xRandom.randint(0,len(listWarpPlayers)-1) byteStartPt = newPoint # make sure any widgets that are supposed to be 'home' are really there if byteSphere == len(objSpheres.value): self.WarpWidgetsHome(0) if byteLilBox == len(objLilBoxes.value): self.WarpWidgetsHome(1) if byteBigBox == len(objBigBoxes.value): self.WarpWidgetsHome(2) if byteRamp == len(objRamps.value): self.WarpWidgetsHome(3) if byteRect == len(objRects.value): self.WarpWidgetsHome(4) elif len(PtGetPlayerList()) == 1: print "jlakField.OnServerInitComplete(): on link-in, 1 player already here. Will warp 2 points away (across from previous point)" byteStartPt = byteStartPt+2 if byteStartPt == 4: byteStartPt = 0 elif byteStartPt >= 5: # greater than 5 shouldn't be possible, but as a safety... byteStartPt = 1 else: print "jlakField.OnServerInitComplete(): on link-in, 2 or more players already here. Will warp to next point" if byteStartPt == 0: byteStartPt = 2 elif byteStartPt == 1: byteStartPt = 0 elif byteStartPt == 2: byteStartPt = 3 elif byteStartPt == 3: byteStartPt = 1 print "jlakField.OnServerInitComplete(): player start point = ",byteStartPt onInit = 1 i = 0 for pos in byteColumns: if pos != 0: self.MoveColumn(i,pos,onInit) i += 1 warpWidgets = warpWidgetsPlay.value[0].getKey() warpPt = warpPlayers.value[byteStartPt].getKey() LocalAvatar.physics.warpObj(warpPt) ageSDL[sdlStartPt] = (byteStartPt,) # vault = ptVault() # if not vault.amOwnerOfCurrentAge(): # return if boolWall: respWallToggle.run(self.key,state="on",fastforward=1,netPropagate=0) self.DoWallSensors(1) else: respWallToggle.run(self.key,state="off",fastforward=1,netPropagate=0) self.DoWallSensors(0) if PtGetLocalKILevel() < 2: print "jlakField.OnServerInitComplete(): KI level too low, columns will not be clickable" for up in clkColumnUp.value: up.disable() for dn in clkColumnDn.value: dn.disable()
def GetExplodeTime(self): timeExplode = xRandom.randint(kMinExplodeTime,kMaxExplodeTime) timeExplode = (float(timeExplode))/10 return timeExplode
def GetLaunchTime(self): timeLaunch = xRandom.randint(kMinLaunchTime,kMaxLaunchTime) return timeLaunch
def OnServerInitComplete(self): global byteRect global boolGUILock global byteStartPt global byteRamp global LocalAvatar global kZeroed global byteLilBox global boolWall global byteSphere global warpWidgets global byteBigBox LocalAvatar = PtGetLocalAvatar() ageSDL = PtGetAgeSDL() ageSDL.setFlags(sdlStartPt, 1, 1) ageSDL.setFlags(sdlWall, 1, 1) ageSDL.setFlags(sdlSphere, 1, 1) ageSDL.setFlags(sdlLilBox, 1, 1) ageSDL.setFlags(sdlBigBox, 1, 1) ageSDL.setFlags(sdlRamp, 1, 1) ageSDL.setFlags(sdlRect, 1, 1) ageSDL.setFlags(sdlGUILock, 1, 1) ageSDL.sendToClients(sdlStartPt) ageSDL.sendToClients(sdlWall) ageSDL.sendToClients(sdlSphere) ageSDL.sendToClients(sdlLilBox) ageSDL.sendToClients(sdlBigBox) ageSDL.sendToClients(sdlRamp) ageSDL.sendToClients(sdlRect) ageSDL.sendToClients(sdlGUILock) ageSDL.setNotify(self.key, sdlStartPt, 0.0) ageSDL.setNotify(self.key, sdlWall, 0.0) ageSDL.setNotify(self.key, sdlSphere, 0.0) ageSDL.setNotify(self.key, sdlLilBox, 0.0) ageSDL.setNotify(self.key, sdlBigBox, 0.0) ageSDL.setNotify(self.key, sdlRamp, 0.0) ageSDL.setNotify(self.key, sdlRect, 0.0) ageSDL.setNotify(self.key, sdlGUILock, 0.0) byteStartPt = ageSDL[sdlStartPt][0] boolWall = ageSDL[sdlWall][0] byteSphere = ageSDL[sdlSphere][0] byteLilBox = ageSDL[sdlLilBox][0] byteBigBox = ageSDL[sdlBigBox][0] byteRamp = ageSDL[sdlRamp][0] byteRect = ageSDL[sdlRect][0] if (len(PtGetPlayerList()) == 0): PtDebugPrint( "jlakField.OnServerInitComplete():\tResetting GUI lock as we're the only ones here!" ) ageSDL[sdlGUILock] = (0, ) boolGUILock = 0 else: boolGUILock = ageSDL[sdlGUILock][0] print 'jlakField.OnServerInitComplete(): byteStartPt = ', print byteStartPt print 'jlakField.OnServerInitComplete(): boolWall = ', print boolWall print 'jlakField.OnServerInitComplete(): byteSphere = ', print byteSphere print 'jlakField.OnServerInitComplete(): byteLilBox = ', print byteLilBox print 'jlakField.OnServerInitComplete(): byteBigBox = ', print byteBigBox print 'jlakField.OnServerInitComplete(): byteRamp = ', print byteRamp print 'jlakField.OnServerInitComplete(): byteRect = ', print byteRect print 'jlakField.OnServerInitComplete(): boolGUILock = ', print boolGUILock for sdl in sdlColumns: ageSDL.setFlags(sdl, 1, 1) ageSDL.sendToClients(sdl) ageSDL.setNotify(self.key, sdl, 0.0) val = ageSDL[sdl][0] byteColumns.append(val) print 'jlakField.OnServerInitComplete(): byteColumns = ', print byteColumns kZeroed = ptVector3(0, 0, 0) for objCol in objColumns.value: obj = objCol.getName() listObjCols.append(obj) print 'listObjCols = ', print listObjCols if (len(clkColumnUp.value) != len(listObjCols)): print 'error! not enough up clickables' elif (len(clkColumnDn.value) != len(listObjCols)): print 'error! not enough down clickables' for resp in respSfxColumn.value: aResp = resp.getName() listSfxCols.append(aResp) for warp in warpPlayers.value: pt = warp.getName() listWarpPlayers.append(pt) if (not len(PtGetPlayerList())): print 'jlakField.OnServerInitComplete(): on link-in, am only player here. Will reset player start point' newPoint = byteStartPt while (newPoint == byteStartPt): newPoint = xRandom.randint(0, (len(listWarpPlayers) - 1)) byteStartPt = newPoint if (byteSphere == len(objSpheres.value)): self.WarpWidgetsHome(0) if (byteLilBox == len(objLilBoxes.value)): self.WarpWidgetsHome(1) if (byteBigBox == len(objBigBoxes.value)): self.WarpWidgetsHome(2) if (byteRamp == len(objRamps.value)): self.WarpWidgetsHome(3) if (byteRect == len(objRects.value)): self.WarpWidgetsHome(4) elif (len(PtGetPlayerList()) == 1): print 'jlakField.OnServerInitComplete(): on link-in, 1 player already here. Will warp 2 points away (across from previous point)' byteStartPt = (byteStartPt + 2) if (byteStartPt == 4): byteStartPt = 0 elif (byteStartPt >= 5): byteStartPt = 1 else: print 'jlakField.OnServerInitComplete(): on link-in, 2 or more players already here. Will warp to next point' if (byteStartPt == 0): byteStartPt = 2 elif (byteStartPt == 1): byteStartPt = 0 elif (byteStartPt == 2): byteStartPt = 3 elif (byteStartPt == 3): byteStartPt = 1 print 'jlakField.OnServerInitComplete(): player start point = ', print byteStartPt onInit = 1 i = 0 for pos in byteColumns: if (pos != 0): self.MoveColumn(i, pos, onInit) i += 1 warpWidgets = warpWidgetsPlay.value[0].getKey() warpPt = warpPlayers.value[byteStartPt].getKey() LocalAvatar.physics.warpObj(warpPt) ageSDL[sdlStartPt] = (byteStartPt, ) if boolWall: respWallToggle.run(self.key, state='on', fastforward=1, netPropagate=0) self.DoWallSensors(1) else: respWallToggle.run(self.key, state='off', fastforward=1, netPropagate=0) self.DoWallSensors(0) if (PtGetLocalKILevel() < 2): print 'jlakField.OnServerInitComplete(): KI level too low, columns will not be clickable' for up in clkColumnUp.value: up.disable() for dn in clkColumnDn.value: dn.disable()
def GetLaunchTime(self): timeLaunch = xRandom.randint(kMinLaunchTime, kMaxLaunchTime) return timeLaunch
def IDoScores(self): if pellet < 0: pelletKIpoints = 0 lakePoints = (pellet / 5) if lakePoints < -70: lakePoints = -70 elif pellet > 200: pelletKIpoints = (pellet - ((pellet - 200) * 4)) lakePoints = (pellet - ((pellet - 200) * 4)) if pelletKIpoints < 0: pelletKIpoints = 0 if lakePoints < -200: lakePoints = -200 else: pelletKIpoints = pellet lakePoints = pellet pelletKIpoints = int( round(pelletKIpoints * ((xRandom.randint(1, 25) / 100.0) + 4.75))) lakePoints = int(round(lakePoints)) print "ErcanaCitySilo.IDoScores(): this pellet drop is worth %d KI points!" % ( pelletKIpoints) print "ErcanaCitySilo.IDoScores(): and %d lake points!" % (lakePoints) scoreList = ptScoreMgr().getPlayerScores("PelletDrop") oldScore = 0 if scoreList: print "old pellet score = ", scoreList[0].getValue() oldScore = scoreList[0].getValue() pelletScoreNew = scoreList[0].addPoints(pelletKIpoints) #scoreListNew = ptScoreMgr().getPlayerScores("PelletDrop") if pelletScoreNew == None: print "hmm, updated score says it's none, we've got a problem" else: pelletScoreNew = ptScoreMgr().createPlayerScore( "PelletDrop", PtGameScoreTypes.kAccumulative, pelletKIpoints) # THE PRINT WAS CAUSING A LOT OF TRACEBACKS. IS IT TOO SOON AFTER NEW SCORE CREATION? #scoreListNew = ptScoreMgr().getPlayerScores("PelletDrop") #print "created score record 'PelletDrop', initial pellet score = ",scoreListNew[0].getValue() if pelletScoreNew == None: print "hmm, initial score says it's none, we've got a problem" totalScoreList = ptScoreMgr().getPlayerScores("PelletTotal") if totalScoreList: print "old total pellet score = ", totalScoreList[0].getValue() pelletTotalScoreNew = totalScoreList[0].addPoints(pelletKIpoints) if pelletTotalScoreNew == None: print "hmm, updated total score says it's none, we've got a problem" else: pelletTotalScoreNew = ptScoreMgr().createPlayerScore( "PelletTotal", PtGameScoreTypes.kAccumulative, (pelletKIpoints + oldScore)) if pelletTotalScoreNew == None: print "hmm, initial total score says it's none, we've got a problem" lakeScoreList = ptScoreMgr().getGlobalScores("LakeScore") if lakeScoreList: oldLakeScore = lakeScoreList[0].getValue() print "old LakeScore = ", oldLakeScore lakeScoreNew = lakeScoreList[0].addPoints(lakePoints) if lakeScoreNew == None: print "updated lake score says None, we've got a problem" else: print "new LakeScore should = ", oldLakeScore + lakePoints else: print "Couldn't find the global LakeScore, creating now..." lakeScoreNew = ptScoreMgr().createGlobalScore( "LakeScore", PtGameScoreTypes.kAccumAllowNegative, lakePoints) if lakeScoreNew == None: print "initial score says it's none, we've got a problem" else: print "initial LakeScore should = ", lakePoints PtSendKIMessage(kUpdatePelletScore, 0)
def NextQuakeDelay(self): QuakeDelay = xRandom.randint(minDelay, maxDelay) print 'dsntQuake: The next quake will happen in ', print QuakeDelay, print ' seconds.' PtAtTimeCallback(self.key, QuakeDelay, 1)
def IDoScores(self): if pellet < 0: pelletKIpoints = 0 lakePoints = (pellet/5) if lakePoints < -70: lakePoints = -70 elif pellet > 200: pelletKIpoints = (pellet - ((pellet-200) * 4)) lakePoints = (pellet - ((pellet-200) * 4)) if pelletKIpoints < 0: pelletKIpoints = 0 if lakePoints < -200: lakePoints = -200 else: pelletKIpoints = pellet lakePoints = pellet pelletKIpoints = int(round(pelletKIpoints * ((xRandom.randint(1,25) / 100.0) + 4.75))) lakePoints = int(round(lakePoints)) print "ErcanaCitySilo.IDoScores(): this pellet drop is worth %d KI points!" % (pelletKIpoints) print "ErcanaCitySilo.IDoScores(): and %d lake points!" % (lakePoints) scoreList = ptScoreMgr().getPlayerScores("PelletDrop") oldScore = 0 if scoreList: print "old pellet score = ",scoreList[0].getValue() oldScore = scoreList[0].getValue() pelletScoreNew = scoreList[0].addPoints(pelletKIpoints) #scoreListNew = ptScoreMgr().getPlayerScores("PelletDrop") if pelletScoreNew == None: print "hmm, updated score says it's none, we've got a problem" else: pelletScoreNew = ptScoreMgr().createPlayerScore("PelletDrop", PtGameScoreTypes.kAccumulative, pelletKIpoints) # THE PRINT WAS CAUSING A LOT OF TRACEBACKS. IS IT TOO SOON AFTER NEW SCORE CREATION? #scoreListNew = ptScoreMgr().getPlayerScores("PelletDrop") #print "created score record 'PelletDrop', initial pellet score = ",scoreListNew[0].getValue() if pelletScoreNew == None: print "hmm, initial score says it's none, we've got a problem" totalScoreList = ptScoreMgr().getPlayerScores("PelletTotal") if totalScoreList: print "old total pellet score = ",totalScoreList[0].getValue() pelletTotalScoreNew = totalScoreList[0].addPoints(pelletKIpoints) if pelletTotalScoreNew == None: print "hmm, updated total score says it's none, we've got a problem" else: pelletTotalScoreNew = ptScoreMgr().createPlayerScore("PelletTotal", PtGameScoreTypes.kAccumulative, (pelletKIpoints + oldScore)) if pelletTotalScoreNew == None: print "hmm, initial total score says it's none, we've got a problem" lakeScoreList = ptScoreMgr().getGlobalScores("LakeScore") if lakeScoreList: oldLakeScore = lakeScoreList[0].getValue() print "old LakeScore = ",oldLakeScore lakeScoreNew = lakeScoreList[0].addPoints(lakePoints) if lakeScoreNew == None: print "updated lake score says None, we've got a problem" else: print "new LakeScore should = ",oldLakeScore+lakePoints else: print "Couldn't find the global LakeScore, creating now..." lakeScoreNew = ptScoreMgr().createGlobalScore("LakeScore", PtGameScoreTypes.kAccumAllowNegative, lakePoints) if lakeScoreNew == None: print "initial score says it's none, we've got a problem" else: print "initial LakeScore should = ",lakePoints PtSendKIMessage(kUpdatePelletScore,0)
def IPickEderBooks(self): print "nb01EmgrPhase0.IPickEderBooks()" newBook = xRandom.randint(2,3) ageSDL = PtGetAgeSDL() ageSDL[sdlEderToggle] = (newBook, ) self.IPickEderGlass(newBook)
def OnNotify(self, state, id, events): global isBirdSpawned global soBird global birdRegion global birdBrain if (not (state)): return if ((id == Act1Bird.id) or ((id == Act2Bird.id) or ((id == Act3Bird.id) or (id == Act4Bird.id)))): if PtFindAvatar(events) != PtGetLocalAvatar() or not PtWasLocallyNotified(self.key) or not self.sceneobject.isLocallyOwned(): return if (not (isBirdSpawned)): print 'lakiCreatures.OnNotify(): some region triggered. Spawning creature...' #soBird = ptSceneobject.getSpawnedNPC(SpawnBird.value) soBird = soBird.value birdBrain = PirBirdBrain(self.key) isBirdSpawned = 1 if (id == Act1Bird.id): if (birdRegion != 1): print 'lakiCreatures.OnNotify(): region 1 triggered. Warping creature...' soBird.physics.warpObj(Warp1Bird.value.getKey()) birdRegion = 1 birdBrain.OnRegionChange() return # unfortunately other areas are not really good to use with bird, so... if (id == Act2Bird.id): if (birdRegion != 2): print 'lakiCreatures.OnNotify(): region 2 triggered. Warping creature...' soBird.physics.warpObj(Warp2Bird.value.getKey()) birdRegion = 2 birdBrain.OnRegionChange() elif (id == Act3Bird.id): if (birdRegion != 3): print 'lakiCreatures.OnNotify(): region 3 triggered. Warping creature...' soBird.physics.warpObj(Warp3Bird.value.getKey()) birdRegion = 3 birdBrain.OnRegionChange() elif (id == Act4Bird.id): if (birdRegion != 4): print 'lakiCreatures.OnNotify(): region 4 triggered. Warping creature...' soBird.physics.warpObj(Warp4Bird.value.getKey()) birdRegion = 4 birdBrain.OnRegionChange() elif (id == respFishPath1.id): for event in events: if (event[0] == kCallbackEvent): randState = xRandom.randint(0, (len(listPaths) - 1)) newState = listPaths[randState] respFishPath1.run(self.key, state=('%s' % newState)) elif (id == respFishPath2.id): for event in events: if (event[0] == kCallbackEvent): randState = xRandom.randint(0, (len(listPaths) - 1)) newState = listPaths[randState] respFishPath2.run(self.key, state=('%s' % newState)) elif (id == respFishPath3.id): for event in events: if (event[0] == kCallbackEvent): randState = xRandom.randint(0, (len(listPaths) - 1)) newState = listPaths[randState] respFishPath3.run(self.key, state=('%s' % newState)) elif (id == respFishBeh1.id): for event in events: if (event[0] == kCallbackEvent): randState = xRandom.randint(0, 100) if (randState <= 40): newState = 'beh1' elif (randState >= 80): newState = 'beh3' else: newState = 'beh2' respFishBeh1.run(self.key, state=('%s' % newState)) elif (id == respFishBeh2.id): for event in events: if (event[0] == kCallbackEvent): randState = xRandom.randint(0, 100) if (randState <= 40): newState = 'beh1' elif (randState >= 80): newState = 'beh3' else: newState = 'beh2' respFishBeh2.run(self.key, state=('%s' % newState)) elif (id == respFishBeh3.id): for event in events: if (event[0] == kCallbackEvent): randState = xRandom.randint(0, 100) if (randState <= 40): newState = 'beh1' elif (randState >= 80): newState = 'beh3' else: newState = 'beh2' respFishBeh3.run(self.key, state=('%s' % newState)) elif id == birdAnims["chomp"].id \ or id == birdAnims["idle"].id \ or id == birdAnims["swallow"].id \ or id == birdAnims["vocalize"].id \ or id == birdAnims["walk"].id: print "Got callback from bird. Id =", id birdBrain.OnBirdAnimDone(id)
def OnBirdAnimDone(self, animid): if len(self.tooCloseAv): #self.msg("Bird worried, will shout at avatar") self.animate("vocalize") return else: if animid == chompId: # chances are: # - swallow (50%) # - chomp (30%) # - idle (15%) p = xRandom.randint(0, 99) if p < 60: self.animate("swallow") elif p < 85: self.animate("chomp") else: self.animate("idle") elif animid == idleId: # chances are: # - idle (50%) # - chomp (30%) # - swallow (0%) p = xRandom.randint(0, 99) if p < 50: self.animate("idle") else: self.animate("chomp") elif animid == swallowId: # chances are: # - chomp (50%) # - idle (30%) # - swallow (20%) p = xRandom.randint(0, 99) if p < 50: self.animate("chomp") elif p < 80: self.animate("idle") else: self.animate("swallow") elif animid == vocalizeId: pass # chances are: # - idle (%) # - chomp (%) # - swallow (%) #-#-# DO SOMETHING HERE #-#-# #self.msg("Vocalizing: uuhh, why would I do that ?") elif animid == walkId: pass
def GetExplodeTime(self): timeExplode = xRandom.randint(kMinExplodeTime, kMaxExplodeTime) timeExplode = (float(timeExplode)) / 10 return timeExplode