Example #1
0
 def __launchTreeFallEffect(self, chunkID, destrIndex, effectName,
                            fallDirYaw):
     player = BigWorld.player()
     if player is None or isPlayerAccount():
         return
     else:
         desc = g_cache.getDestructibleDesc(self.__spaceID, chunkID,
                                            destrIndex)
         if desc is None:
             _printErrDescNotAvailable(self.__spaceID, chunkID, destrIndex)
             return
         effectVars = desc.get(effectName)
         if effectVars is None:
             return
         effectStuff = random.choice(effectVars)
         chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
         destrMatrix = BigWorld.wg_getDestructibleMatrix(
             self.__spaceID, chunkID, destrIndex)
         pos = chunkMatrix.translation + destrMatrix.translation
         dir = Math.Vector3(math.sin(fallDirYaw), 0.0, math.cos(fallDirYaw))
         treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
         scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
         player.terrainEffects.addNew(pos,
                                      effectStuff.effectsList,
                                      effectStuff.keyPoints,
                                      None,
                                      dir=dir,
                                      scale=scale)
         return
 def __launchEffect(self, chunkID, destrIndex, desc, effectType, modelFile, isHavokVisible, callbackOnStop = None):
     effectVars = desc.get(effectType)
     if effectVars is None:
         return
     else:
         type = desc.get('type')
         if type == DESTR_TYPE_TREE or type == DESTR_TYPE_FALLING_ATOM:
             chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
             destrMatrix = BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex)
             dir = destrMatrix.applyVector((0, 0, 1))
             pos = chunkMatrix.translation + destrMatrix.translation
             if type == DESTR_TYPE_TREE:
                 treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
                 scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
             else:
                 scale = desc['effectScale']
         else:
             hpMatrix = BigWorld.wg_getHardPointMatrix(self.__spaceID, chunkID, destrIndex, desc['effectHP'])
             if hpMatrix is None:
                 LOG_ERROR("Can't find hardpoint %s in model %s" % (desc['effectHP'], modelFile))
                 return
             dir = hpMatrix.applyVector((0, 0, 1))
             pos = hpMatrix.translation
             scale = desc['effectScale']
         player = BigWorld.player()
         if player is None or isPlayerAccount():
             return
         effectStuff = random.choice(effectVars)
         effectID = player.terrainEffects.addNew(pos, effectStuff.effectsList, effectStuff.keyPoints, callbackOnStop, dir=dir, scale=scale, havokEnabled=isHavokVisible)
         return effectID
Example #3
0
 def __launchFallEffect(self, chunkID, destrIndex, effectType, fallDirYaw):
     player = BigWorld.player()
     if player is None or isPlayerAccount():
         return
     else:
         effectName = BigWorld.wg_getDestructibleEffectName(
             self.__spaceID, chunkID, destrIndex, -1, effectType)
         if effectName == 'none':
             return
         effectVars = g_cache._getEffect(effectName, 'fallingAtoms', False)
         if effectVars is None:
             return
         effectStuff = random.choice(effectVars)
         chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
         destrMatrix = BigWorld.wg_getDestructibleMatrix(
             self.__spaceID, chunkID, destrIndex)
         pos = chunkMatrix.translation + destrMatrix.translation
         dir = Math.Vector3(math.sin(fallDirYaw), 0.0, math.cos(fallDirYaw))
         scale = BigWorld.wg_getDestructibleEffectScale(
             self.__spaceID, chunkID, destrIndex, -1)
         player.terrainEffects.addNew(pos,
                                      effectStuff.effectsList,
                                      effectStuff.keyPoints,
                                      None,
                                      dir=dir,
                                      scale=scale)
         return
 def __launchTreeFallEffect(self,
                            chunkID,
                            destrIndex,
                            effectType,
                            fallDirYaw,
                            tintColor=COLOR_WHITE):
     player = BigWorld.player()
     if player is None or isPlayerAccount():
         return
     else:
         effectName = BigWorld.wg_getDestructibleEffectName(
             self.__spaceID, chunkID, destrIndex, -1, effectType)
         if effectName == 'none':
             return
         effectVars = g_cache._getEffect(effectName, 'trees', False)
         if effectVars is None:
             return
         effectStuff = random.choice(effectVars)
         chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
         destrMatrix = BigWorld.wg_getDestructibleMatrix(
             self.__spaceID, chunkID, destrIndex)
         pos = chunkMatrix.translation + destrMatrix.translation
         direction = Math.Vector3(math.sin(fallDirYaw), 0.0,
                                  math.cos(fallDirYaw))
         treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
         scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
         player.terrainEffects.addNew(pos,
                                      effectStuff.effectsList,
                                      effectStuff.keyPoints,
                                      None,
                                      dir=direction,
                                      scale=scale,
                                      tintColor=tintColor)
         return
 def __getEffectParams(self, lArgs):
     destrType = BigWorld.wg_getDestructibleEffectCategory(self.__spaceID, lArgs.chunkID, lArgs.destrIndex, lArgs.moduleIndex)
     effectCat = ''
     if destrType == DestructiblesCache.DESTR_TYPE_TREE:
         effectCat = 'trees'
     elif destrType == DestructiblesCache.DESTR_TYPE_FALLING_ATOM:
         effectCat = 'fallingAtoms'
     elif destrType == DestructiblesCache.DESTR_TYPE_FRAGILE:
         effectCat = 'fragiles'
     elif destrType == DestructiblesCache.DESTR_TYPE_STRUCTURE:
         effectCat = 'structures'
     effectName = BigWorld.wg_getDestructibleEffectName(self.__spaceID, lArgs.chunkID, lArgs.destrIndex, lArgs.moduleIndex, lArgs.effectType)
     if destrType == DestructiblesCache.DESTR_TYPE_TREE or destrType == DestructiblesCache.DESTR_TYPE_FALLING_ATOM:
         chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, lArgs.chunkID)
         destrMatrix = BigWorld.wg_getDestructibleMatrix(self.__spaceID, lArgs.chunkID, lArgs.destrIndex)
         direction = destrMatrix.applyVector((0, 0, 1))
         pos = chunkMatrix.translation + destrMatrix.translation
         if destrType == DestructiblesCache.DESTR_TYPE_TREE:
             treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
             scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
         else:
             scale = BigWorld.wg_getDestructibleEffectScale(self.__spaceID, lArgs.chunkID, lArgs.destrIndex, lArgs.moduleIndex)
     else:
         hpMatrix = BigWorld.wg_getNMHardPointMatrix(self.__spaceID, lArgs.chunkID, lArgs.destrIndex, lArgs.moduleIndex)
         direction = hpMatrix.applyVector((0, 0, 1))
         pos = hpMatrix.translation
         scale = BigWorld.wg_getDestructibleEffectScale(self.__spaceID, lArgs.chunkID, lArgs.destrIndex, lArgs.moduleIndex)
     lArgs = lArgs._replace(destrType=destrType, effectName=effectName, effectCategory=effectCat, pos=pos, dir=direction, scale=scale)
     return lArgs
 def __launchFallEffect(self, chunkID, destrIndex, effectName, fallDirYaw):
     player = BigWorld.player()
     if player is None:
         return
     else:
         desc = g_cache.getDestructibleDesc(self.__spaceID, chunkID, destrIndex)
         if desc is None:
             _printErrDescNotAvailable(self.__spaceID, chunkID, destrIndex)
             return
         effectVars = desc.get(effectName)
         if effectVars is None:
             return
         effectStuff = random.choice(effectVars)
         stages, effectList = effectStuff
         chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
         destrMatrix = BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex)
         pos = chunkMatrix.translation + destrMatrix.translation
         dir = Math.Vector3(math.sin(fallDirYaw), 0.0, math.cos(fallDirYaw))
         if desc['type'] == DESTR_TYPE_TREE:
             treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
             scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
         else:
             scale = desc['effectScale']
         player.terrainEffects.addNew(pos, effectList, stages, None, dir=dir, scale=scale)
         return
 def __launchEffect(self, chunkID, destrIndex, moduleIndex, effectType, isHavokVisible, callbackOnStop=None):
     destrType = BigWorld.wg_getDestructibleEffectCategory(self.__spaceID, chunkID, destrIndex, moduleIndex)
     effectCat = ""
     if destrType == DESTR_TYPE_TREE:
         effectCat = "trees"
     elif destrType == DESTR_TYPE_FALLING_ATOM:
         effectCat = "fallingAtoms"
     elif destrType == DESTR_TYPE_FRAGILE:
         effectCat = "fragiles"
     elif destrType == DESTR_TYPE_STRUCTURE:
         effectCat = "structures"
     effectName = BigWorld.wg_getDestructibleEffectName(self.__spaceID, chunkID, destrIndex, moduleIndex, effectType)
     if effectName == "none":
         return
     else:
         effectVars = g_cache._getEffect(effectName, effectCat, False)
         if effectVars is None:
             LOG_ERROR(
                 "Could not find any effects vars for: "
                 + str(effectName)
                 + " - type: "
                 + str(effectType)
                 + " - cat: "
                 + str(effectCat)
                 + " ("
                 + str(destrType)
                 + ")"
             )
             return
         if destrType == DESTR_TYPE_TREE or destrType == DESTR_TYPE_FALLING_ATOM:
             chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
             destrMatrix = BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex)
             dir = destrMatrix.applyVector((0, 0, 1))
             pos = chunkMatrix.translation + destrMatrix.translation
             if destrType == DESTR_TYPE_TREE:
                 treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
                 scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
             else:
                 scale = BigWorld.wg_getDestructibleEffectScale(self.__spaceID, chunkID, destrIndex, moduleIndex)
         else:
             hpMatrix = BigWorld.wg_getNMHardPointMatrix(self.__spaceID, chunkID, destrIndex, moduleIndex)
             dir = hpMatrix.applyVector((0, 0, 1))
             pos = hpMatrix.translation
             scale = BigWorld.wg_getDestructibleEffectScale(self.__spaceID, chunkID, destrIndex, moduleIndex)
         player = BigWorld.player()
         if player is None or isPlayerAccount():
             return
         effectStuff = random.choice(effectVars)
         effectID = player.terrainEffects.addNew(
             pos,
             effectStuff.effectsList,
             effectStuff.keyPoints,
             callbackOnStop,
             dir=dir,
             scale=scale,
             havokEnabled=isHavokVisible,
         )
         return effectID
 def __pickPrefferedTiltAngle(self, chunkID, destrIndex, hitDirYaw, desc):
     transformation = BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex)
     dYaw = transformation.yaw
     hitYaw_localFrame = hitDirYaw - dYaw
     tiltYaw_localFrame = min(desc['preferredTiltDirections'] or [hitYaw_localFrame], key=lambda angle: abs(angle - hitYaw_localFrame))
     if tiltYaw_localFrame > math.pi:
         tiltYaw_localFrame -= 2 * math.pi
     elif tiltYaw_localFrame < -math.pi:
         tiltYaw_localFrame += 2 * math.pi
     tiltYaw_worldFrame = tiltYaw_localFrame + dYaw
     return tiltYaw_worldFrame
 def __pickPrefferedTiltAngle(self, chunkID, destrIndex, hitDirYaw, desc):
     transformation = BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex)
     dYaw = transformation.yaw
     hitYaw_localFrame = hitDirYaw - dYaw
     tiltYaw_localFrame = min(desc['preferredTiltDirections'] or [hitYaw_localFrame], key=lambda angle: abs(angle - hitYaw_localFrame))
     if tiltYaw_localFrame > math.pi:
         tiltYaw_localFrame -= 2 * math.pi
     elif tiltYaw_localFrame < -math.pi:
         tiltYaw_localFrame += 2 * math.pi
     tiltYaw_worldFrame = tiltYaw_localFrame + dYaw
     return tiltYaw_worldFrame
Example #10
0
 def __launchEffect(self,
                    chunkID,
                    destrIndex,
                    desc,
                    effectType,
                    modelFile,
                    callbackOnStop=None):
     effectVars = desc.get(effectType)
     if effectVars is None:
         return
     else:
         type = desc.get('type')
         if type == DESTR_TYPE_TREE or type == DESTR_TYPE_FALLING_ATOM:
             chunkMatrix = BigWorld.wg_getChunkMatrix(
                 self.__spaceID, chunkID)
             destrMatrix = BigWorld.wg_getDestructibleMatrix(
                 self.__spaceID, chunkID, destrIndex)
             dir = destrMatrix.applyVector((0, 0, 1))
             pos = chunkMatrix.translation + destrMatrix.translation
             if type == DESTR_TYPE_TREE:
                 treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
                 scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
             else:
                 scale = desc['effectScale']
         else:
             hpMatrix = BigWorld.wg_getHardPointMatrix(
                 self.__spaceID, chunkID, destrIndex, desc['effectHP'])
             if hpMatrix is None:
                 LOG_ERROR("Can't find hardpoint %s in model %s" %
                           (desc['effectHP'], modelFile))
                 return
             dir = hpMatrix.applyVector((0, 0, 1))
             pos = hpMatrix.translation
             scale = desc['effectScale']
         player = BigWorld.player()
         if player is None:
             return
         effectStuff = random.choice(effectVars)
         stages, effectList = effectStuff
         effectID = player.terrainEffects.addNew(pos,
                                                 effectList,
                                                 stages,
                                                 callbackOnStop,
                                                 dir=dir,
                                                 scale=scale)
         return effectID
 def __launchFallEffect(self, chunkID, destrIndex, effectType, fallDirYaw):
     player = BigWorld.player()
     if player is None or isPlayerAccount():
         return
     else:
         effectName = BigWorld.wg_getDestructibleEffectName(self.__spaceID, chunkID, destrIndex, -1, effectType)
         if effectName == 'none':
             return
         effectVars = g_cache._getEffect(effectName, 'fallingAtoms', False)
         if effectVars is None:
             return
         effectStuff = random.choice(effectVars)
         chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
         destrMatrix = BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex)
         pos = chunkMatrix.translation + destrMatrix.translation
         dir = Math.Vector3(math.sin(fallDirYaw), 0.0, math.cos(fallDirYaw))
         scale = BigWorld.wg_getDestructibleEffectScale(self.__spaceID, chunkID, destrIndex, -1)
         player.terrainEffects.addNew(pos, effectStuff.effectsList, effectStuff.keyPoints, None, dir=dir, scale=scale)
         return
 def __launchEffect(self, chunkID, destrIndex, moduleIndex, effectType, isHavokVisible, callbackOnStop = None):
     destrType = BigWorld.wg_getDestructibleEffectCategory(self.__spaceID, chunkID, destrIndex, moduleIndex)
     effectCat = ''
     if destrType == DestructiblesCache.DESTR_TYPE_TREE:
         effectCat = 'trees'
     elif destrType == DestructiblesCache.DESTR_TYPE_FALLING_ATOM:
         effectCat = 'fallingAtoms'
     elif destrType == DestructiblesCache.DESTR_TYPE_FRAGILE:
         effectCat = 'fragiles'
     elif destrType == DestructiblesCache.DESTR_TYPE_STRUCTURE:
         effectCat = 'structures'
     effectName = BigWorld.wg_getDestructibleEffectName(self.__spaceID, chunkID, destrIndex, moduleIndex, effectType)
     if effectName == 'none':
         return
     else:
         effectVars = g_cache._getEffect(effectName, effectCat, False)
         if effectVars is None:
             LOG_ERROR('Could not find any effects vars for: ' + str(effectName) + ' - type: ' + str(effectType) + ' - cat: ' + str(effectCat) + ' (' + str(destrType) + ')')
             return
         if destrType == DestructiblesCache.DESTR_TYPE_TREE or destrType == DestructiblesCache.DESTR_TYPE_FALLING_ATOM:
             chunkMatrix = BigWorld.wg_getChunkMatrix(self.__spaceID, chunkID)
             destrMatrix = BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex)
             dir = destrMatrix.applyVector((0, 0, 1))
             pos = chunkMatrix.translation + destrMatrix.translation
             if destrType == DestructiblesCache.DESTR_TYPE_TREE:
                 treeScale = destrMatrix.applyVector((0.0, 1.0, 0.0)).length
                 scale = 1.0 + (treeScale - 1.0) * _TREE_EFFECTS_SCALE_RATIO
             else:
                 scale = BigWorld.wg_getDestructibleEffectScale(self.__spaceID, chunkID, destrIndex, moduleIndex)
         else:
             hpMatrix = BigWorld.wg_getNMHardPointMatrix(self.__spaceID, chunkID, destrIndex, moduleIndex)
             dir = hpMatrix.applyVector((0, 0, 1))
             pos = hpMatrix.translation
             scale = BigWorld.wg_getDestructibleEffectScale(self.__spaceID, chunkID, destrIndex, moduleIndex)
         player = BigWorld.player()
         if player is None or isPlayerAccount():
             return
         effectStuff = random.choice(effectVars)
         effectID = player.terrainEffects.addNew(pos, effectStuff.effectsList, effectStuff.keyPoints, callbackOnStop, dir=dir, scale=scale, havokEnabled=isHavokVisible)
         return effectID
Example #13
0
 def __getDestrInitialMatrix(self, chunkID, destrIndex):
     return self.__destrInitialMatrices.setdefault(
         (chunkID, destrIndex),
         BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID,
                                           destrIndex))
 def __getDestrInitialMatrix(self, chunkID, destrIndex):
     return self.__destrInitialMatrices.setdefault((chunkID, destrIndex), BigWorld.wg_getDestructibleMatrix(self.__spaceID, chunkID, destrIndex))
Example #15
0
 def getDestPos(spaceID, chunkID, destrIndex):
     chunkMatrix = BigWorld.wg_getChunkMatrix(spaceID, chunkID)
     destrMatrix = BigWorld.wg_getDestructibleMatrix(
         spaceID, chunkID, destrIndex)
     pos = chunkMatrix.translation + destrMatrix.translation
     return pos