Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- WOT VERSION: 0.8.11
- WOT SERVER : EU/NA/RU
- Supported Crosshairs:
- -KT Mjolnir v2.x
- -Deegies Sights
- -Dikeys Taipan
- -Arty SAU
- -Melty Map's Math Mode
- ----------------------
- (c) P0LIR0ID 2014
- ----------------------
- Don't forget to delete
- Aims.pyc in your
- res_mods folder !
- """
- import BigWorld
- import GUI
- import Math, math
- import ResMgr
- import BattleReplay
- import AvatarInputHandler.control_modes
- from math import degrees
- from AvatarInputHandler.aims import Aim
- from AvatarInputHandler.aims import StrategicAim
- from AvatarInputHandler.aims import ArcadeAim
- from AvatarInputHandler.aims import clearState
- from AvatarInputHandler.aims import _DamageIndicator
- from AvatarInputHandler.control_modes import _FlashGunMarker, _calcScale
- from gui.Scaleform.Flash import Flash
- from gui.IngameSoundNotifications import ComplexSoundNotifications
- from debug_utils import *
- isAimingEnded = False
- isShown = False
- class ZoomIndicator(object):
- def __init__(self):
- self.Objects = {}
- self.Objects['SniperCamera'] = None
- self.isReplayPlaying = False
- self.Inited = False
- return
- def processBattleType(self):
- if BattleReplay.g_replayCtrl.isPlaying is True:
- self.isReplayPlaying = True
- self.Inited = True
- print BattleReplay.g_replayCtrl.isPlaying
- def isReplay(self):
- return self.isReplayPlaying
- def getZoom(self):
- if self.Objects['SniperCamera'] is None:
- return 2.1
- else:
- return self.Objects['SniperCamera']._SniperCamera__zoom
- return
- ZI = ZoomIndicator()
- class _DamageIndicator(Flash):
- __SWF_FILE_NAME = 'DamageIndicator.swf'
- __FLASH_CLASS = 'WGHitIndicatorFlash'
- __FLASH_MC_NAME = 'damageMC'
- __FLASH_SIZE = (680, 680)
- TOTAL_FRAMES = 360
- FRAME_RATE = 24
- def __init__(self):
- Flash.__init__(self, self.__SWF_FILE_NAME, self.__FLASH_CLASS, [self.__FLASH_MC_NAME])
- self.component.wg_inputKeyMode = 2
- self.component.position.z = DEPTH_OF_Aim
- self.movie.backgroundAlpha = 0.0
- self.component.focus = False
- self.component.moveFocus = False
- self.component.heightMode = 'PIXEL'
- self.component.widthMode = 'PIXEL'
- self.flashSize = self.__FLASH_SIZE
- def setup(self, gYaw, offset):
- self.component.position.x = offset[0]
- self.component.position.y = offset[1]
- self.component.wg_globalYaw = gYaw
- def __del__(self):
- pass
- def new_update(self):
- global isAimingEnded
- if ZI.Inited is False:
- ZI.processBattleType()
- from AvatarInputHandler.aims import _g_aimState
- targetID = _g_aimState['target']['id']
- if targetID is not None:
- targ = BigWorld.entity(targetID)
- if targ is None:
- self.clearTarget()
- LOG_ERROR('Invalid target ID')
- else:
- state = _g_aimState['target']
- state['dist'] = (targ.position - BigWorld.player().getOwnVehiclePosition()).length
- state['health'] = math.ceil(100.0 * max(0, targ.health) / targ.typeDescriptor.maxHealth)
- reload = _g_aimState['reload']
- correction = reload['correction']
- if reload['isReloading']:
- if correction is not None:
- reloadTimer = correction['startTime'] + correction['timeRemaining'] - BigWorld.time()
- else:
- reloadTimer = reload['startTime'] + reload['duration'] - BigWorld.time()
- else:
- reloadTimer = 0
- gunPitch = degrees(Math.Matrix(BigWorld.player().gunRotator.gunMatrix).pitch)
- self._flashCall('reloadTimer', [reloadTimer, gunPitch])
- aimMode = BigWorld.player().inputHandler.aim.mode
- if aimMode == 'sniper':
- if ZI.isReplay() == False:
- if hasattr(self, 'component'):
- self._flashCall('getZoomByMeltyMap', [1.0471 / ZI.getZoom()])
- self._flashCall('sniperZoom', [ZI.getZoom()])
- else:
- if hasattr(self, 'component'):
- self._flashCall('getZoomByMeltyMap', [1.0471 / ZI.getZoom()])
- self._flashCall('sniperZoom', [1.0675761419418335 / BigWorld.projection().fov])
- if BigWorld.target() != None:
- typeDescr = BigWorld.target().typeDescriptor
- speed = [typeDescr.physics['speedLimits'][0], typeDescr.physics['speedLimits'][1]]
- self._flashCall('vehicleSpeed', [speed[0], speed[1]])
- if aimMode == 'strategic':
- height = BigWorld.camera().position.y - AvatarInputHandler.control_modes.getFocalPoint()[1]
- self._flashCall('heightSight', [height])
- if BigWorld.player().isOnArena:
- if aimMode == 'arcade' or aimMode == 'sniper':
- x, y, z = BigWorld.player().gunRotator.markerInfo[0]
- v = BigWorld.player().getOwnVehiclePosition() - Math.Vector3(x, y, z)
- self._flashCall('markerDistance', [v.length])
- self._flashCall('aimingEnded', [isAimingEnded])
- return
- Aim._update = new_update
- def new_setTarget(self, name, vType, isFriend):
- self._flashCall('setTarget', [name,
- vType,
- self.getTargetColor(isFriend),
- isFriend])
- Aim._setTarget = new_setTarget
- saved_strategic_enable = StrategicAim._enable
- def new_strategic_enable(self, state, isFirstInit):
- saved_strategic_enable(self, state, isFirstInit)
- Aim._flashCall(self, 'updateDistanceMS', [self._getAimDistanceMS()])
- StrategicAim._enable = new_strategic_enable
- saved_strategic_update = StrategicAim._update
- def new_strategic_update(self):
- saved_strategic_update(self)
- Aim._flashCall(self, 'updateDistanceMS', [self._getAimDistanceMS()])
- StrategicAim._update = new_strategic_update
- def _getAimDistanceMS(self):
- x, y, z = BigWorld.player().gunRotator.markerInfo[0]
- v = BigWorld.player().getOwnVehiclePosition() - Math.Vector3(x, y, z)
- return v.length
- StrategicAim._getAimDistanceMS = _getAimDistanceMS
- def new_arcade_update(self):
- Aim._update(self)
- from AvatarInputHandler.aims import _g_aimState
- Aim._flashCall(self, 'updateTarget', [int(_g_aimState['target']['dist'])])
- Aim._flashCall(self, 'updateTargetMS', [_g_aimState['target']['dist']])
- ArcadeAim._update = new_arcade_update
- saved_arcade_enable = ArcadeAim._enable
- def new_arcade_enable(self, state, isFirstInit):
- saved_arcade_enable(self, state, isFirstInit)
- ts = state['target']
- if ts['startTime'] is not None:
- Aim._flashCall(self, 'updateTarget', [int(ts['dist'])])
- Aim._flashCall(self, 'updateTargetMS', [ts['dist']])
- return
- ArcadeAim._enable = new_arcade_enable
- def new_setHealth(self, cur, max):
- if cur is not None and max is not None:
- self._flashCall('setHealth', [cur / max, cur, max])
- return
- Aim._setHealth = new_setHealth
- saved_setAimingEnded = ComplexSoundNotifications.setAimingEnded
- def new_setAimingEnded(self, isEnded, isReloading):
- global isAimingEnded
- saved_setAimingEnded(self, isEnded, isReloading)
- isAimingEnded = isEnded
- ComplexSoundNotifications.setAimingEnded = new_setAimingEnded
- saved_changeColor = _FlashGunMarker._changeColor
- def new_changeColor(self, hitPoint, armor):
- vDesc = BigWorld.player().vehicleTypeDescriptor
- ppDesc = vDesc.shot['piercingPower']
- maxDist = vDesc.shot['maxDistance']
- dist = (hitPoint - BigWorld.player().getOwnVehiclePosition()).length
- if dist <= 100.0:
- piercingPower = ppDesc[0]
- elif maxDist > dist:
- p100, p500 = ppDesc
- piercingPower = p100 + (p500 - p100) * (dist - 100.0) / 400.0
- if piercingPower < 0.0:
- piercingPower = 0.0
- else:
- piercingPower = 0.0
- piercingPercent = 1000.0
- if piercingPower > 0.0:
- piercingPercent = 100.0 + (armor - piercingPower) / piercingPower * 100.0
- type = 'great_pierced'
- if piercingPercent >= 150:
- type = 'not_pierced'
- elif 90 < piercingPercent < 150:
- type = 'little_pierced'
- self.call('Crosshair.setMarkerType', [self._curColors[type], armor, piercingPower])
- _FlashGunMarker._changeColor = new_changeColor
- def new_gm_update(self, pos, dir, size, relaxTime, collData):
- m = Math.Matrix()
- m.setTranslate(pos)
- self._FlashGunMarker__setupMatrixAnimation()
- self._FlashGunMarker__animMat.keyframes = ((0.0, Math.Matrix(self._FlashGunMarker__animMat)), (relaxTime, m))
- self._FlashGunMarker__animMat.time = 0.0
- self._FlashGunMarker__curSize = _calcScale(m, size) * (GUI.screenResolution()[0] * 0.5)
- replayCtrl = BattleReplay.g_replayCtrl
- if replayCtrl.isPlaying and replayCtrl.isClientReady:
- s = replayCtrl.getArcadeGunMarkerSize()
- if s != -1.0:
- self._FlashGunMarker__curSize = s
- elif replayCtrl.isRecording:
- replayCtrl.setArcadeGunMarkerSize(self._FlashGunMarker__curSize)
- if collData is None or collData[0].health <= 0 or collData[0].publicInfo['team'] == BigWorld.player().team:
- self.call('Crosshair.setMarkerType', ['normal'])
- else:
- self._changeColor(pos, collData[2])
- self.component.wg_updateSize(self._FlashGunMarker__curSize / 1.0, relaxTime)
- if BigWorld.player().inputHandler.aim != None:
- aimMode = BigWorld.player().inputHandler.aim.mode
- self.call('Crosshair.AimMode', [aimMode])
- return
- _FlashGunMarker.update = new_gm_update
- def new_setReloading(self, duration, startTime = None, isReloading = True, correction = None, baseTime = None):
- replayCtrl = BattleReplay.g_replayCtrl
- if replayCtrl.isPlaying and replayCtrl.replayContainsGunReloads:
- replayCtrl.setGunReloadTime(startTime, duration)
- if replayCtrl.isRecording:
- replayCtrl.setGunReloadTime(startTime, duration)
- if correction is not None:
- params = self._getCorrectionReloadingParams(correction)
- if params is not None:
- self._flashCall('setReloading', params)
- else:
- self._flashCall('setReloading', [duration,
- startTime,
- isReloading,
- None,
- baseTime])
- shotDescr = BigWorld.player().vehicleTypeDescriptor.shot
- gunDescr = BigWorld.player().vehicleTypeDescriptor.gun
- vehicleName = BigWorld.player().vehicleTypeDescriptor.type.userString
- try:
- shellSplash = shotDescr['shell']['explosionRadius']
- except:
- shellSplash = 0
- if shotDescr['shell']['kind'] == 'ARMOR_PIERCING':
- shellType = shotDescr['shell']['kind'].replace('ARMOR_PIERCING', 'AP')
- elif shotDescr['shell']['kind'] == 'HIGH_EXPLOSIVE':
- shellType = shotDescr['shell']['kind'].replace('HIGH_EXPLOSIVE', 'HE')
- elif shotDescr['shell']['kind'] == 'ARMOR_PIERCING_CR':
- shellType = shotDescr['shell']['kind'].replace('ARMOR_PIERCING_CR', 'CR')
- else:
- shellType = shotDescr['shell']['kind'].replace('HOLLOW_CHARGE', 'HC')
- self._flashCall('setGunParams', [gunDescr['shortUserString'],
- shotDescr['speed'],
- shotDescr['gravity'],
- shotDescr['shell']['userString'],
- shellSplash])
- self._flashCall('vehicleParams', [gunDescr['shortUserString'],
- shotDescr['speed'],
- shotDescr['gravity'],
- shotDescr['shell']['userString'],
- shellSplash,
- vehicleName,
- shellType])
- return
- Aim._setReloading = new_setReloading
- saved_setTarget = Aim.setTarget
- def new_setTarget(self, target):
- typeDescr = target.typeDescriptor
- speed = [typeDescr.physics['speedLimits'][0], typeDescr.physics['speedLimits'][1]]
- hullArmor = [typeDescr.hull['primaryArmor'][0], typeDescr.hull['primaryArmor'][1], typeDescr.hull['primaryArmor'][2]]
- turretArmor = [typeDescr.turret['primaryArmor'][0], typeDescr.turret['primaryArmor'][1], typeDescr.turret['primaryArmor'][2]]
- gunName = typeDescr.gun['shortUserString']
- gunReload = typeDescr.gun['reloadTime']
- visionRadius = typeDescr.turret['circularVisionRadius']
- iconName = typeDescr.name.replace(':', '-')
- shellDamage = [0, 0, 0]
- i = 0
- for element in target.typeDescriptor.gun['shots']:
- shellDamage[i] = element['shell']['damage'][0]
- i = i + 1
- shellPower = [0, 0, 0]
- j = 0
- for element in target.typeDescriptor.gun['shots']:
- shellPower[j] = element['piercingPower'][0]
- j = j + 1
- shellType = ['', '', '']
- k = 0
- for element in target.typeDescriptor.gun['shots']:
- if element['shell']['kind'] == 'ARMOR_PIERCING':
- shellType[k] = element['shell']['kind'].replace('ARMOR_PIERCING', 'AP')
- elif element['shell']['kind'] == 'HIGH_EXPLOSIVE':
- shellType[k] = element['shell']['kind'].replace('HIGH_EXPLOSIVE', 'HE')
- elif element['shell']['kind'] == 'ARMOR_PIERCING_CR':
- shellType[k] = element['shell']['kind'].replace('ARMOR_PIERCING_CR', 'CR')
- else:
- shellType[k] = element['shell']['kind'].replace('HOLLOW_CHARGE', 'HC')
- k = k + 1
- saved_setTarget(self, target)
- self._flashCall('setTargetParams', [BigWorld.target().typeDescriptor.gun['reloadTime'], BigWorld.target().typeDescriptor.turret['circularVisionRadius']])
- self._flashCall('infoPanel', [speed[0],
- speed[1],
- gunName,
- gunReload,
- visionRadius,
- iconName,
- hullArmor[0],
- hullArmor[1],
- hullArmor[2],
- turretArmor[0],
- turretArmor[1],
- turretArmor[2],
- shellDamage[0],
- shellDamage[1],
- shellDamage[2],
- shellPower[0],
- shellPower[1],
- shellPower[2],
- shellType[0],
- shellType[1],
- shellType[2]])
- Aim.setTarget = new_setTarget
- from AvatarInputHandler.DynamicCameras.SniperCamera import SniperCamera
- link_SniperCamera_init = SniperCamera.__init__
- def new_SniperCamera_init(self, dataSec, aim, binoculars):
- link_SniperCamera_init(self, dataSec, aim, binoculars)
- ZI.Objects['SniperCamera'] = self
- SniperCamera.__init__ = new_SniperCamera_init
- import gui.Scaleform.Flash, AvatarInputHandler.control_modes
- def StrategyEraser():
- class MultiController:
- target = None
- prevSpeed = 0.0
- def control(self):
- try:
- gui.Scaleform.Flash.GUI.roots()[1].movie.invoke(('call', ['Aim.updateHeight', int(round(BigWorld.camera().position.y - AvatarInputHandler.control_modes.getFocalPoint()[1]))]))
- if BigWorld.player().inputHandler._AvatarInputHandler__targeting.getTargetEntity() != None:
- self.target = BigWorld.player().inputHandler._AvatarInputHandler__targeting.getTargetEntity()
- if self.target != None:
- if self.target.isDestroyed == False:
- speed = self.target.getSpeed()
- gui.Scaleform.Flash.GUI.roots()[1].movie.invoke(('call', ['Aim.updateTargetSpeed', speed]))
- else:
- self.target = None
- except:
- pass
- BigWorld.callback(0.05, lambda : self.control())
- return
- mca1 = MultiController()
- mca1.control()
- BigWorld.callback(10, lambda : StrategyEraser())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement