def showDamageFromShot(self, attackerID, points, effectsIndex, damageFactor): if not self.isStarted: return else: effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints(points, self.typeDescriptor) hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode) firstHitDir = Math.Vector3(0) if decodedPoints: firstHitPoint = decodedPoints[0] compoundModel = self.appearance.compoundModel compMatrix = Math.Matrix(compoundModel.node(firstHitPoint.componentName)) firstHitDirLocal = firstHitPoint.matrix.applyToAxis(2) firstHitDir = compMatrix.applyVector(firstHitDirLocal) self.appearance.receiveShotImpulse(firstHitDir, effectsDescr['targetImpulse']) self.appearance.executeHitVibrations(maxHitEffectCode) player = BigWorld.player() player.inputHandler.onVehicleShaken(self, compMatrix.translation, firstHitDir, effectsDescr['caliber'], ShakeReason.HIT if hasPiercedHit else ShakeReason.HIT_NO_DAMAGE) for shotPoint in decodedPoints: showFullscreenEffs = self.isPlayerVehicle and self.isAlive() keyPoints, effects, _ = effectsDescr[shotPoint.hitEffectGroup] self.appearance.boundEffects.addNewToNode(shotPoint.componentName, shotPoint.matrix, effects, keyPoints, isPlayerVehicle=self.isPlayerVehicle, showShockWave=showFullscreenEffs, showFlashBang=showFullscreenEffs, entity_id=self.id, damageFactor=damageFactor, attackerID=attackerID, hitdir=firstHitDir) if not self.isAlive(): return if attackerID == BigWorld.player().playerVehicleID and maxHitEffectCode is not None and not self.isPlayerVehicle: if hasPiercedHit: eventID = _GUI_EVENT_ID.VEHICLE_ARMOR_PIERCED else: eventID = _GUI_EVENT_ID.VEHICLE_HIT ctrl = g_sessionProvider.shared.feedback if ctrl is not None: ctrl.setVehicleState(self.id, eventID) return
def showDamageFromShot(self, attackerID, points, effectsIndex, damageFactor): if not self.isStarted: return else: effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints( points, self.typeDescriptor) hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode) firstHitDir = Math.Vector3(0) if decodedPoints: firstHitPoint = decodedPoints[0] compoundModel = self.appearance.compoundModel compMatrix = Math.Matrix( compoundModel.node(firstHitPoint.componentName)) firstHitDirLocal = firstHitPoint.matrix.applyToAxis(2) firstHitDir = compMatrix.applyVector(firstHitDirLocal) self.appearance.receiveShotImpulse( firstHitDir, effectsDescr['targetImpulse']) self.appearance.executeHitVibrations(maxHitEffectCode) player = BigWorld.player() player.inputHandler.onVehicleShaken( self, compMatrix.translation, firstHitDir, effectsDescr['caliber'], ShakeReason.HIT if hasPiercedHit else ShakeReason.HIT_NO_DAMAGE) for shotPoint in decodedPoints: showFullscreenEffs = self.isPlayerVehicle and self.isAlive() keyPoints, effects, _ = effectsDescr[shotPoint.hitEffectGroup] self.appearance.boundEffects.addNewToNode( shotPoint.componentName, shotPoint.matrix, effects, keyPoints, isPlayerVehicle=self.isPlayerVehicle, showShockWave=showFullscreenEffs, showFlashBang=showFullscreenEffs, entity_id=self.id, damageFactor=damageFactor, attackerID=attackerID, hitdir=firstHitDir) if not self.isAlive(): return if attackerID == BigWorld.player( ).playerVehicleID and maxHitEffectCode is not None and not self.isPlayerVehicle: if maxHitEffectCode in VEHICLE_HIT_EFFECT.RICOCHETS: eventID = _GUI_EVENT_ID.VEHICLE_RICOCHET elif maxHitEffectCode == VEHICLE_HIT_EFFECT.CRITICAL_HIT and damageFactor == 0.0: if maxDamagedComponent == TankPartNames.CHASSIS: eventID = _GUI_EVENT_ID.VEHICLE_CRITICAL_HIT_CHASSIS else: eventID = _GUI_EVENT_ID.VEHICLE_CRITICAL_HIT elif hasPiercedHit: eventID = _GUI_EVENT_ID.VEHICLE_ARMOR_PIERCED else: eventID = _GUI_EVENT_ID.VEHICLE_HIT ctrl = self.guiSessionProvider.shared.feedback if ctrl is not None: ctrl.setVehicleState(self.id, eventID) return
def showDamageFromShot(self, attackerID, points, effectsIndex): if not self.isStarted: return effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints(points, self.typeDescriptor) hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode) for shotPoint in decodedPoints: showFullscreenEffs = self.isPlayer and self.isAlive() keyPoints, effects, _ = effectsDescr[shotPoint.hitEffectGroup] self.appearance.modelsDesc[shotPoint.componentName]['boundEffects'].addNew(shotPoint.matrix, effects, keyPoints, isPlayer=self.isPlayer, showShockWave=showFullscreenEffs, showFlashBang=showFullscreenEffs, entity_id=self.id) if decodedPoints: firstHitPoint = decodedPoints[0] compMatrix = Math.Matrix(self.appearance.modelsDesc[firstHitPoint.componentName]['model'].matrix) firstHitDirLocal = firstHitPoint.matrix.applyToAxis(2) firstHitDir = compMatrix.applyVector(firstHitDirLocal) self.appearance.receiveShotImpulse(firstHitDir, effectsDescr['targetImpulse']) self.appearance.executeHitVibrations(maxHitEffectCode) player = BigWorld.player() player.inputHandler.onVehicleShaken(self, compMatrix.translation, firstHitDir, effectsDescr['caliber'], ShakeReason.HIT if hasPiercedHit else ShakeReason.HIT_NO_DAMAGE) self.__hitType = effectsIndex if not hasPiercedHit: self.damage_announce(attackerID, 0) if not self.isAlive(): return if attackerID == BigWorld.player().playerVehicleID and maxHitEffectCode is not None and not self.isPlayer: marker = getattr(self, 'marker', None) if marker is not None: manager = g_windowsManager.battleWindow.markersManager manager.updateMarkerState(marker, 'hit_pierced' if hasPiercedHit else 'hit')
def showDamageFromShot(self, attackerID, points, effectsIndex): if not self.isStarted: return effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints( points, self.typeDescriptor) hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode) for shotPoint in decodedPoints: showFullscreenEffs = self.isPlayer and self.isAlive() keyPoints, effects, _ = effectsDescr[shotPoint.hitEffectGroup] self.appearance.modelsDesc[ shotPoint.componentName]['boundEffects'].addNew( shotPoint.matrix, effects, keyPoints, isPlayer=self.isPlayer, showShockWave=showFullscreenEffs, showFlashBang=showFullscreenEffs, entity_id=self.id) if decodedPoints: firstHitPoint = decodedPoints[0] compMatrix = Math.Matrix(self.appearance.modelsDesc[ firstHitPoint.componentName]['model'].matrix) firstHitDirLocal = firstHitPoint.matrix.applyToAxis(2) firstHitDir = compMatrix.applyVector(firstHitDirLocal) self.appearance.receiveShotImpulse(firstHitDir, effectsDescr['targetImpulse']) self.appearance.executeHitVibrations(maxHitEffectCode) player = BigWorld.player() player.inputHandler.onVehicleShaken( self, compMatrix.translation, firstHitDir, effectsDescr['caliber'], ShakeReason.HIT if hasPiercedHit else ShakeReason.HIT_NO_DAMAGE) self.__hitType = effectsIndex if not hasPiercedHit: self.damage_announce(attackerID, 0) if not self.isAlive(): return if attackerID == BigWorld.player( ).playerVehicleID and maxHitEffectCode is not None and not self.isPlayer: marker = getattr(self, 'marker', None) if marker is not None: manager = g_windowsManager.battleWindow.vMarkersManager manager.updateMarkerState( marker, 'hit_pierced' if hasPiercedHit else 'hit')
def shot(self, vehicle, attacker_id, points, effects_index): if not (_config.data['enabled'] and self.on_off): return if not vehicle.isStarted: return if not vehicle.isPlayerVehicle: return if BigWorld.player().team == BigWorld.player().arena.vehicles.get(attacker_id)['team']: return if vehicle.health < 1: return self.shots += 1 index_hit, decode_comp_name = DamageFromShotDecoder.decodeHitPoints(points, vehicle.typeDescriptor) #compName = decode_comp_name[0].componentName if decode_comp_name else None has_pierced_hit = index_hit >= VEHICLE_HIT_EFFECT.ARMOR_PIERCED is_blocked = self.blocked_armor_hit(vehicle, decode_comp_name[0]) if decode_comp_name else False if is_blocked: for shell in BigWorld.player().arena.vehicles.get(attacker_id)['vehicleType'].gun['shots']: if effects_index == shell['shell']['effectsIndex']: type_shell = shell['shell']['kind'] if type_shell != 'HIGH_EXPLOSIVE': self.avgDMG, _ = shell['shell']['damage'] if has_pierced_hit: self.list[self.shots] = { 'id' : attacker_id, 'avgDMG' : self.avgDMG, 'isDamage': False, 'used' : False } BigWorld.callback(0.15, partial(self.shout_damage_hp, self.shots)) else: self.shout_damage() break else: self.clear_data()
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): if vehicle.isPlayerVehicle and self.isAlive: self.isAlive = vehicle.health > 0 self.data['isDamage'] = damageFactor > 0 maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints( points, vehicle.typeDescriptor) self.data['compName'] = decodedPoints[ 0].componentName if decodedPoints else 'do_not_know' self.data['maxHitEffectCode'] = maxHitEffectCode self.data['attackReasonID'] = 0 self.data['attackerID'] = attackerID self.data['isDamage'] = damageFactor > 0 self.data['splash-hit'] = 'no-splash' if (effectsIndex == 24) or (effectsIndex == 25): self.data['attackReasonID'] = effectsIndex self.typeShell(effectsIndex) if (maxHitEffectCode < 4): self.data['HIT_EFFECT_CODE'] = HIT_EFFECT_CODES[ maxHitEffectCode] self.data['dmg'] = 0 self.updateData() elif (maxHitEffectCode == 5) and (damageFactor == 0): self.data['HIT_EFFECT_CODE'] = 'armor_pierced_no_damage' self.data['dmg'] = 0 self.updateData() elif maxHitEffectCode == 4: self.data['HIT_EFFECT_CODE'] = 'armor_pierced'
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
def showDamageFromShot(self, points, effectsIndex): maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints(points, self.__vehDescr) for shotPoint in decodedPoints: if shotPoint.componentName == TankPartNames.TURRET or shotPoint.componentName == TankPartNames.GUN: self.__hitEffects.showHit(shotPoint, effectsIndex, shotPoint.componentName) else: LOG_ERROR("Detached turret got hit into %s component, but it's impossible" % shotPoint.componentName)
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints(points, vehicle.typeDescriptor) self.data['compName'] = decodedPoints[0].componentName if decodedPoints else 'unknown' self.data['splashHit'] = 'no-splash' self.data['criticalHit'] = (maxHitEffectCode == 5) if damageFactor == 0: self.data['hitEffect'] = HIT_EFFECT_CODES[min(3, maxHitEffectCode)] self.hitShell(attackerID, effectsIndex, damageFactor)
def showDamageFromShot(self, points, effectsIndex): (maxHitEffectCode, decodedPoints,) = DamageFromShotDecoder.decodeHitPoints(points, self.__vehDescr) for shotPoint in decodedPoints: hitEffects = self.__hitEffects.get(shotPoint.componentName) if hitEffects is not None: hitEffects.showHit(shotPoint, effectsIndex) else: LOG_ERROR("Detached turret got hit into %s component, but it's impossible" % shotPoint.componentName)
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints(points, vehicle.typeDescriptor) self.data['compName'] = decodedPoints[0].componentName if decodedPoints else 'unknown' self.data['splashHit'] = 'no-splash' self.data['criticalHit'] = (maxHitEffectCode == 5) if damageFactor == 0: self.data['hitEffect'] = HIT_EFFECT_CODES[min(3, maxHitEffectCode)] self.data['isAlive'] = bool(vehicle.isCrewActive) self.hitShell(attackerID, effectsIndex, damageFactor)
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))
def showDamageFromShot(self, attackerID, points, effectsIndex): if not self.isStarted: return effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints( points, self.typeDescriptor) hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode) for shotPoint in decodedPoints: showFullscreenEffs = self.isPlayer and self.isAlive() keyPoints, effects, _ = effectsDescr[shotPoint.hitEffectGroup] self.appearance.modelsDesc[ shotPoint.componentName]['boundEffects'].addNew( shotPoint.matrix, effects, keyPoints, isPlayer=self.isPlayer, showShockWave=showFullscreenEffs, showFlashBang=showFullscreenEffs, entity_id=self.id) if decodedPoints: firstHitPoint = decodedPoints[0] compMatrix = Math.Matrix(self.appearance.modelsDesc[ firstHitPoint.componentName]['model'].matrix) firstHitDirLocal = firstHitPoint.matrix.applyToAxis(2) firstHitDir = compMatrix.applyVector(firstHitDirLocal) self.appearance.receiveShotImpulse(firstHitDir, effectsDescr['targetImpulse']) self.appearance.executeHitVibrations(maxHitEffectCode) player = BigWorld.player() player.inputHandler.onVehicleShaken( self, compMatrix.translation, firstHitDir, effectsDescr['caliber'], ShakeReason.HIT if hasPiercedHit else ShakeReason.HIT_NO_DAMAGE) if not self.isAlive(): return if attackerID == BigWorld.player( ).playerVehicleID and maxHitEffectCode is not None and not self.isPlayer: if hasPiercedHit: eventID = _GUI_EVENT_ID.VEHICLE_ARMOR_PIERCED else: eventID = _GUI_EVENT_ID.VEHICLE_HIT g_sessionProvider.getFeedback().setVehicleState(self.id, eventID)
def showDamageFromShot(self, points, effectsIndex): maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints( points, self.__vehDescr) for shotPoint in decodedPoints: hitEffects = self.__hitEffects.get(shotPoint.componentName) if hitEffects is not None: hitEffects.showHit(shotPoint, effectsIndex) else: LOG_ERROR( "Detached turret got hit into %s component, but it's impossible" % shotPoint.componentName)
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): if not vehicle.isStarted: return maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints(points, vehicle.appearance.collisions) self.data['compName'] = decodedPoints[0].componentName if decodedPoints else 'unknown' # self.data['criticalHit'] = (maxHitEffectCode == 5) if not self.data['isDamage']: self.data['hitEffect'] = HIT_EFFECT_CODES[min(3, maxHitEffectCode)] self.data['isAlive'] = bool(vehicle.isCrewActive) self.hitShell(attackerID, effectsIndex, damageFactor)
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))
def new_showDamageFromShot(self, attackerID, points, effectsIndex, damageFactor, *a, **k): if LOG_EVENTS: player = BigWorld.player() shellName = '' for shot in player.arena.vehicles[attackerID]['vehicleType'].gun.shots: if effectsIndex == shot.shell.effectsIndex: shellName = shot.shell.name g_replayCtrl = BattleReplay.g_replayCtrl effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints(points, self.appearance.collisions) hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode) eventInfo = ('%s' % player.arenaUniqueID, ('%.3f' % (g_replayCtrl.getArenaLength() if g_replayCtrl.isPlaying else \ player.arena.periodEndTime - BigWorld.serverTime())).replace('.',','), '"Vehicle.showDamageFromShot"', '%s' % player.arena.vehicles[self.id]['accountDBID'], '%s' % player.arena.vehicles[attackerID]['accountDBID'], json.dumps({'effectsIndex':effectsIndex, 'shellName':shellName, 'damageFactor':damageFactor, \ 'maxHitEffectCode':VEHICLE_HIT_EFFECT_NAMES.get(maxHitEffectCode), 'maxDamagedComponent':maxDamagedComponent, \ 'hasPiercedHit':hasPiercedHit})) printStrings(LOG_EVENTS_FILENAME, eventInfo)
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): maxComponentIdx = TankPartIndexes.ALL[-1] wheelsConfig = vehicle.appearance.typeDescriptor.chassis.generalWheelsAnimatorConfig if wheelsConfig: maxComponentIdx += wheelsConfig.getWheelsCount() maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints(points, vehicle.appearance.collisions, maxComponentIdx) compName = decodedPoints[0].componentName if decodedPoints: self.data['compName'] = compName if compName[0] != 'W' else 'wheel' else: self.data['compName'] = 'unknown' self.data['criticalHit'] = (maxHitEffectCode == 5)
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): maxComponentIdx = TankPartIndexes.ALL[-1] wheelsConfig = vehicle.appearance.typeDescriptor.chassis.generalWheelsAnimatorConfig if wheelsConfig: maxComponentIdx += wheelsConfig.getWheelsCount() maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints( points, vehicle.appearance.collisions, maxComponentIdx) if decodedPoints: compName = decodedPoints[0].componentName self.compName = compName if compName[0] != 'W' else 'wheel' else: self.compName = 'unknown' self.criticalHit = (maxHitEffectCode == 5)
def new_showDamageFromShot(self, attackerID, points, effectsIndex, damageFactor): global PLAYER_SHOTS try: effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxHitEffectCode, _ = DamageFromShotDecoder.decodeHitPoints( points, self.typeDescriptor) if not attackerID in PLAYER_SHOTS: PLAYER_SHOTS[attackerID] = [] if DamageFromShotDecoder.hasDamaged(maxHitEffectCode): #С уроном for index in TANKS_STATISTICS[attackerID]['gun']['shell']: if 'effectsIndex' in TANKS_STATISTICS[attackerID]['gun'][ 'shell'][index]: if TANKS_STATISTICS[attackerID]['gun']['shell'][index][ 'effectsIndex'] == effectsIndex: PLAYER_SHOTS[attackerID].append( index) #Тип снаряда определен return PLAYER_SHOTS[attackerID] = [] #Без урона finally: if old_showDamageFromShot is not None: old_showDamageFromShot(self, attackerID, points, effectsIndex, damageFactor) return
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))
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): if not vehicle.isStarted: return maxComponentIdx = TankPartIndexes.ALL[-1] wheelsConfig = vehicle.appearance.typeDescriptor.chassis.generalWheelsAnimatorConfig if wheelsConfig: maxComponentIdx += wheelsConfig.getWheelsCount() maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints( points, vehicle.appearance.collisions, maxComponentIdx) self.data['compName'] = decodedPoints[ 0].componentName if decodedPoints else 'unknown' # self.data['criticalHit'] = (maxHitEffectCode == 5) if not self.data['isDamage']: self.data['hitEffect'] = HIT_EFFECT_CODES[min(3, maxHitEffectCode)] self.data['isAlive'] = bool(vehicle.isCrewActive) self.hitShell(attackerID, effectsIndex, damageFactor)
def showDamageFromShot(self, points, effectsIndex): hasPiercedHit = DamageFromShotDecoder.hasDamaged(effectsIndex) eventID = _GUI_EVENT_ID.VEHICLE_RICOCHET if effectsIndex is not None: if effectsIndex in VEHICLE_HIT_EFFECT.RICOCHETS: eventID = _GUI_EVENT_ID.VEHICLE_RICOCHET elif effectsIndex == VEHICLE_HIT_EFFECT.CRITICAL_HIT: eventID = _GUI_EVENT_ID.VEHICLE_CRITICAL_HIT elif hasPiercedHit: eventID = _GUI_EVENT_ID.VEHICLE_ARMOR_PIERCED else: eventID = _GUI_EVENT_ID.VEHICLE_HIT destructibleEntityComponent = BigWorld.player( ).arena.componentSystem.destructibleEntityComponent if destructibleEntityComponent is not None: destructibleEntityComponent.updateDestructibleEntityFeedback( self, eventID) return
def showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor): if not vehicle.isStarted: return maxComponentIdx = TankPartIndexes.ALL[-1] wheelsConfig = vehicle.appearance.typeDescriptor.chassis.generalWheelsAnimatorConfig if wheelsConfig: maxComponentIdx += wheelsConfig.getWheelsCount() maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints(points, vehicle.appearance.collisions, maxComponentIdx) compName = decodedPoints[0].componentName if decodedPoints: self.data['compName'] = compName if compName[0] != 'W' else 'wheel' else: self.data['compName'] = 'unknown' # self.data['criticalHit'] = (maxHitEffectCode == 5) if not self.data['isDamage']: self.data['hitEffect'] = HIT_EFFECT_CODES[min(3, maxHitEffectCode)] self.data['isAlive'] = bool(vehicle.isCrewActive) self.hitShell(attackerID, effectsIndex, damageFactor)
def addDamageSticker(self, code, componentIdx, stickerID, segStart, segEnd, collisionComponent): componentName = TankPartIndexes.getName(componentIdx) if not componentName: convertedComponentIdx = DamageFromShotDecoder.convertComponentIndex( componentIdx) if convertedComponentIdx < 0: return componentStickers = self.__stickers[componentName] if code in componentStickers.damageStickers: return segment = segEnd - segStart segLen = segment.lengthSquared if segLen != 0: segStart -= 0.25 * segment / math.sqrt(segLen) handle = componentStickers.stickers.addDamageSticker( stickerID, segStart, segEnd) componentStickers.damageStickers[code] = DamageSticker( stickerID, segStart, segEnd, handle)
def showDamageFromShot(self, attackerID, points, effectsIndex, damageFactor): if not self.isStarted: return else: effectsDescr = vehicles.g_cache.shotEffects[effectsIndex] maxComponentIdx = TankPartIndexes.ALL[-1] wheelsConfig = self.appearance.typeDescriptor.chassis.generalWheelsAnimatorConfig if wheelsConfig: maxComponentIdx = maxComponentIdx + wheelsConfig.getNonTrackWheelsCount( ) maxHitEffectCode, decodedPoints, maxDamagedComponent = DamageFromShotDecoder.decodeHitPoints( points, self.appearance.collisions, maxComponentIdx) hasPiercedHit = DamageFromShotDecoder.hasDamaged(maxHitEffectCode) firstHitDir = Math.Vector3(0) if decodedPoints: firstHitPoint = decodedPoints[0] compoundModel = self.appearance.compoundModel compMatrix = Math.Matrix( compoundModel.node(firstHitPoint.componentName)) firstHitDirLocal = firstHitPoint.matrix.applyToAxis(2) firstHitDir = compMatrix.applyVector(firstHitDirLocal) self.appearance.receiveShotImpulse( firstHitDir, effectsDescr['targetImpulse']) self.appearance.executeHitVibrations(maxHitEffectCode) player = BigWorld.player() player.inputHandler.onVehicleShaken( self, compMatrix.translation, firstHitDir, effectsDescr['caliber'], ShakeReason.HIT if hasPiercedHit else ShakeReason.HIT_NO_DAMAGE) showFriendlyFlashBang = False sessionProvider = self.guiSessionProvider isAlly = sessionProvider.getArenaDP().isAlly(attackerID) if isAlly: friendlyFireBonusTypes = self.lobbyContext.getServerSettings( ).getFriendlyFireBonusTypes() isFriendlyFireMode = sessionProvider.arenaVisitor.bonus.isFriendlyFireMode( friendlyFireBonusTypes) hasCustomAllyDamageEffect = sessionProvider.arenaVisitor.bonus.hasCustomAllyDamageEffect( ) showFriendlyFlashBang = isFriendlyFireMode and hasCustomAllyDamageEffect for shotPoint in decodedPoints: showFullscreenEffs = self.isPlayerVehicle and self.isAlive() keyPoints, effects, _ = effectsDescr[shotPoint.hitEffectGroup] self.appearance.boundEffects.addNewToNode( shotPoint.componentName, shotPoint.matrix, effects, keyPoints, isPlayerVehicle=self.isPlayerVehicle, showShockWave=showFullscreenEffs, showFlashBang=showFullscreenEffs and not showFriendlyFlashBang, showFriendlyFlashBang=showFullscreenEffs and showFriendlyFlashBang, entity_id=self.id, damageFactor=damageFactor, attackerID=attackerID, hitdir=firstHitDir) if not self.isAlive(): return if attackerID == BigWorld.player().playerVehicleID: if maxHitEffectCode is not None and not self.isPlayerVehicle: if maxHitEffectCode in VEHICLE_HIT_EFFECT.RICOCHETS: eventID = _GUI_EVENT_ID.VEHICLE_RICOCHET elif maxHitEffectCode == VEHICLE_HIT_EFFECT.CRITICAL_HIT: if maxDamagedComponent == TankPartNames.CHASSIS: if damageFactor: eventID = _GUI_EVENT_ID.VEHICLE_CRITICAL_HIT_CHASSIS_PIERCED else: eventID = _GUI_EVENT_ID.VEHICLE_CRITICAL_HIT_CHASSIS else: eventID = _GUI_EVENT_ID.VEHICLE_CRITICAL_HIT elif maxHitEffectCode == VEHICLE_HIT_EFFECT.ARMOR_PIERCED_DEVICE_DAMAGED: eventID = _GUI_EVENT_ID.VEHICLE_CRITICAL_HIT elif hasPiercedHit: eventID = _GUI_EVENT_ID.VEHICLE_ARMOR_PIERCED else: eventID = _GUI_EVENT_ID.VEHICLE_HIT ctrl = self.guiSessionProvider.shared.feedback ctrl is not None and ctrl.setVehicleState(self.id, eventID) return
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)
def getBounds(self, partIdx): return self.collisions.getBoundingBox( DamageFromShotDecoder.convertComponentIndex( partIdx, vehicleDesc=self.typeDescriptor) ) if self.collisions is not None else (Math.Vector3(0.0, 0.0, 0.0), Math.Vector3(0.0, 0.0, 0.0), 0)