Exemplo n.º 1
0
 def addEffect(self, path, visibleCondition, name, timed, delayRange = None):
     variant = 'OWN' if self.__context.isPlayer else 'OTHER'
     effectDB = db.DBLogic.g_instance.getEffectDataVariant(Effects.getEffectId(name), variant)
     if effectDB:
         effectType = effectDB['type']
         nodeId = self.__rootNode.resolvePath(convertPath(path)).id
         sound = None
         if 'SoundEffectID' in effectDB:
             sound = [nodeId, effectDB['SoundEffectID'], None]
         if effectType == 'Loft' or effectType == 'Jet':
             effectObject = LoftEffectObject(self.__context, len(self.__loftList), sound)
             self.__boolCombiner.addObject(visibleCondition, effectObject.onVisibleChange)
             self.addLoftToList(nodeId, effectObject.isVisible, effectDB, name)
             self.__registerDrawObj(effectObject)
         elif effectType == 'TimedParticle' or effectType == 'LoopParticle' or effectType == 'TrailParticle':
             resourceName = effectDB.get('particleFile', None)
             if resourceName:
                 objId = len(self.__particleList)
                 if timed or effectType == 'TimedParticle':
                     effectObject = TimeEffectObject(self.__context, objId, sound)
                 elif effectType == 'TrailParticle':
                     effectObject = TrailEffectObject(self.__context, objId, sound)
                 else:
                     effectObject = EffectObject(self.__context, objId, sound)
                 effectObject.instantHide = effectDB.get('instantHide', False)
                 self.__boolCombiner.addObject(visibleCondition, effectObject.onVisibleChange)
                 self.addParticleToList(nodeId, effectObject.isVisible, resourceName, name)
                 self.__registerDrawObj(effectObject)
         else:
             debug_utils.LOG_ERROR("Can't create effect {0}. Unsupported type {1} for compound model".format(Effects.getEffectId(name), effectType))
     else:
         debug_utils.LOG_WARNING_DEBUG("Can't create effect {0}".format(Effects.getEffectId(name)))
     return
Exemplo n.º 2
0
 def setState(self, state, timeShift=0.0):
     UpdatableObjectBase.setState(self, state, timeShift)
     if IS_CLIENT and self._owner:
         curState = self.getState()
         if curState == UPDATABLE_STATE.DESTROY:
             if self._stateCB:
                 self._stateCB(UPDATABLE_STATE_CB.EXPLODED,
                               self._updatableTypeId, self)
                 self._stateCB = None
             if IS_CLIENT:
                 self.__updatableSound.stopSound()
             self.__collider = self.__collider or self.__getClientCollision(
             )
             explosionParticle = self.__shellDescription.explosionParticles.default
             if self.__collider:
                 self.position, materialName = self.__collider
                 if materialName == 'water':
                     explosionParticle = self.__shellDescription.explosionParticles.water
                 elif materialName == 'object':
                     explosionParticle = getattr(
                         self.__shellDescription.explosionParticles,
                         'object', explosionParticle)
             else:
                 LOG_ERROR(
                     "Can't find collision for UPDATABLE_STATE.DESTROY")
             rotation = Math.Vector3(uniform(0.0, radians(360.0)), 0.0, 0.0)
             EffectManager.g_instance.createWorldEffect(
                 Effects.getEffectId(explosionParticle), self.position,
                 {'rotation': rotation})
             if self._owner == BigWorld.player():
                 BigWorld.player().eOwnShellExplosion(
                     self.position, self.__shellDescription)
             self.destroy()
         elif curState == UPDATABLE_STATE.CREATE:
             if self.model:
                 self.model.visible = True
         elif curState == UPDATABLE_STATE.ON_THE_GROUND:
             self.__collider = self.__getClientCollision()
             if self.__collider:
                 self.position, materialName = self.__collider
                 if materialName == 'water':
                     self.__hideModel()
                     EffectManager.g_instance.createWorldEffect(
                         Effects.getEffectId(
                             'EFFECT_hit_water_rocket_bomb'), self.position,
                         {})
                 elif materialName == 'object':
                     self.__hideModel()
                     EffectManager.g_instance.createWorldEffect(
                         Effects.getEffectId('EFFECT_hit_smoke'),
                         self.position, {})
             else:
                 LOG_ERROR(
                     "Can't find collision for UPDATABLE_STATE.ON_THE_GROUND"
                 )
             if IS_CLIENT:
                 self.__updatableSound.stopSound()
     return
Exemplo n.º 3
0
    def __initHangar(self):
        from gui.Scaleform.utils.HangarSpace import g_hangarSpace
        if self.__delayedInitCB:
            BigWorld.cancelCallback(self.__delayedInitCB)
            self.__delayedInitCB = None
        self.__clear()
        if g_hangarSpace and g_hangarSpace.space:
            self.__model = BigWorld.Model(MODEL_NAME)
            if self.__model:
                self.__model.scale = (0.6, 0.6, 0.6)
                self.__model.actionScale = 0.5
                BigWorld.addModel(self.__model, g_hangarSpace.space.spaceID)
                positionHpMap = syncHpMap(HP_NAME)
                LOG_DEBUG('found HPs', positionHpMap)
                for k, hp in positionHpMap.iteritems():
                    self.__model.position = Math.Matrix(hp).translation
                    break

                self.__model.visible = True
                action = self.__model.action(ANIMATION_NAME)
                action()
                self.__effect = EffectManager.g_instance.createNodeAttachedEffect(
                    Effects.getEffectId(PARTICLE_NAME),
                    self.__model.node(ATTACH_HP), {})
                self.__soPlane = SoundObject('hangar_1st_of_April_plane', 0, 0)
                self.__soPlane.transform = self.__model.node(ATTACH_HP)
                self.__soPlane.postEvent(PLAY_SOUND_NAME, False, None)
                LOG_DEBUG('effect', PARTICLE_NAME, self.__effect)
                self.__hangarLoaded = True
            else:
                LOG_ERROR("can't load 1 april model", MODEL_NAME)
        else:
            self.__delayedInitCB = BigWorld.callback(HANGAR_INIT_DELAY,
                                                     self.__initHangar)
        return
Exemplo n.º 4
0
 def _checkStateSettings(self, transtitionActions=False):
     if self.inWorld:
         self.setGameState(self.state)
         self.controllers['modelManipulator'].setState(
             self.state, transtitionActions)
         if EntityStates.inState(self, EntityStates.CREATED):
             self.onRespawn()
         elif EntityStates.inState(self, EntityStates.DESTROYED):
             if transtitionActions:
                 LOG_DEBUG(
                     'TeamObject::_checkStateSettings - For object %s set effects %s to self.position'
                     % (self._settings.name,
                        self._settings.damageEffects.destroy))
                 EffectManager.g_instance.createWorldEffect(
                     Effects.getEffectId(
                         self._settings.damageEffects.destroy),
                     self.position, {})
             self._clearFromArena(False)
     if EntityStates.inState(self,
                             EntityStates.GAME | EntityStates.WAIT_START):
         self._addToArena()
         self.controllers['modelManipulator'].setVisible(True)
     self.__collisionStateUpdate(True)
     if EntityStates.inState(self,
                             EntityStates.GAME) and not self.vscriptStarted:
         self.vscriptStarted = True
         BigWorld.startEntityScripts(self)
     if self.vscriptStarted and not EntityStates.inState(
             self, EntityStates.GAME):
         self.vscriptStarted = False
         BigWorld.stopEntityScripts(self)
Exemplo n.º 5
0
 def worldEffect(actionData, environmentData):
     """create some effect with world transformation"""
     position = applyRadius(actionData.position, actionData)
     EffectManager.g_instance.createWorldEffect(
         Effects.getEffectId(actionData.effectName), position,
         {'rotation': actionData.rotation} if hasattr(
             actionData, 'rotation') else {})
Exemplo n.º 6
0
    def attachedEffect(actionData, environmentData):
        """attach some effect to object's mountPoint"""
        modelManipulator = environmentData.destructableObject.controllers[
            'modelManipulator']
        pathList = actionData.mountPoint.split('/')
        node = None
        partModel = 1
        if len(pathList) == 2 and pathList[0] in modelManipulator.namedParts:
            partModel = modelManipulator.namedParts[pathList[0]].getMainModel()
            if partModel:
                try:
                    node = partModel.model.node(pathList[1])
                except:
                    pass

        if node:
            EffectManager.g_instance.createNodeAttachedEffect(
                Effects.getEffectId(actionData.effectName), node, {})
        elif partModel:
            LOG_ERROR(
                'ClientScenarioActions: Wrong path for scenario attachedEffect!',
                environmentData.destructableObject._settings.typeName,
                environmentData.destructableObject.scenarioName,
                actionData.mountPoint)
        return
Exemplo n.º 7
0
 def onHangarLoaded(self):
     from gui.Scaleform.utils.HangarSpace import g_hangarSpace
     from gui.HangarScripts.PlaneBirthday import ConfigFactory
     if self.__isEnabled or not g_hangarSpace.space:
         return
     config = ConfigFactory.get(g_hangarSpace.space.spaceName)
     self.__model = BigWorld.Model(config.MODEL_NAME)
     if self.__model:
         EffectManager.Init()
         self.__model.scale = config.SCALE
         self.__model.actionScale = 4.0
         self.__model.visible = False
         BigWorld.addModel(self.__model, BigWorld.player().spaceID)
         self.__model.position = g_hangarSpace.space.getHangarPos(
         ) + config.TRANSLATION_VECTOR
         self.__model.visible = True
         action = self.__model.action(config.ANIMATION_NAME)
         action()
         LOG_DEBUG('onHangarLoaded hp',
                   [(hp, self.__model.node(hp))
                    for i, hp in enumerate(config.PARTICLE_HPS)])
         self.__effects = [
             EffectManager.g_instance.createNodeAttachedEffect(
                 Effects.getEffectId(config.PARTICLE_NAMES[i]),
                 self.__model.node(hp), {})
             for i, hp in enumerate(config.PARTICLE_HPS)
         ]
     else:
         LOG_ERROR("can't load model", config.MODEL_NAME)
     self.__isEnabled = True
Exemplo n.º 8
0
 def relativeEffect(actionData, environmentData):
     """create some effect with transformation, relative to parent destructible transformation"""
     matrix = Math.Matrix(environmentData.destructableObject.resMatrix)
     position = applyRadius(matrix.applyPoint(actionData.position),
                            actionData)
     EffectManager.g_instance.createWorldEffect(
         Effects.getEffectId(actionData.effectName), position,
         {'rotation': actionData.rotation} if hasattr(
             actionData, 'rotation') else {})
Exemplo n.º 9
0
def getBulletExplosionEffectFromMaterial(gd, materialName):
    if materialName == None:
        materialName = ''
    if hasattr(gd.explosionParticles, materialName):
        explosionEffectName = gd.explosionParticles.__dict__[materialName]
    else:
        explosionEffectName = gd.explosionParticles.default
    if explosionEffectName != '':
        return Effects.getEffectId(explosionEffectName)
    else:
        return
Exemplo n.º 10
0
 def setState(self, state, timeShift = 0.0):
     UpdatableObjectBase.setState(self, state, timeShift)
     if IS_CLIENT and self._owner:
         if self.getState() == UPDATABLE_STATE.DESTROY:
             position = self.position
             EffectManager.g_instance.createWorldEffect(Effects.getEffectId(self.__effectName), position, {})
             if IS_CLIENT:
                 self.__updatableSound.stopSound()
             self.onExplosion(self)
             self.destroy()
         if self.getState() == UPDATABLE_STATE.CREATE:
             if self.model:
                 self.model.visible = True
Exemplo n.º 11
0
 def __onTimer(self, lineIndex):
     timeline = self.TIMELINES[lineIndex]
     particle = choice(timeline['PARTICLES'])
     pos = choice(timeline['POSITIONS'])
     linetimers = timeline['TIMERS']
     if EffectManager.g_instance:
         EffectManager.g_instance.createWorldEffect(
             Effects.getEffectId(particle), pos, {})
     self.__timers[lineIndex] += 1
     if self.__timers[lineIndex] >= len(linetimers):
         self.__timers[lineIndex] = 0
     t = linetimers[self.__timers[lineIndex]]
     self.__callbacks[lineIndex] = BigWorld.callback(
         randint(t[0], t[1]), partial(self.__onTimer, lineIndex))
Exemplo n.º 12
0
 def __createDropModel(self, dropModelObject, hardpoints, resourceName):
     variant = 'OWN' if self.__context.isPlayer else 'OTHER'
     effectDB = db.DBLogic.g_instance.getEffectDataVariant(Effects.getEffectId('FALLING_OUT_PART'), variant)
     hierarchy = [(-1, Math.Matrix())]
     if 'HP_hit' in hardpoints:
         hierarchy.append((0, hardpoints['HP_hit']))
         particleList = [(1, True, effectDB['particleFile'])]
     else:
         particleList = []
     matrix = BigWorld.DropMatrixProvider()
     matrixProviders = [(0, matrix)]
     modelList = [(0, True, resourceName)]
     self.__compoundsForLoad += 1
     cid = CompoundSystem.addDynamicModel(hierarchy, matrixProviders, modelList, particleList, [], self.__onCompoundLoaded)
     dropModelObject.cid = cid
     dropModelObject.matrix = matrix
Exemplo n.º 13
0
 def setState(self, state, timeShift=0.0):
     UpdatableObjectBase.setState(self, state, timeShift)
     if IS_CLIENT and self._owner:
         if self.getState() == UPDATABLE_STATE.EXPLODED:
             if self.model:
                 mesh = self.model
                 self.model = None
                 self.model = BigWorld.Model('objects/fake_model.model')
                 if self.model.motors:
                     self.model.delMotor(self.model.motors[0])
                 self.model.addMotor(BigWorld.Servo(self.matrix))
                 BigWorld.addModel(self.model)
                 self._rocketEffect.reAttachToNode(self.model.root)
                 BigWorld.delModel(mesh)
             if self._stateCB:
                 self._stateCB(UPDATABLE_STATE_CB.EXPLODED,
                               self._updatableTypeId, self)
                 self._stateCB = None
             if self._rocketEffect:
                 self._rocketEffect.stopEmission()
             position = self.position
             materialName = None
             nearestCollision = self.__findNearestCollision(
                 self.position - self._startVector * 2,
                 self.position + self._startVector * 2)
             if nearestCollision:
                 position, matId = nearestCollision
                 if matId != None:
                     materialName = db.DBLogic.g_instance.getMaterialName(
                         matId)
             explosionParticle = self.__shellDescription.explosionParticles.water if materialName == 'water' else self.__shellDescription.explosionParticles.default
             EffectManager.g_instance.createWorldEffect(
                 Effects.getEffectId(explosionParticle), position, {})
             self.__updatableSound.stopSound()
             if self._owner == BigWorld.player():
                 BigWorld.player().eOwnShellExplosion(
                     position, self.__shellDescription)
         elif self.getState() == UPDATABLE_STATE.DESTROY:
             self.destroy()
         elif self.getState() == UPDATABLE_STATE.CREATE:
             if self.model:
                 self.model.visible = True
     return
Exemplo n.º 14
0
    def onClientBulletExplosion(gd, contacts, isPlayer, victim, bulletDir):
        materialId = isTeamObject(victim) and 254 or 255
        materialName = db.DBLogic.g_instance.getMaterialName(materialId)
        if hasattr(gd.explosionParticles, materialName):
            explosionEffectName = gd.explosionParticles.__dict__[materialName]
        else:
            explosionEffectName = gd.explosionParticles.default
        if explosionEffectName:
            import Avatar
            for position, partID, bbox, armor in contacts:
                Avatar.onBulletExplosion(
                    Effects.getEffectId(explosionEffectName), isPlayer,
                    position,
                    bulletDir if materialName == 'aircraft' else None, victim)
                if isPlayer:
                    Weapons.debug_addBulletCollisionEffects(
                        explosionEffectName)
                    Weapons.debug_drawBulletCollisionLines(position)

        return
Exemplo n.º 15
0
 def __setModel(self):
     self.model.position = self.position
     scaleMatrix = Math.Matrix()
     scaleMatrix.setScale((AIRCRAFT_MODEL_SCALING, AIRCRAFT_MODEL_SCALING,
                           AIRCRAFT_MODEL_SCALING))
     self.matrix = Math.Matrix()
     self.matrix.setRotateYPR(
         (self._startVector.yaw, self._startVector.pitch, 0.0))
     self.matrix.preMultiply(scaleMatrix)
     self.matrix.translation = self.position
     servo = BigWorld.Servo(self.matrix)
     self.model.addMotor(servo)
     BigWorld.addModel(self.model)
     self.model.visible = self.getState() == UPDATABLE_STATE.CREATE
     self._rocketEffect = EffectManager.g_instance.createNodeAttachedEffect(
         Effects.getEffectId(self.__shellDescription.particleSmoke),
         self.model.node('HP_flame'), {'uniqueId': str(self._id)})
     if self._stateCB:
         self._stateCB(UPDATABLE_STATE_CB.MODEL_LOADED,
                       self._updatableTypeId, self)
Exemplo n.º 16
0
 def spawnFlaresInPosition(self, position, flareType):
     effectName = SETTINGS.SIGNAL_FLARE_EFFECTS[flareType]
     effectId = Effects.getEffectId(effectName)
     EffectManager.g_instance.createWorldEffect(effectId, position, {})
Exemplo n.º 17
0
def onBulletExplosion(effectName, end):
    EffectManager.g_instance.createWorldEffect(Effects.getEffectId(effectName),
                                               end, {})
Exemplo n.º 18
0
 def __setModel(self):
     self.model.position = self.position
     self.__matrix = BigWorld.MatrixBalisticMoveProvider(self.position, self._endPosition, self._startVector)
     self.__matrix.scaleMatrix = self.__scaleMatrix
     self.__matrix.koefA = self.__koefA
     self.__matrix.koefB = self.__koefB
     self.__matrix.startSpeed = self.__shellDescription.startSpeed
     self.__matrix.acceleration = self.__shellDescription.acceleration
     servo = BigWorld.Servo(self.__matrix)
     self.model.addMotor(servo)
     BigWorld.addModel(self.model)
     self.model.visible = self.getState() == UPDATABLE_STATE.CREATE
     try:
         self.__attachedEffect = EffectManager.g_instance.createNodeAttachedEffect(Effects.getEffectId(self.__shellDescription.particleSmoke), self.model.node('HP_flame'), {'uniqueId': str(self._id)})
     except ValueError:
         LOG_ERROR('Ballistic: No node named HP_flame in model ', self.model.sources)