def getTossPieInterval(self, toon, x, y, z, h, p, r, power, beginFlyIval = Sequence()):
        ToontownBattleGlobals = ToontownBattleGlobals
        import toontown.toonbase
        BattleProps = BattleProps
        import toontown.battle
        pie = toon.getPieModel()
        pie.setScale(0.5)
        flyPie = pie.copyTo(NodePath('a'))
        pieName = ToontownBattleGlobals.pieNames[toon.pieType]
        pieType = BattleProps.globalPropPool.getPropType(pieName)
        animPie = Sequence()
        if pieType == 'actor':
            animPie = ActorInterval(pie, pieName, startFrame = 48)
        
        sound = loader.loadSfx('phase_3.5/audio/sfx/AA_pie_throw_only.mp3')
        t = power / 100.0
        dist = lerp(PartyGlobals.CogActivityPieMinDist, PartyGlobals.CogActivityPieMaxDist, t)
        time = lerp(1.0, 1.5, t)
        proj = ProjectileInterval(None, startPos = Point3(0, 0, 0), endPos = Point3(0, dist, 0), duration = time)
        relVel = proj.startVel
        
        def getVelocity(toon = toon, relVel = relVel):
            return render.getRelativeVector(toon, relVel) * 0.59999999999999998

        
        def _PartyCogActivity__safeSetAnimState(toon = toon, state = 'Happy'):
            if toon and hasattr(toon, 'animFSM'):
                toon.setAnimState('Happy')
            else:
                self.notify.warning('The toon is being destroyed. No attribute animState.')

        toss = Track((0, Sequence(Func(toon.setPosHpr, x, y, z, h, p, r), Func(pie.reparentTo, toon.rightHand), Func(pie.setPosHpr, 0, 0, 0, 0, 0, 0), animPie, Parallel(ActorInterval(toon, 'throw', startFrame = 48, playRate = 1.5, partName = 'torso'), animPie), Func(_PartyCogActivity__safeSetAnimState, toon, 'Happy'))), (16.0 / 24.0, Func(pie.detachNode)))
        fly = Track((14.0 / 24.0, SoundInterval(sound, node = toon, cutOff = PartyGlobals.PARTY_COG_CUTOFF)), (16.0 / 24.0, Sequence(Func(flyPie.reparentTo, render), Func(flyPie.setPosHpr, toon, 0.52000000000000002, 0.96999999999999997, 2.2400000000000002, 0, -45, 0), beginFlyIval, ProjectileInterval(flyPie, startVel = getVelocity, duration = 6), Func(flyPie.detachNode))))
        return (toss, fly, flyPie)
示例#2
0
    def getTossPieInterval(self,
                           toon,
                           x,
                           y,
                           z,
                           h,
                           p,
                           r,
                           power,
                           beginFlyIval=Sequence()):
        """Adapted from toon.py to suit our needs.
        Returns (toss, pie, flyPie), where toss is an interval to
        animate the toon tossing a pie, pie is the interval to
        animate the pie flying through the air, and pieModel is the
        model that flies.  This is used in the final BossBattle
        sequence of CogHQ when we all throw pies directly at the
        boss cog.
        """

        from toontown.toonbase import ToontownBattleGlobals
        from toontown.battle import BattleProps

        pie = toon.getPieModel()
        pie.setScale(0.5)
        flyPie = pie.copyTo(NodePath('a'))
        pieName = ToontownBattleGlobals.pieNames[toon.pieType]
        pieType = BattleProps.globalPropPool.getPropType(pieName)
        animPie = Sequence()
        if pieType == 'actor':
            animPie = ActorInterval(pie, pieName, startFrame=48)

        sound = loader.loadSfx('phase_3.5/audio/sfx/AA_pie_throw_only.mp3')

        # First, create a ProjectileInterval to compute the relative
        # velocity.

        assert 0 <= power <= 100, "invalid pie throw power %s" % power

        t = power / 100.0

        # Distance ranges from CogActivityPieMinDist to CogActivityPieMaxDist ft, time ranges from 1 to 1.5 s.
        dist = lerp(PartyGlobals.CogActivityPieMinDist,
                    PartyGlobals.CogActivityPieMaxDist, t)
        time = lerp(1.0, 1.5, t)

        proj = ProjectileInterval(None,
                                  startPos=Point3(0, 0, 0),
                                  endPos=Point3(0, dist, 0),
                                  duration=time)
        relVel = proj.startVel

        def getVelocity(toon=toon, relVel=relVel):
            return render.getRelativeVector(toon, relVel) * 0.6

        toss = Track(
            (
                0,
                Sequence(
                    Func(toon.setPosHpr, x, y, z, h, p, r),
                    Func(pie.reparentTo, toon.rightHand),
                    Func(pie.setPosHpr, 0, 0, 0, 0, 0, 0),
                    animPie,
                    Parallel(
                        ActorInterval(
                            toon,
                            'throw',
                            startFrame=48,
                            #duration=0.25, #self.throwPieLimitTime,
                            playRate=1.5,
                            partName='torso'),
                        animPie),
                    Func(toon.setAnimState, 'Happy'),
                )),
            (16. / 24., Func(pie.detachNode)))

        fly = Track(
            (14. / 24.,
             SoundInterval(
                 sound, node=toon, cutOff=PartyGlobals.PARTY_COG_CUTOFF)),
            (
                16. / 24.,
                Sequence(
                    Func(flyPie.reparentTo, render),
                    Func(flyPie.setPosHpr, toon, 0.52, 0.97, 2.24, 0, -45, 0),
                    beginFlyIval,
                    ProjectileInterval(
                        flyPie, startVel=getVelocity, duration=6),
                    #LerpPosInterval(flyPie, duration = 3, Point3(0.52,50,2.24)),
                    Func(flyPie.detachNode),
                )),
        )
        return (toss, fly, flyPie)