Esempio n. 1
0
    def requestThrow(self, x, y, z):
        avId = self.air.getAvatarIdFromSender()
        if avId not in self.avatars:
            self.air.writeServerEvent(
                'suspicious',
                avId=avId,
                issue="Toon tried to throw a gag in a race they're not in!")
        if self.avatarGags[avId] == RaceGlobals.BANANA:
            gag = DistributedGagAI(self.air)
            gag.setRace(self.doId)
            gag.setOwnerId(avId)
            gag.setPos(x, y, z)
            gag.setType(0)
            gag.setInitTime(globalClockDelta.getRealNetworkTime())
            gag.setActivateTime(globalClockDelta.getRealNetworkTime())
            gag.generateWithRequired(self.zoneId)
            self.livingGags.append(gag)
        else:
            if self.avatarGags[avId] == RaceGlobals.TURBO:
                pass
            else:
                if self.avatarGags[avId] == RaceGlobals.ANVIL:
                    places = sorted(self.avatarProgress,
                                    key=self.avatarProgress.get,
                                    reverse=True)
                    for i in places:
                        if i not in self.finishedAvatars and not self.currentlyAffectedByAnvil[
                                i]:
                            currAvatar = i
                            break

                    self.currentlyAffectedByAnvil[avId] = True
                    taskMgr.doMethodLater(RaceGlobals.AnvilSquishDuration,
                                          self.unsquish,
                                          'unsquish-%i' % currAvatar,
                                          [currAvatar])
                    self.sendUpdate('dropAnvilOn', [
                        avId, currAvatar,
                        globalClockDelta.getRealNetworkTime()
                    ])
                else:
                    if self.avatarGags[avId] == RaceGlobals.PIE:
                        places = sorted(self.avatarProgress,
                                        key=self.avatarProgress.get)
                        avPlace = places.index(avId)
                        if avPlace + 1 == len(places):
                            target = 0
                        else:
                            target = places[(avPlace + 1)]
                        self.sendUpdate('shootPiejectile', [avId, target, 0])
                    else:
                        self.air.writeServerEvent(
                            'suspicious',
                            avId=avId,
                            issue='Toon use race gag while not having one!')
        self.avatarGags[avId] = 0
Esempio n. 2
0
 def requestThrow(self, x, y, z):
     avId = self.air.getAvatarIdFromSender()
     if not avId in self.avatars:
         self.air.writeServerEvent('suspicious', avId, 'Toon tried to throw a gag in a race they\'re not in!')
     if self.avatarGags[avId] == RaceGlobals.BANANA:
         gag = DistributedGagAI(self.air)
         gag.setRace(self.doId)
         gag.setOwnerId(avId)
         gag.setPos(x, y, z)
         gag.setType(0)
         gag.setInitTime(globalClockDelta.getRealNetworkTime())
         gag.setActivateTime(globalClockDelta.getRealNetworkTime())
         gag.generateWithRequired(self.zoneId)
         self.livingGags.append(gag)
     elif self.avatarGags[avId] == RaceGlobals.TURBO:
         pass
     elif self.avatarGags[avId] == RaceGlobals.ANVIL:
         places = sorted(self.avatarProgress, key=self.avatarProgress.get, reverse=True)
         for i in places:
             if not i in self.finishedAvatars and not self.currentlyAffectedByAnvil[i]:
                 currAvatar = i
                 break
         self.currentlyAffectedByAnvil[avId] = True
         taskMgr.doMethodLater(RaceGlobals.AnvilSquishDuration, self.unsquish, 'unsquish-%i' % currAvatar, [currAvatar])
         self.sendUpdate('dropAnvilOn', [avId, currAvatar, globalClockDelta.getRealNetworkTime()])
     elif self.avatarGags[avId] == RaceGlobals.PIE:
         places = sorted(self.avatarProgress, key=self.avatarProgress.get)
         avPlace = places.index(avId)
         if avPlace + 1 == len(places):
             target = 0
         else:
             target = places[avPlace + 1]
         self.sendUpdate('shootPiejectile', [avId, target, 0])
     else:
         self.air.writeServerEvent('suspicious', avId, 'Toon use race gag while not having one!')
     self.avatarGags[avId] = 0