コード例 #1
0
    def set_damageStickers(self, prev=None):
        if not self.isAlive():
            return
        else:
            prev = self.__prevDamageStickers
            curr = frozenset(self.damageStickers)
            self.__prevDamageStickers = curr
            for sticker in prev.difference(curr):
                for damageStickers in self.__activeStateResource.damageStickers.itervalues(
                ):
                    damageStickers.delDamageSticker(sticker)

            for sticker in curr.difference(prev):
                hitCompIndx, stickerID, segStart, segEnd = DamageFromShotDecoder.decodeSegment(
                    sticker, self.__activeStateResource.collisionComponent)
                if hitCompIndx is None:
                    return
                if hitCompIndx not in self.__activeStateResource.damageStickers:
                    LOG_ERROR(
                        'component is not available for damage sticker: ',
                        hitCompIndx)
                    continue
                segStart, segEnd = self.__activeStateResource.reduceSegmentLength(
                    hitCompIndx, segStart, segEnd)
                self.__activeStateResource.damageStickers[
                    hitCompIndx].addDamageSticker(sticker, stickerID, segStart,
                                                  segEnd)

            return
コード例 #2
0
    def set_damageStickers(self, prev=None):
        if self.isStarted:
            prev = self.__prevDamageStickers
            curr = frozenset(self.damageStickers)
            self.__prevDamageStickers = curr
            for sticker in prev.difference(curr):
                self.appearance.removeDamageSticker(sticker)

            for sticker in curr.difference(prev):
                self.appearance.addDamageSticker(sticker, *DamageFromShotDecoder.decodeSegment(sticker, self.appearance.collisions))
コード例 #3
0
ファイル: vehicle.py プロジェクト: Bouilloire/WoTConfig
    def set_damageStickers(self, prev = None):
        if self.isStarted:
            prev = self.__prevDamageStickers
            curr = frozenset(self.damageStickers)
            self.__prevDamageStickers = curr
            for sticker in prev.difference(curr):
                self.appearance.removeDamageSticker(sticker)

            descr = self.typeDescriptor
            for sticker in curr.difference(prev):
                self.appearance.addDamageSticker(sticker, *DamageFromShotDecoder.decodeSegment(sticker, descr))
コード例 #4
0
    def set_damageStickers(self, prev=None):
        if self.isStarted:
            prev = self.__prevDamageStickers
            curr = frozenset(self.damageStickers)
            self.__prevDamageStickers = curr
            for sticker in prev.difference(curr):
                self.appearance.removeDamageSticker(sticker)

            maxComponentIdx = TankPartIndexes.ALL[-1]
            wheelsConfig = self.appearance.typeDescriptor.chassis.generalWheelsAnimatorConfig
            if wheelsConfig:
                maxComponentIdx = maxComponentIdx + wheelsConfig.getNonTrackWheelsCount(
                )
            for sticker in curr.difference(prev):
                self.appearance.addDamageSticker(
                    sticker,
                    *DamageFromShotDecoder.decodeSegment(
                        sticker, self.appearance.collisions, maxComponentIdx))
コード例 #5
0
 def new_showDamageFromShot(self, attackerID, points, effectsIndex,
                            damageFactor, *a, **k):
     if LOG_EVENTS and attackerID > 0:
         player = BigWorld.player()
         #Initial info
         points_count = len(points) if points else 0
         timeLeft, timeLeftSec = getTimeLeft()
         eventInfo = [
             '%s' % player.arenaUniqueID, timeLeft, timeLeftSec,
             '"Vehicle.showDamageFromShot"',
             '%s' % player.arena.vehicles[self.id].get('accountDBID', '-'),
             '%s' %
             player.arena.vehicles[attackerID].get('accountDBID', '-'),
             json.dumps({
                 'points': points_count,
                 'effectsIndex': effectsIndex,
                 'damageFactor': damageFactor
             })
         ]
         #Decode info
         shellInfo = {}
         for shot in player.arena.vehicles[attackerID][
                 'vehicleType'].gun.shots:
             if effectsIndex == shot.shell.effectsIndex:
                 shellInfo['name'] = shot.shell.name
                 shellInfo['kind'] = shellTypeAbb(shot.shell.kind)
                 shellInfo['damage'] = str(shot.shell.damage)
                 shellInfo['caliber'] = shot.shell.caliber
                 shellInfo['piercingPower'] = str(shot.piercingPower)
                 shellInfo['speed'] = round(shot.speed / 0.8, 3)
                 shellInfo['gravity'] = round(shot.gravity / 0.64, 3)
                 shellInfo['maxDistance'] = shot.maxDistance
                 if shot.shell.kind == 'HIGH_EXPLOSIVE':
                     shellInfo[
                         'explosionRadius'] = shot.shell.type.explosionRadius
                 break
         eventInfo.append(json.dumps(shellInfo) if shellInfo else '')
         maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints(
             points, self.appearance.collisions)
         hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode)
         attacker = BigWorld.entities.get(attackerID, None)
         attackerPos = attacker.position if isinstance(
             attacker, Vehicle
         ) and attacker.inWorld and attacker.isStarted else player.arena.positions.get(
             attackerID)
         eventInfo.append(
             json.dumps({
                 'maxHitEffectCode':
                 VEHICLE_HIT_EFFECT_NAMES.get(maxHitEffectCode),
                 'maxDamagedComponent':
                 maxDamagedComponent,
                 'hasPiercedHit':
                 hasPiercedHit,
                 'distance':
                 round(self.position.distTo(attackerPos), 3)
                 if attackerPos else None,
                 'hitPoints': [{
                     'componentName': point.componentName,
                     'hitEffectGroup': point.hitEffectGroup
                 } for point in decodedPoints] if decodedPoints else None
             }))
         for num, encodedPoint in enumerate(points, 1):
             hitsInfo = []  #[[Dir1-Layer1, ...], [Dir2-Layer1, ...], ...]
             hitsScheme = None
             compIdx, hitEffectCode, startPoint, endPoint = DamageFromShotDecoder.decodeSegment(
                 encodedPoint, self.appearance.collisions,
                 TankPartIndexes.ALL[-1])
             if compIdx >= 0 and startPoint != endPoint:
                 convertedCompIdx = DamageFromShotDecoder.convertComponentIndex(
                     compIdx)
                 bbox = self.appearance.collisions.getBoundingBox(
                     convertedCompIdx)
                 width, height, depth = (bbox[1] - bbox[0]) / 256.0
                 if COLLIDE_MULTI:
                     if COLLIDE_SCHEME == 'hexahedron':
                         hitsScheme = _CSHexahedron(width, height, depth,
                                                    COLLIDE_SCALE)
                     elif COLLIDE_SCHEME == 'cross':
                         hitsScheme = _CSCross(width, height, depth,
                                               COLLIDE_SCALE)
                     else:
                         hitsScheme = _CSCenter()
                 else:
                     hitsScheme = _CSCenter()
                 compMatrix = Matrix(
                     self.appearance.compoundModel.node(
                         TankPartIndexes.getName(convertedCompIdx)))
                 firstHitDir = endPoint - startPoint
                 firstHitDir.normalise()
                 firstHitDir = compMatrix.applyVector(firstHitDir)
                 firstHitPos = compMatrix.applyPoint(startPoint)
                 for direction in hitsScheme.directions:
                     hitInfo = []
                     collisions = self.appearance.collisions.collideAllWorld(
                         firstHitPos - firstHitDir.scale(COLLIDE_INDENT) +
                         direction, firstHitPos +
                         firstHitDir.scale(COLLIDE_LENGTH) + direction)
                     if collisions:
                         base = None
                         testPointAdded = collidePointAdded = False
                         for collision in collisions:
                             if collision[3] in TankPartIndexes.ALL:
                                 if base is None:
                                     base = collision[0]
                                 if not testPointAdded:
                                     if collision[0] > COLLIDE_INDENT:
                                         hitInfo.append(
                                             'TestPoint%s(distance=%s, tankPart=%s)'
                                             %
                                             (num
                                              if points_count > 1 else '',
                                              round(COLLIDE_INDENT - base,
                                                    4),
                                              TankPartIndexes.getName(
                                                  convertedCompIdx)))
                                         testPointAdded = True
                                 material = self.getMatinfo(
                                     collision[3], collision[2])
                                 hitInfo.append({
                                     'distance':
                                     round(collision[0] - base, 4),
                                     'angleCos':
                                     round(collision[1], 4),
                                     'tankPart':
                                     TankPartIndexes.getName(collision[3]),
                                     'armor':
                                     round(material.armor, 4)
                                     if material else None
                                 })
                                 if not collidePointAdded:
                                     collidePointAdded = True
                                 if material and material.vehicleDamageFactor > 0 and collision[
                                         3] in (TankPartIndexes.HULL,
                                                TankPartIndexes.TURRET):
                                     break
                         if collidePointAdded:
                             if not testPointAdded and base is not None:
                                 hitInfo.append(
                                     'TestPoint%s(distance=%s, tankPart=%s)'
                                     % (num if points_count > 1 else '',
                                        round(COLLIDE_INDENT - base, 4),
                                        TankPartIndexes.getName(
                                            convertedCompIdx)))
                     hitsInfo.append(hitInfo)
             eventInfo.append(json.dumps('%s: %s' % ('TestPoint%d' % num if points_count > 1 else 'layers' if hitsScheme.NAME == 'center' else 'TestPoint', \
                                                     hitsScheme.format(hitsInfo[0] if hitsScheme.NAME == 'center' else hitsInfo) if hitsScheme else '[]')))
         printStrings(LOG_EVENTS_FILENAME, eventInfo)