def adjustAnimScale(self, state, moveSpeed, slideSpeed = 0):
        self.fsmLock.acquire()

        try:
            currAnimName = self.av.getCurrentAnim()
            if (self.av.isNpc == False or currAnimName != 'walk') and currAnimName != 'run' and currAnimName != 'bayonet_walk' and currAnimName != 'bayonet_run':
                return None

            style = self.av.style
            scale = None
            if hasattr(self.av, 'walkAnimScale'):
                scale = self.av.walkAnimScale

            if self.av is not localAvatar or style or scale:
                if scale:
                    newScale = moveSpeed * scale
                elif type(style) is not types.StringType:
                    style = style.getBodyShape()

                animFileName = self.av.getAnimFilename(self.av.getCurrentAnim())
                animSpeedScale = PiratesGlobals.GetAnimScale(animFileName)
                if animSpeedScale == None:
                    if currAnimName == 'walk' or currAnimName == 'bayonet_walk':
                        animSpeedScale = 0.24399999999999999
                    else:
                        animSpeedScale = 0.029999999999999999

                newScale = moveSpeed * animSpeedScale
                avScale = EnemyGlobals.getEnemyScale(self.av)
                if avScale:
                    newScale /= avScale

                newScale = max(newScale, 0.25)
                if currAnimName == 'walk' or currAnimName == 'bayonet_walk':
                    animIdx = PiratesGlobals.WALK_INDEX
                else:
                    animIdx = PiratesGlobals.RUN_INDEX
                currPlayRate = self.av.getPlayRate(self.animInfo[animIdx][0])
                if currPlayRate == None or abs(currPlayRate - newScale) < 0.074999999999999997:
                    return None

                if animIdx == PiratesGlobals.WALK_INDEX:
                    newAnimInfo = ((self.animInfo[PiratesGlobals.STAND_INDEX][0], self.animInfo[PiratesGlobals.STAND_INDEX][1]), (self.animInfo[PiratesGlobals.WALK_INDEX][0], newScale)) + self.animInfo[2:]
                else:
                    newAnimInfo = ((self.animInfo[PiratesGlobals.STAND_INDEX][0], self.animInfo[PiratesGlobals.STAND_INDEX][1]), (self.animInfo[PiratesGlobals.WALK_INDEX][0], self.animInfo[PiratesGlobals.WALK_INDEX][1]), (self.animInfo[PiratesGlobals.RUN_INDEX][0], newScale)) + self.animInfo[3:]
                if slideSpeed:
                    slideSpeed = max(slideSpeed, 0.45000000000000001)
                    newAnimInfo = ((self.animInfo[PiratesGlobals.STAND_INDEX][0], self.animInfo[PiratesGlobals.STAND_INDEX][1]), (self.animInfo[PiratesGlobals.WALK_INDEX][0], self.animInfo[PiratesGlobals.WALK_INDEX][1]), (self.animInfo[PiratesGlobals.RUN_INDEX][0], self.animInfo[PiratesGlobals.RUN_INDEX][1]), (self.animInfo[PiratesGlobals.REVERSE_INDEX][0], self.animInfo[PiratesGlobals.REVERSE_INDEX][1]), (self.animInfo[PiratesGlobals.STRAFE_LEFT_INDEX][0], slideSpeed), (self.animInfo[PiratesGlobals.STRAFE_RIGHT_INDEX][0], slideSpeed)) + self.animInfo[6:]

                self.av.motionFSM.setAnimInfo(newAnimInfo, reset = False)
                self.av.setPlayRate(newScale, self.animInfo[animIdx][0])
        finally:
            self.fsmLock.release()
Example #2
0
 def adjustAnimScale(self, state, moveSpeed, slideSpeed=0):
     self.fsmLock.acquire()
     try:
         currAnimName = self.av.getCurrentAnim()
         if self.av.isNpc == False or currAnimName != 'walk' and currAnimName != 'run' and currAnimName != 'bayonet_walk' and currAnimName != 'bayonet_run':
             return
         style = self.av.style
         scale = None
         if hasattr(self.av, 'walkAnimScale'):
             scale = self.av.walkAnimScale
         if self.av is not localAvatar and style or scale:
             if scale:
                 newScale = moveSpeed * scale
             else:
                 if type(style) is not types.StringType:
                     style = style.getBodyShape()
                 animFileName = self.av.getAnimFilename(self.av.getCurrentAnim())
                 animSpeedScale = PiratesGlobals.GetAnimScale(animFileName)
                 if animSpeedScale == None:
                     if currAnimName == 'walk' or currAnimName == 'bayonet_walk':
                         animSpeedScale = 0.244
                     else:
                         animSpeedScale = 0.03
                 newScale = moveSpeed * animSpeedScale
                 avScale = EnemyGlobals.getEnemyScale(self.av)
                 if avScale:
                     newScale /= avScale
             newScale = max(newScale, 0.25)
             if currAnimName == 'walk' or currAnimName == 'bayonet_walk':
                 animIdx = PiratesGlobals.WALK_INDEX
             else:
                 animIdx = PiratesGlobals.RUN_INDEX
             currPlayRate = self.av.getPlayRate(self.animInfo[animIdx][0])
             if currPlayRate == None or abs(currPlayRate - newScale) < 0.075:
                 return
             if animIdx == PiratesGlobals.WALK_INDEX:
                 newAnimInfo = (
                  (
                   self.animInfo[PiratesGlobals.STAND_INDEX][0], self.animInfo[PiratesGlobals.STAND_INDEX][1]), (self.animInfo[PiratesGlobals.WALK_INDEX][0], newScale)) + self.animInfo[2:]
             else:
                 newAnimInfo = ((self.animInfo[PiratesGlobals.STAND_INDEX][0], self.animInfo[PiratesGlobals.STAND_INDEX][1]), (self.animInfo[PiratesGlobals.WALK_INDEX][0], self.animInfo[PiratesGlobals.WALK_INDEX][1]), (self.animInfo[PiratesGlobals.RUN_INDEX][0], newScale)) + self.animInfo[3:]
             if slideSpeed:
                 slideSpeed = max(slideSpeed, 0.45)
                 newAnimInfo = ((self.animInfo[PiratesGlobals.STAND_INDEX][0], self.animInfo[PiratesGlobals.STAND_INDEX][1]), (self.animInfo[PiratesGlobals.WALK_INDEX][0], self.animInfo[PiratesGlobals.WALK_INDEX][1]), (self.animInfo[PiratesGlobals.RUN_INDEX][0], self.animInfo[PiratesGlobals.RUN_INDEX][1]), (self.animInfo[PiratesGlobals.REVERSE_INDEX][0], self.animInfo[PiratesGlobals.REVERSE_INDEX][1]), (self.animInfo[PiratesGlobals.STRAFE_LEFT_INDEX][0], slideSpeed), (self.animInfo[PiratesGlobals.STRAFE_RIGHT_INDEX][0], slideSpeed)) + self.animInfo[6:]
             self.av.motionFSM.setAnimInfo(newAnimInfo, reset=False)
             self.av.setPlayRate(newScale, self.animInfo[animIdx][0])
     finally:
         self.fsmLock.release()
Example #3
0
 def getEnemyScale(self):
     return EnemyGlobals.getEnemyScale(self, self._getBossModelScale())