def enterReward(self, code, itemDesc1, itemDesc2, itemDesc3): self.__placeAvatar() self.bob.reparentTo(self.angleNP) self.waterLevel = FishingTargetGlobals.getWaterLevel(self.area) self.bob.setZ(self.waterLevel) self.__showLineReeling() self.castTrack.pause() if self.localToonFishing: self.__showCastGui() if code == FishGlobals.QuestItem: self.__showQuestItem(itemDesc1) elif code in (FishGlobals.FishItem, FishGlobals.FishItemNewEntry, FishGlobals.FishItemNewRecord): genus, species, weight = itemDesc1, itemDesc2, itemDesc3 fish = FishBase.FishBase(genus, species, weight) self.__showFishItem(code, fish) if base.wantBingo: self.pond.handleBingoCatch((genus, species)) elif code == FishGlobals.BootItem: self.__showBootItem() if base.wantBingo: self.pond.handleBingoCatch(FishGlobals.BingoBoot) elif code == FishGlobals.JellybeanItem: amount = itemDesc1 self.__showJellybeanItem(amount) elif code == FishGlobals.OverTankLimit: self.__hideCastGui() else: self.__showFailureReason(code) self.track = Sequence(Parallel(ActorInterval(self.av, 'reel'), ActorInterval(self.pole, 'cast', startFrame=63, endFrame=127)), ActorInterval(self.av, 'reel-neutral'), Func(self.__hideLine), Func(self.__hideBob), ActorInterval(self.av, 'fish-again'), Func(self.av.loop, 'pole-neutral')) self.track.start()
def updateState(self): if not self.pondId in self.air.doId2do: return self.b_setPosHpr(self.targetRadius * math.cos(self.angle) + self.centerPoint[0], self.targetRadius * math.sin(self.angle) + self.centerPoint[1], self.centerPoint[2], 0, 0, 0) self.angle = random.randrange(359) self.targetRadius = random.uniform(FishingTargetGlobals.getTargetRadius(self.air.doId2do[self.pondId].getArea()), 0) self.time = random.uniform(10.0, 5.0) self.sendUpdate('setState', [0, self.angle, self.targetRadius, self.time, globalClockDelta.getRealNetworkTime()]) taskMgr.doMethodLater(self.time + random.uniform(5, 2.5), DistributedFishingTargetAI.updateState, 'updateFishingTarget%d' % self.doId, [self])
def generate(self): DistributedNodeAI.generate(self) self.updateState() if not self.pondId: #We dont have a pond ID for some reason... return pond = self.air.doId2do[self.pondId] pond.addTarget(self) self.centerPoint = FishingTargetGlobals.getTargetCenter(pond.getArea())
def updateState(self): if not self.pondId in self.air.doId2do: return self.b_setPosHpr( self.targetRadius * math.cos(self.angle) + self.centerPoint[0], self.targetRadius * math.sin(self.angle) + self.centerPoint[1], self.centerPoint[2], 0, 0, 0) self.angle = random.randrange(359) self.targetRadius = random.uniform( FishingTargetGlobals.getTargetRadius( self.air.doId2do[self.pondId].getArea()), 0) self.time = random.uniform(10.0, 5.0) self.sendUpdate('setState', [ 0, self.angle, self.targetRadius, self.time, globalClockDelta.getRealNetworkTime() ]) taskMgr.doMethodLater(self.time + random.uniform(5, 2.5), DistributedFishingTargetAI.updateState, 'updateFishingTarget%d' % self.doId, [self])
def enterReward(self, code, itemDesc1, itemDesc2, itemDesc3): self.__placeAvatar() self.bob.reparentTo(self.angleNP) self.waterLevel = FishingTargetGlobals.getWaterLevel(self.area) self.bob.setZ(self.waterLevel) self.__showLineReeling() self.castTrack.pause() if self.localToonFishing: self.__showCastGui() if code == FishGlobals.QuestItem: self.__showQuestItem(itemDesc1) elif code in (FishGlobals.FishItem, FishGlobals.FishItemNewEntry, FishGlobals.FishItemNewRecord): genus, species, weight = itemDesc1, itemDesc2, itemDesc3 fish = FishBase.FishBase(genus, species, weight) self.__showFishItem(code, fish) if base.wantBingo: self.pond.handleBingoCatch((genus, species)) elif code == FishGlobals.BootItem: self.__showBootItem() if base.wantBingo: self.pond.handleBingoCatch(FishGlobals.BingoBoot) elif code == FishGlobals.JellybeanItem: amount = itemDesc1 self.__showJellybeanItem(amount) elif code == FishGlobals.OverTankLimit: self.__hideCastGui() else: self.__showFailureReason(code) self.track = Sequence( Parallel( ActorInterval(self.av, 'reel'), ActorInterval(self.pole, 'cast', startFrame=63, endFrame=127)), ActorInterval(self.av, 'reel-neutral'), Func(self.__hideLine), Func(self.__hideBob), ActorInterval(self.av, 'fish-again'), Func(self.av.loop, 'pole-neutral')) self.track.start()
def start(self): for _ in xrange(FishingTargetGlobals.getNumTargets(self.area)): fishingTarget = DistributedFishingTargetAI(simbase.air) fishingTarget.setPondDoId(self.doId) fishingTarget.generateWithRequired(self.zoneId)
def setPond(self, pond): self.pond = pond self.area = self.pond.getArea() self.waterLevel = FishingTargetGlobals.getWaterLevel(self.area)