Exemplo n.º 1
0
 def makeTreasure(self, goon):
     if self.state != 'BattleThree':
         return
     pos = goon.getPos(self)
     v = Vec3(pos[0], pos[1], 0.0)
     if not v.normalize():
         v = Vec3(1, 0, 0)
     v = v * 27
     angle = random.uniform(0.0, 2.0 * math.pi)
     radius = 10
     dx = radius * math.cos(angle)
     dy = radius * math.sin(angle)
     fpos = self.scene.getRelativePoint(self, Point3(v[0] + dx, v[1] + dy, 0))
     if goon.strength <= 40:
         style = ToontownGlobals.ToontownCentral
         healAmount = 40
     elif goon.strength <= 60:
         style = random.choice([ToontownGlobals.DonaldsDock, ToontownGlobals.DaisyGardens, ToontownGlobals.MinniesMelodyland])
         healAmount = 30
     else:
         style = random.choice([ToontownGlobals.TheBrrrgh, ToontownGlobals.DonaldsDreamland])
         healAmount = 20
     if self.recycledTreasures:
         treasure = self.recycledTreasures.pop(0)
         treasure.d_setGrab(0)
         treasure.b_setGoonId(goon.doId)
         treasure.b_setStyle(style)
         treasure.b_setPosition(pos[0], pos[1], 0)
         treasure.b_setFinalPosition(fpos[0], fpos[1], 0)
     else:
         treasure = DistributedCashbotBossTreasureAI.DistributedCashbotBossTreasureAI(self.air, self, goon, style, fpos[0], fpos[1], 0)
         treasure.generateWithRequired(self.zoneId)
     treasure.healAmount = healAmount
     self.treasures[treasure.doId] = treasure
    def makeTreasure(self, goon):
        # Places a treasure, as pooped out by the given goon.  We
        # place the treasure at the goon's current position, or at
        # least at the beginning of its current path.  Actually, we
        # ignore Z, and always place the treasure at Z == 0,
        # presumably the ground.

        if self.state != 'BattleThree':
            return

        # The BossCog acts like a treasure planner as far as the
        # treasure is concerned.
        pos = goon.getPos(self)

        # The treasure pops out and lands somewhere nearby.  Let's
        # start by choosing a point on a ring around the boss, based
        # on our current angle to the boss.
        v = Vec3(pos[0], pos[1], 0.0)
        if not v.normalize():
            v = Vec3(1, 0, 0)
        v = v * 27

        # Then perterb that point by a distance in some random
        # direction.
        angle = random.uniform(0.0, 2.0 * math.pi)
        radius = 10
        dx = radius * math.cos(angle)
        dy = radius * math.sin(angle)

        fpos = self.scene.getRelativePoint(self, Point3(v[0] + dx, v[1] + dy, 0))

        if goon.strength <= 10:
            style = ToontownGlobals.ToontownCentral
            healAmount = 3

        elif goon.strength <= 15:
            style = random.choice(
                [ToontownGlobals.DonaldsDock,
                 ToontownGlobals.DaisyGardens,
                 ToontownGlobals.MinniesMelodyland])
            healAmount = 10

        else:
            style = random.choice(
                [ToontownGlobals.TheBrrrgh,
                 ToontownGlobals.DonaldsDreamland])
            healAmount = 12

        if self.recycledTreasures:
            # Reuse a previous treasure object
            treasure = self.recycledTreasures.pop(0)
            treasure.d_setGrab(0)
            treasure.b_setGoonId(goon.doId)
            treasure.b_setStyle(style)
            treasure.b_setPosition(pos[0], pos[1], 0)
            treasure.b_setFinalPosition(fpos[0], fpos[1], 0)

        else:
            # Create a new treasure object
            treasure = DistributedCashbotBossTreasureAI.DistributedCashbotBossTreasureAI(
                self.air, self, goon,
                style, fpos[0], fpos[1], 0)
            treasure.generateWithRequired(self.zoneId)

        treasure.healAmount = healAmount
        self.treasures[treasure.doId] = treasure