def doCast(self, power, heading): # The client begins a cast. avId = self.air.getAvatarIdFromSender() self.notify.debug("doCast: avId: %s" % (avId)) if not self.validate(avId, (self.avId == avId), "doCast: avId is not fishing in this spot"): return if not self.validate(avId, (0.0 <= power <= 1.0), ("doCast: power: %s is out of range" % power)): return if not self.validate(avId, (-FishGlobals.FishingAngleMax <= heading <= FishGlobals.FishingAngleMax), ("doCast: heading: %s is out of range" % heading)): return av = self.air.doId2do.get(self.avId) if not self.validate(avId, (av), "doCast: avId not currently logged in to this AI"): return self.__stopTimeout() money = av.getMoney() # cast cost is based on rod now castCost = FishGlobals.getCastCost(av.getFishingRod()) if money < castCost: # Not enough money to cast self.normalExit() return self.air.writeServerEvent("fished_cast", avId, "%s|%s" %(av.getFishingRod(), castCost)) av.b_setMoney(money - castCost) self.d_setMovie(FishGlobals.CastMovie, power=power, h=heading) self.__startTimeout(FishGlobals.CastTimeout)
def doCast(self, p, h): avId = self.air.getAvatarIdFromSender() if self.avId != avId: self.air.writeServerEvent( 'suspicious', avId, 'Toon tried to cast from a pier they\'re not on!') return av = self.air.doId2do[avId] money = av.getMoney() cost = FishGlobals.getCastCost(av.getFishingRod()) if money < cost: self.air.writeServerEvent( 'suspicious', avId, 'Toon tried to cast without enough jellybeans!') return if len(av.fishTank) >= av.getMaxFishTank(): self.air.writeServerEvent( 'suspicious', avId, 'Toon tried to cast with too many fish!') return av.takeMoney(cost, False) self.d_setMovie(FishGlobals.CastMovie, 0, 0, 0, 0, p, h) taskMgr.remove('cancelAnimation%d' % self.doId) taskMgr.doMethodLater(2, DistributedFishingSpotAI.cancelAnimation, 'cancelAnimation%d' % self.doId, [self]) taskMgr.remove('timeOut%d' % self.doId) taskMgr.doMethodLater(45, DistributedFishingSpotAI.removeFromPierWithAnim, 'timeOut%d' % self.doId, [self]) self.cast = True
def enterLocalCasting(self): if self.power == 0.0 and len(self.av.fishCollection) == 0: self.__showHowTo(TTLocalizer.FishingHowToFailed) if self.castTrack: self.castTrack.pause() self.av.loop("pole-neutral") self.track = None return castCost = FishGlobals.getCastCost(self.av.getFishingRod()) self.jar["text"] = str(max(self.av.getMoney() - castCost, 0)) if not self.castTrack: self.createCastTrack() self.castTrack.pause() startT = 0.7 + (1 - self.power) * 0.3 self.castTrack.start(startT) self.track = Sequence( Wait(1.2 - startT), Func(self.startMoveBobTask), Func(self.__showLineCasting), ) self.track.start() heading = self.angleNP.getH() self.d_doCast(self.power, heading) self.timer.countdown(FishGlobals.CastTimeout) return
def enterLocalAdjusting(self, guiEvent = None): if self.track: self.track.pause() if self.castTrack: self.castTrack.pause() self.power = 0.0 self.firstCast = 0 self.castButton['image0_color'] = Vec4(0, 1, 0, 1) self.castButton['text'] = '' self.av.stopLookAround() self._DistributedFishingSpot__hideLine() self._DistributedFishingSpot__hideBob() self.howToDialog.hide() castCost = FishGlobals.getCastCost(self.av.getFishingRod()) if self.av.getMoney() < castCost: self._DistributedFishingSpot__hideCastGui() self._DistributedFishingSpot__showBroke() self.av.loop('pole-neutral') return None if self.av.isFishTankFull(): self._DistributedFishingSpot__hideCastGui() self._DistributedFishingSpot__showFishTankFull() self.av.loop('pole-neutral') return None self.arrow.show() self.arrow.setColorScale(1, 1, 0, 0.69999999999999996) self.startAngleNP = self.angleNP.getH() self.getMouse() self.initMouseX = self.mouseX self.initMouseY = self.mouseY self._DistributedFishingSpot__hideBob() if config.GetBool('fishing-independent-axes', 0): taskMgr.add(self.localAdjustingCastTaskIndAxes, self.taskName('adjustCastTask')) else: taskMgr.add(self.localAdjustingCastTask, self.taskName('adjustCastTask')) if base.wantBingo: bingoMgr = self.pond.getPondBingoManager() if bingoMgr: bingoMgr.castingStarted()
def doCast(self, p, h): avId = self.air.getAvatarIdFromSender() if not avId: return if self.avId != avId: self.air.writeServerEvent( 'suspicious', avId, 'Toon tried to cast from a fishing spot they\'re not on!') return av = self.air.doId2do.get(avId) if not av: self.air.writeServerEvent( 'suspicious', avId, 'Toon tried to cast, but they don\'t exist on this shard!') return money = av.getMoney() cost = FishGlobals.getCastCost(av.getFishingRod()) if money < cost: self.air.writeServerEvent( 'suspicious', avId, 'Toon tried to cast without enough jellybeans!') return if len(av.fishTank) >= av.getMaxFishTank(): self.air.writeServerEvent( 'suspicious', avId, 'Toon tried to cast with too many fish!') return av.takeMoney(cost, False) self.d_setMovie(FishGlobals.CastMovie, 0, 0, 0, 0, p, h) taskMgr.remove('cancel-animation-%d' % self.doId) taskMgr.doMethodLater(2, self.d_setMovie, 'cancel-animation-%d' % self.doId, [FishGlobals.NoMovie, 0, 0, 0, 0, 0, 0]) taskMgr.remove('time-out-%d' % self.doId) taskMgr.doMethodLater(FishGlobals.CastTimeout, self.removeFromFishingSpotWithAnim, 'time-out-%d' % self.doId) self.cast = True
def enterLocalCasting(self): if self.power == 0.0 and len(self.av.fishCollection) == 0: self.__showHowTo(TTLocalizer.FishingHowToFailed) if self.castTrack: self.castTrack.pause() self.av.loop('pole-neutral') self.track = None return castCost = FishGlobals.getCastCost(self.av.getFishingRod()) self.jar['text'] = str(max(self.av.getMoney() - castCost, 0)) if not self.castTrack: self.createCastTrack() self.castTrack.pause() startT = 0.7 + (1 - self.power) * 0.3 self.castTrack.start(startT) self.track = Sequence(Wait(1.2 - startT), Func(self.startMoveBobTask), Func(self.__showLineCasting)) self.track.start() heading = self.angleNP.getH() self.d_doCast(self.power, heading) self.timer.countdown(FishGlobals.CastTimeout)
def enterLocalAdjusting(self, guiEvent=None): if self.track: self.track.pause() if self.castTrack: self.castTrack.pause() self.power = 0.0 self.firstCast = 0 self.castButton['image0_color'] = Vec4(0, 1, 0, 1) self.castButton['text'] = '' self.av.stopLookAround() self.__hideLine() self.__hideBob() self.howToDialog.hide() castCost = FishGlobals.getCastCost(self.av.getFishingRod()) if self.av.getMoney() < castCost: self.__hideCastGui() self.__showBroke() self.av.loop('pole-neutral') return if self.av.isFishTankFull(): self.__hideCastGui() self.__showFishTankFull() self.av.loop('pole-neutral') return self.arrow.show() self.arrow.setColorScale(1, 1, 0, 0.7) self.startAngleNP = self.angleNP.getH() self.getMouse() self.initMouseX = self.mouseX self.initMouseY = self.mouseY self.__hideBob() if config.GetBool('fishing-independent-axes', 0): taskMgr.add(self.localAdjustingCastTaskIndAxes, self.taskName('adjustCastTask')) else: taskMgr.add(self.localAdjustingCastTask, self.taskName('adjustCastTask')) if base.wantBingo: bingoMgr = self.pond.getPondBingoManager() if bingoMgr: bingoMgr.castingStarted()
def doCast(self, p, h): avId = self.air.getAvatarIdFromSender() if self.avId != avId: self.air.writeServerEventMessage('suspicious', avId, 'Toon tried to cast from a pier they\'re not on!') return av = self.air.doId2do[avId] money = av.getMoney() cost = FishGlobals.getCastCost(av.getFishingRod()) if money < cost: self.air.writeServerEventMessage('suspicious', avId, 'Toon tried to cast without enough jellybeans!') return if len(av.fishTank) >= av.getMaxFishTank(): self.air.writeServerEventMessage('suspicious', avId, 'Toon tried to cast with too many fish!') return av.takeMoney(cost, False) self.d_setMovie(FishGlobals.CastMovie, 0, 0, 0, 0, p, h) taskMgr.remove('cancelAnimation%d' % self.doId) taskMgr.doMethodLater(2, DistributedFishingSpotAI.cancelAnimation, 'cancelAnimation%d' % self.doId, [self]) taskMgr.remove('timeOut%d' % self.doId) taskMgr.doMethodLater(45, DistributedFishingSpotAI.removeFromPierWithAnim, 'timeOut%d' % self.doId, [self]) self.cast = True