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, 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.appearance.collisions) 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: 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 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 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 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 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 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)