View difference between Paste ID: SqswyKrV and VVEPpz2s
SHOW: | | - or go back to the newest paste.
1-
from functools import partial
1+
"""
2-
import math
2+
WOT VERSION: 0.8.11
3-
import weakref
3+
WOT SERVER : EU/NA/RU
4
Supported Crosshairs:
5
-KT Mjolnir v2.x
6-
import Math
6+
-Deegies Sights
7
-Dikeys Taipan
8
-Arty SAU
9-
from helpers import i18n
9+
-Melty Map's Math Mode
10-
from helpers.func_utils import *
10+
----------------------
11-
from gui import DEPTH_OF_Aim
11+
(c) P0LIR0ID 2014
12
----------------------
13-
from gui.Scaleform.ColorSchemeManager import _ColorSchemeManager
13+
Don't forget to delete
14-
from account_helpers.AccountSettings import AccountSettings
14+
Aims.pyc in your
15-
from gui.BattleContext import g_battleContext
15+
res_mods folder !
16
"""
17
import BigWorld
18-
def createAim(type):
18+
19-
    if type == 'strategic':
19+
import Math, math
20-
        return StrategicAim((0, 0.0))
20+
21-
    if type == 'arcade':
21+
22-
        return ArcadeAim((0, 0.15), False)
22+
import AvatarInputHandler.control_modes
23-
    if type == 'sniper':
23+
from math import degrees
24-
        return ArcadeAim((0, 0.0), True)
24+
from AvatarInputHandler.aims import Aim
25-
    if type == 'postmortem':
25+
from AvatarInputHandler.aims import StrategicAim
26-
        return PostMortemAim((0, 0.0))
26+
from AvatarInputHandler.aims import ArcadeAim
27-
    LOG_ERROR('Undefined aim type. <%s>' % type)
27+
from AvatarInputHandler.aims import clearState
28
from AvatarInputHandler.aims import _DamageIndicator
29
from AvatarInputHandler.control_modes import _FlashGunMarker, _calcScale
30-
class Aim(Flash):
30+
31-
    _UPDATE_INTERVAL = 0.03
31+
from gui.IngameSoundNotifications import ComplexSoundNotifications
32-
    __FLASH_CLASS = 'WGAimFlash'
32+
33
isAimingEnded = False
34-
    def __init__(self, mode, offset):
34+
isShown = False
35-
        Flash.__init__(self, 'crosshair_panel_{0:>s}.swf'.format(mode), self.__FLASH_CLASS)
35+
36
class ZoomIndicator(object):
37
38
    def __init__(self):
39
        self.Objects = {}
40
        self.Objects['SniperCamera'] = None
41
        self.isReplayPlaying = False
42-
        self.movie.backgroundAlpha = 0
42+
        self.Inited = False
43-
        self.flashSize = GUI.screenResolution()
43+
44-
        self._offset = offset
44+
45-
        self._isLoaded = False
45+
    def processBattleType(self):
46-
        self.mode = mode
46+
        if BattleReplay.g_replayCtrl.isPlaying is True:
47-
        self.__timeInterval = _TimeInterval(Aim._UPDATE_INTERVAL, '_update', weakref.proxy(self))
47+
            self.isReplayPlaying = True
48-
        self.__isColorBlind = AccountSettings.getSettings('isColorBlind')
48+
        self.Inited = True
49
        print BattleReplay.g_replayCtrl.isPlaying
50-
    def prerequisites(self):
50+
51-
        return []
51+
    def isReplay(self):
52
        return self.isReplayPlaying
53-
    def _isColorBlind(self):
53+
54-
        return self.__isColorBlind
54+
    def getZoom(self):
55
        if self.Objects['SniperCamera'] is None:
56-
    def create(self):
56+
            return 2.1
57-
        from account_helpers.SettingsCore import g_settingsCore
57+
58-
        g_settingsCore.onSettingsChanged += self.applySettings
58+
            return self.Objects['SniperCamera']._SniperCamera__zoom
59-
        replayCtrl = BattleReplay.g_replayCtrl
59+
60-
        if replayCtrl.isPlaying and replayCtrl.replayContainsGunReloads:
60+
ZI = ZoomIndicator()
61-
            self._flashCall('setupReloadingCounter', [False])
61+
62-
            self.__cbIdSetReloading = BigWorld.callback(0.0, self.setReloadingFromReplay)
62+
class _DamageIndicator(Flash):
63
    __SWF_FILE_NAME = 'DamageIndicator.swf'
64-
            self.__cbIdSetReloading = None
64+
65
    __FLASH_MC_NAME = 'damageMC'
66
    __FLASH_SIZE = (680, 680)
67-
    def destroy(self):
67+
    TOTAL_FRAMES = 360
68-
        from account_helpers.SettingsCore import g_settingsCore
68+
69-
        g_settingsCore.onSettingsChanged -= self.applySettings
69+
70-
        self.close()
70+
71-
        if self.__cbIdSetReloading is not None:
71+
72-
            BigWorld.cancelCallback(self.__cbIdSetReloading)
72+
73-
            self.__cbIdSetReloading = None
73+
74-
        self.__timeInterval.stop()
74+
75-
        self.__timeInterval = None
75+
76
        self.component.moveFocus = False
77
        self.component.heightMode = 'PIXEL'
78-
    def applySettings(self, diff):
78+
79-
        from account_helpers.SettingsCore import g_settingsCore
79+
80-
        for type in ('arcade', 'sniper'):
80+
81-
            if type in diff and self.mode == type:
81+
82-
                settings = g_settingsCore.getSetting(type)
82+
83-
                subSetting = settings['centralTag']
83+
84-
                subSettingType = settings['centralTagType']
84+
85-
                self._flashCall('setCenterType', [subSetting, subSettingType])
85+
86-
                subSetting = settings['net']
86+
87-
                subSettingType = settings['netType']
87+
88-
                self._flashCall('setNetType', [subSetting, subSettingType])
88+
89-
                subSetting = settings['reloader']
89+
def new_update(self):
90-
                self._flashCall('setReloaderType', [subSetting, 0])
90+
    global isAimingEnded
91-
                subSetting = settings['condition']
91+
    if ZI.Inited is False:
92-
                self._flashCall('setConditionType', [subSetting, 0])
92+
        ZI.processBattleType()
93-
                subSetting = settings['cassette']
93+
    from AvatarInputHandler.aims import _g_aimState
94-
                self._flashCall('setCassetteType', [subSetting, 0])
94+
    targetID = _g_aimState['target']['id']
95-
                subSetting = settings['reloaderTimer']
95+
    if targetID is not None:
96-
                self._flashCall('setReloaderTimerType', [subSetting, 0])
96+
        targ = BigWorld.entity(targetID)
97
        if targ is None:
98-
        if 'isColorBlind' in diff:
98+
            self.clearTarget()
99-
            self.__isColorBlind = diff['isColorBlind']
99+
            LOG_ERROR('Invalid target ID')
100
        else:
101-
    def enable(self):
101+
            state = _g_aimState['target']
102-
        global _g_aimState
102+
            state['dist'] = (targ.position - BigWorld.player().getOwnVehiclePosition()).length
103-
        self.active(True)
103+
            state['health'] = math.ceil(100.0 * max(0, targ.health) / targ.typeDescriptor.maxHealth)
104-
        self.applySettings(self.mode)
104+
    reload = _g_aimState['reload']
105-
        self.__timeInterval.start()
105+
    correction = reload['correction']
106-
        _g_aimState['target']['id'] = None
106+
    if reload['isReloading']:
107-
        self._enable(_g_aimState, _g_aimState['isFirstInit'])
107+
108-
        _g_aimState['isFirstInit'] = False
108+
            reloadTimer = correction['startTime'] + correction['timeRemaining'] - BigWorld.time()
109-
        self.onRecreateDevice()
109+
110
            reloadTimer = reload['startTime'] + reload['duration'] - BigWorld.time()
111
    else:
112-
    def disable(self):
112+
        reloadTimer = 0
113-
        self.active(False)
113+
    gunPitch = degrees(Math.Matrix(BigWorld.player().gunRotator.gunMatrix).pitch)
114-
        _g_aimState['target']['id'] = None
114+
    self._flashCall('reloadTimer', [reloadTimer, gunPitch])
115-
        self.__timeInterval.stop()
115+
    aimMode = BigWorld.player().inputHandler.aim.mode
116-
        self._disable()
116+
    if aimMode == 'sniper':
117
        if ZI.isReplay() == False:
118
            if hasattr(self, 'component'):
119-
    def updateMarkerPos(self, pos, relaxTime):
119+
                self._flashCall('getZoomByMeltyMap', [1.0471 / ZI.getZoom()])
120-
        self.component.updateMarkerPos(pos, relaxTime)
120+
            self._flashCall('sniperZoom', [ZI.getZoom()])
121
        else:
122-
    def onRecreateDevice(self):
122+
            if hasattr(self, 'component'):
123-
        screen = GUI.screenResolution()
123+
                self._flashCall('getZoomByMeltyMap', [1.0471 / ZI.getZoom()])
124-
        self.component.size = screen
124+
            self._flashCall('sniperZoom', [1.0675761419418335 / BigWorld.projection().fov])
125-
        width = screen[0]
125+
    if BigWorld.target() != None:
126-
        height = screen[1]
126+
        typeDescr = BigWorld.target().typeDescriptor
127-
        offsetX = self._offset[0]
127+
        speed = [typeDescr.physics['speedLimits'][0], typeDescr.physics['speedLimits'][1]]
128-
        offsetY = self._offset[1]
128+
        self._flashCall('vehicleSpeed', [speed[0], speed[1]])
129-
        posX = 0.5 * width * (1.0 + offsetX)
129+
    if aimMode == 'strategic':
130-
        posX = round(posX) if width % 2 == 0 else int(posX)
130+
        height = BigWorld.camera().position.y - AvatarInputHandler.control_modes.getFocalPoint()[1]
131-
        posY = 0.5 * height * (1.0 - offsetY)
131+
        self._flashCall('heightSight', [height])
132-
        posY = round(posY) if height % 2 == 0 else int(posY)
132+
    if BigWorld.player().isOnArena:
133-
        self._flashCall('onRecreateDevice', [posX, posY])
133+
        if aimMode == 'arcade' or aimMode == 'sniper':
134
            x, y, z = BigWorld.player().gunRotator.markerInfo[0]
135-
    def setVisible(self, isVisible):
135+
            v = BigWorld.player().getOwnVehiclePosition() - Math.Vector3(x, y, z)
136-
        self.component.visible = isVisible
136+
            self._flashCall('markerDistance', [v.length])
137
    self._flashCall('aimingEnded', [isAimingEnded])
138-
    def offset(self, value = None):
138+
139-
        if value is not None:
139+
140-
            self._offset = value
140+
141-
            self.onRecreateDevice()
141+
Aim._update = new_update
142
143-
            return self._offset
143+
def new_setTarget(self, name, vType, isFriend):
144
    self._flashCall('setTarget', [name,
145
     vType,
146-
    def setTarget(self, target):
146+
     self.getTargetColor(isFriend),
147-
        state = _g_aimState['target']
147+
     isFriend])
148-
        vInfo = dict(target.publicInfo)
148+
149-
        state['id'] = target.id
149+
150-
        state['startTime'] = None
150+
Aim._setTarget = new_setTarget
151-
        clanAbbrev = BigWorld.player().arena.vehicles.get(target.id, {}).get('clanAbbrev', '')
151+
saved_strategic_enable = StrategicAim._enable
152-
        state['name'] = i18n.convert('%s[%s]' % (vInfo['name'], clanAbbrev) if len(clanAbbrev) > 0 else vInfo['name'])
152+
153-
        state['vType'] = i18n.convert(target.typeDescriptor.type.userString)
153+
def new_strategic_enable(self, state, isFirstInit):
154-
        state['isFriend'] = vInfo['team'] == BigWorld.player().team
154+
    saved_strategic_enable(self, state, isFirstInit)
155-
        self._setTarget(state['name'], state['vType'], state['isFriend'])
155+
    Aim._flashCall(self, 'updateDistanceMS', [self._getAimDistanceMS()])
156
157
158-
    def clearTarget(self):
158+
StrategicAim._enable = new_strategic_enable
159-
        state = _g_aimState['target']
159+
saved_strategic_update = StrategicAim._update
160-
        state['id'] = None
160+
161-
        state['startTime'] = BigWorld.time()
161+
def new_strategic_update(self):
162-
        self._clearTarget(0)
162+
    saved_strategic_update(self)
163
    Aim._flashCall(self, 'updateDistanceMS', [self._getAimDistanceMS()])
164
165-
    def getTargetColor(self, isFriend):
165+
166-
        colorScheme = _ColorSchemeManager.getSubScheme('aim_target_ally' if isFriend else 'aim_target_enemy', isColorBlind=self.__isColorBlind)
166+
StrategicAim._update = new_strategic_update
167-
        return _ColorSchemeManager._makeRGB(colorScheme)
167+
168
def _getAimDistanceMS(self):
169-
    def getReloadingTimeLeft(self):
169+
    x, y, z = BigWorld.player().gunRotator.markerInfo[0]
170-
        state = _g_aimState['reload']
170+
    v = BigWorld.player().getOwnVehiclePosition() - Math.Vector3(x, y, z)
171-
        correction = state.get('correction')
171+
    return v.length
172-
        startTime = state.get('startTime', 0)
172+
173-
        duration = state.get('duration', 0)
173+
174
StrategicAim._getAimDistanceMS = _getAimDistanceMS
175-
            startTime = correction.get('startTime', 0)
175+
176-
            duration = correction.get('timeRemaining', 0)
176+
def new_arcade_update(self):
177-
        if startTime is not None:
177+
    Aim._update(self)
178-
            current = BigWorld.time()
178+
    from AvatarInputHandler.aims import _g_aimState
179-
            return duration - (current - startTime)
179+
    Aim._flashCall(self, 'updateTarget', [int(_g_aimState['target']['dist'])])
180
    Aim._flashCall(self, 'updateTargetMS', [_g_aimState['target']['dist']])
181-
            return 0
181+
182
183-
    def getAmmoQuantityLeft(self):
183+
ArcadeAim._update = new_arcade_update
184-
        ammo = _g_aimState['ammo']
184+
saved_arcade_enable = ArcadeAim._enable
185-
        if self.isCasseteClip():
185+
186-
            return ammo[1]
186+
def new_arcade_enable(self, state, isFirstInit):
187
    saved_arcade_enable(self, state, isFirstInit)
188-
            return ammo[0]
188+
    ts = state['target']
189
    if ts['startTime'] is not None:
190-
    def isCasseteClip(self):
190+
        Aim._flashCall(self, 'updateTarget', [int(ts['dist'])])
191-
        clip = _g_aimState['clip']
191+
        Aim._flashCall(self, 'updateTargetMS', [ts['dist']])
192-
        return clip[0] != 1 or clip[1] != 1
192+
193
194-
    def setReloading(self, duration, startTime = None, baseTime = None):
194+
195-
        state = _g_aimState['reload']
195+
ArcadeAim._enable = new_arcade_enable
196-
        _isReloading = state.get('isReloading', False)
196+
197-
        _startTime = state.get('startTime', 0)
197+
def new_setHealth(self, cur, max):
198-
        _duration = state.get('duration', 0)
198+
    if cur is not None and max is not None:
199-
        isReloading = duration != 0
199+
        self._flashCall('setHealth', [cur / max, cur, max])
200-
        state['isReloading'] = isReloading
200+
201-
        state['correction'] = None
201+
202-
        state['baseTime'] = baseTime
202+
203-
        if _isReloading and duration > 0 and _duration > 0 and _startTime > 0:
203+
Aim._setHealth = new_setHealth
204-
            current = BigWorld.time()
204+
saved_setAimingEnded = ComplexSoundNotifications.setAimingEnded
205-
            state['correction'] = {'timeRemaining': duration,
205+
206-
             'startTime': current,
206+
def new_setAimingEnded(self, isEnded, isReloading):
207-
             'startPosition': (current - _startTime) / _duration}
207+
    global isAimingEnded
208-
            self._flashCall('updateReloadingBaseTime', [baseTime, False])
208+
    saved_setAimingEnded(self, isEnded, isReloading)
209-
            self._correctReloadingTime(duration)
209+
    isAimingEnded = isEnded
210
211-
            state['duration'] = duration
211+
212-
            state['startTime'] = BigWorld.time() if isReloading else None
212+
ComplexSoundNotifications.setAimingEnded = new_setAimingEnded
213-
            self._setReloading(duration, 0, isReloading, None, baseTime)
213+
saved_changeColor = _FlashGunMarker._changeColor
214
215
def new_changeColor(self, hitPoint, armor):
216-
    def setHealth(self, current):
216+
    vDesc = BigWorld.player().vehicleTypeDescriptor
217-
        state = _g_aimState['health']
217+
    ppDesc = vDesc.shot['piercingPower']
218-
        state['cur'] = current
218+
    maxDist = vDesc.shot['maxDistance']
219-
        if state['max'] is None:
219+
    dist = (hitPoint - BigWorld.player().getOwnVehiclePosition()).length
220-
            state['max'] = float(BigWorld.player().vehicleTypeDescriptor.maxHealth)
220+
    if dist <= 100.0:
221-
        self._setHealth(state['cur'], state['max'])
221+
        piercingPower = ppDesc[0]
222
    elif maxDist > dist:
223
        p100, p500 = ppDesc
224-
    def setAmmoStock(self, quantity, quantityInClip, clipReloaded = False):
224+
        piercingPower = p100 + (p500 - p100) * (dist - 100.0) / 400.0
225-
        _g_aimState['ammo'] = (quantity, quantityInClip)
225+
        if piercingPower < 0.0:
226-
        self._setAmmoStock(quantity, quantityInClip, clipReloaded=clipReloaded)
226+
            piercingPower = 0.0
227
    else:
228-
    def updateAmmoState(self, hasAmmo):
228+
        piercingPower = 0.0
229-
        self._flashCall('updateAmmoState', [hasAmmo])
229+
    piercingPercent = 1000.0
230
    if piercingPower > 0.0:
231-
    def getAmmoState(self, quantity, quantityInClip):
231+
        piercingPercent = 100.0 + (armor - piercingPower) / piercingPower * 100.0
232-
        clipCapacity, burst = _g_aimState['clip']
232+
    type = 'great_pierced'
233-
        state = 'normal'
233+
    if piercingPercent >= 150:
234-
        isLow = quantity < 3
234+
        type = 'not_pierced'
235-
        if clipCapacity > 1:
235+
    elif 90 < piercingPercent < 150:
236-
            state = self._getClipState(clipCapacity, burst, quantityInClip)
236+
        type = 'little_pierced'
237-
            isLow |= quantity <= clipCapacity
237+
    self.call('Crosshair.setMarkerType', [self._curColors[type], armor, piercingPower])
238-
        return (isLow, state)
238+
239
240-
    def setClipParams(self, capacity, burst):
240+
_FlashGunMarker._changeColor = new_changeColor
241-
        _g_aimState['clip'] = (capacity, burst)
241+
242-
        if capacity > 1:
242+
def new_gm_update(self, pos, dir, size, relaxTime, collData):
243-
            self._setClipParams(capacity, burst)
243+
    m = Math.Matrix()
244
    m.setTranslate(pos)
245-
    def showHit(self, gYaw, isDamage):
245+
    self._FlashGunMarker__setupMatrixAnimation()
246-
        _g_aimState['hitIndicators'].append({'gYaw': gYaw,
246+
    self._FlashGunMarker__animMat.keyframes = ((0.0, Math.Matrix(self._FlashGunMarker__animMat)), (relaxTime, m))
247-
         'startTime': BigWorld.time(),
247+
    self._FlashGunMarker__animMat.time = 0.0
248-
         'isDamage': isDamage})
248+
    self._FlashGunMarker__curSize = _calcScale(m, size) * (GUI.screenResolution()[0] * 0.5)
249-
        self._showHit(_g_aimState['hitIndicators'][-1:][0])
249+
    replayCtrl = BattleReplay.g_replayCtrl
250
    if replayCtrl.isPlaying and replayCtrl.isClientReady:
251-
    def isGunReload(self):
251+
        s = replayCtrl.getArcadeGunMarkerSize()
252-
        return _g_aimState['reload']['isReloading']
252+
        if s != -1.0:
253
            self._FlashGunMarker__curSize = s
254-
    def onCameraChange(self):
254+
    elif replayCtrl.isRecording:
255-
        if not self.isGunReload():
255+
        replayCtrl.setArcadeGunMarkerSize(self._FlashGunMarker__curSize)
256-
            baseTime = _g_aimState['reload'].get('baseTime', -1)
256+
    if collData is None or collData[0].health <= 0 or collData[0].publicInfo['team'] == BigWorld.player().team:
257-
            self._flashCall('updateReloadingBaseTime', [baseTime, True])
257+
        self.call('Crosshair.setMarkerType', ['normal'])
258-
        elif not _g_aimState['reload']['correction']:
258+
    else:
259-
            self._flashCall('clearPreviousCorrection', [])
259+
        self._changeColor(pos, collData[2])
260
    self.component.wg_updateSize(self._FlashGunMarker__curSize / 1.0, relaxTime)
261-
    def resetVehicleMatrix(self):
261+
    if BigWorld.player().inputHandler.aim != None:
262
        aimMode = BigWorld.player().inputHandler.aim.mode
263
        self.call('Crosshair.AimMode', [aimMode])
264-
    def _enable(self, state, isFirstInit):
264+
265
266
267-
    def _disable(self):
267+
_FlashGunMarker.update = new_gm_update
268
269
def new_setReloading(self, duration, startTime = None, isReloading = True, correction = None, baseTime = None):
270-
    def _showHit(self, hitDesc):
270+
    replayCtrl = BattleReplay.g_replayCtrl
271
    if replayCtrl.isPlaying and replayCtrl.replayContainsGunReloads:
272
        replayCtrl.setGunReloadTime(startTime, duration)
273-
    def _setTarget(self, name, vType, isFriend):
273+
    if replayCtrl.isRecording:
274-
        self._flashCall('setTarget', [name, vType, self.getTargetColor(isFriend)])
274+
        replayCtrl.setGunReloadTime(startTime, duration)
275
    if correction is not None:
276-
    def _clearTarget(self, startTime):
276+
        params = self._getCorrectionReloadingParams(correction)
277-
        self._flashCall('clearTarget', [startTime])
277+
        if params is not None:
278
            self._flashCall('setReloading', params)
279-
    def setReloadingFromReplay(self):
279+
    else:
280-
        self._setReloadingAsPercent(100.0 * BattleReplay.g_replayCtrl.getGunReloadAmountLeft())
280+
        self._flashCall('setReloading', [duration,
281-
        self.__cbIdSetReloading = BigWorld.callback(0.0, self.setReloadingFromReplay)
281+
         startTime,
282
         isReloading,
283-
    def _setReloading(self, duration, startTime = None, isReloading = True, correction = None, baseTime = None):
283+
         None,
284-
        replayCtrl = BattleReplay.g_replayCtrl
284+
         baseTime])
285-
        if replayCtrl.isPlaying and replayCtrl.replayContainsGunReloads:
285+
    shotDescr = BigWorld.player().vehicleTypeDescriptor.shot
286
    gunDescr = BigWorld.player().vehicleTypeDescriptor.gun
287
    vehicleName = BigWorld.player().vehicleTypeDescriptor.type.userString
288-
            if replayCtrl.isRecording:
288+
    try:
289-
                replayCtrl.setGunReloadTime(startTime, duration)
289+
        shellSplash = shotDescr['shell']['explosionRadius']
290-
            if correction is not None:
290+
    except:
291-
                params = self._getCorrectionReloadingParams(correction)
291+
        shellSplash = 0
292-
                if params is not None:
292+
293-
                    self._flashCall('setReloading', params)
293+
    if shotDescr['shell']['kind'] == 'ARMOR_PIERCING':
294-
            else:
294+
        shellType = shotDescr['shell']['kind'].replace('ARMOR_PIERCING', 'AP')
295-
                self._flashCall('setReloading', [duration,
295+
    elif shotDescr['shell']['kind'] == 'HIGH_EXPLOSIVE':
296-
                 startTime,
296+
        shellType = shotDescr['shell']['kind'].replace('HIGH_EXPLOSIVE', 'HE')
297-
                 isReloading,
297+
    elif shotDescr['shell']['kind'] == 'ARMOR_PIERCING_CR':
298-
                 None,
298+
        shellType = shotDescr['shell']['kind'].replace('ARMOR_PIERCING_CR', 'CR')
299-
                 baseTime])
299+
    else:
300
        shellType = shotDescr['shell']['kind'].replace('HOLLOW_CHARGE', 'HC')
301
    self._flashCall('setGunParams', [gunDescr['shortUserString'],
302-
    def _setReloadingAsPercent(self, percent):
302+
     shotDescr['speed'],
303-
        self._flashCall('setReloadingAsPercent', [percent])
303+
     shotDescr['gravity'],
304
     shotDescr['shell']['userString'],
305-
    def _correctReloadingTime(self, duration):
305+
     shellSplash])
306-
        replayCtrl = BattleReplay.g_replayCtrl
306+
    self._flashCall('vehicleParams', [gunDescr['shortUserString'],
307-
        if replayCtrl.isPlaying and replayCtrl.replayContainsGunReloads:
307+
     shotDescr['speed'],
308-
            self.setReloadingFromReplay()
308+
     shotDescr['gravity'],
309
     shotDescr['shell']['userString'],
310-
        self._flashCall('correctReloadingTime', [duration])
310+
     shellSplash,
311
     vehicleName,
312-
    def _getCorrectionReloadingParams(self, correction):
312+
     shellType])
313-
        cTimeRemaining = correction.get('timeRemaining', 0)
313+
314-
        cStartTime = correction.get('startTime', 0)
314+
315-
        cStartPosition = correction.get('startPosition', 0)
315+
316-
        if not cTimeRemaining > 0:
316+
Aim._setReloading = new_setReloading
317-
            LOG_WARNING('timeRemaining - invalid value ', cTimeRemaining)
317+
saved_setTarget = Aim.setTarget
318-
            return None
318+
319
def new_setTarget(self, target):
320-
            delta = BigWorld.time() - cStartTime
320+
    typeDescr = target.typeDescriptor
321-
            currentPosition = cStartPosition + delta / cTimeRemaining * (1 - cStartPosition)
321+
    speed = [typeDescr.physics['speedLimits'][0], typeDescr.physics['speedLimits'][1]]
322-
            return [cTimeRemaining - delta,
322+
    hullArmor = [typeDescr.hull['primaryArmor'][0], typeDescr.hull['primaryArmor'][1], typeDescr.hull['primaryArmor'][2]]
323-
             cStartTime,
323+
    turretArmor = [typeDescr.turret['primaryArmor'][0], typeDescr.turret['primaryArmor'][1], typeDescr.turret['primaryArmor'][2]]
324-
             True,
324+
    gunName = typeDescr.gun['shortUserString']
325-
             currentPosition * 100.0]
325+
    gunReload = typeDescr.gun['reloadTime']
326
    visionRadius = typeDescr.turret['circularVisionRadius']
327-
    def _setHealth(self, cur, max):
327+
    iconName = typeDescr.name.replace(':', '-')
328-
        if cur is not None and max is not None:
328+
    shellDamage = [0, 0, 0]
329-
            self._flashCall('setHealth', [cur / max])
329+
    i = 0
330
    for element in target.typeDescriptor.gun['shots']:
331
        shellDamage[i] = element['shell']['damage'][0]
332-
    def _setAmmoStock(self, quantity, quantityInClip, clipReloaded = False):
332+
        i = i + 1
333-
        isLow, state = self.getAmmoState(quantity, quantityInClip)
333+
334-
        self._flashCall('setAmmoStock', [quantity,
334+
    shellPower = [0, 0, 0]
335-
         quantityInClip,
335+
    j = 0
336-
         isLow,
336+
    for element in target.typeDescriptor.gun['shots']:
337-
         state,
337+
        shellPower[j] = element['piercingPower'][0]
338-
         clipReloaded])
338+
        j = j + 1
339
340-
    def _getClipState(self, capacity, burst, quantityInClip):
340+
    shellType = ['', '', '']
341-
        state = 'normal'
341+
    k = 0
342-
        if burst > 1:
342+
    for element in target.typeDescriptor.gun['shots']:
343-
            total = math.ceil(float(capacity) / float(burst))
343+
        if element['shell']['kind'] == 'ARMOR_PIERCING':
344-
            current = math.ceil(float(quantityInClip) / float(burst))
344+
            shellType[k] = element['shell']['kind'].replace('ARMOR_PIERCING', 'AP')
345
        elif element['shell']['kind'] == 'HIGH_EXPLOSIVE':
346-
            total = capacity
346+
            shellType[k] = element['shell']['kind'].replace('HIGH_EXPLOSIVE', 'HE')
347-
            current = quantityInClip
347+
        elif element['shell']['kind'] == 'ARMOR_PIERCING_CR':
348-
        if current <= 0.5 * total:
348+
            shellType[k] = element['shell']['kind'].replace('ARMOR_PIERCING_CR', 'CR')
349-
            state = 'critical' if current == 1 else 'warning'
349+
350-
        return state
350+
            shellType[k] = element['shell']['kind'].replace('HOLLOW_CHARGE', 'HC')
351
        k = k + 1
352-
    def _setClipParams(self, capacity, burst):
352+
        saved_setTarget(self, target)
353-
        self._flashCall('setClipParams', [capacity, burst])
353+
        self._flashCall('setTargetParams', [BigWorld.target().typeDescriptor.gun['reloadTime'], BigWorld.target().typeDescriptor.turret['circularVisionRadius']])
354
        self._flashCall('infoPanel', [speed[0],
355-
    def _update(self):
355+
         speed[1],
356-
        targetID = _g_aimState['target']['id']
356+
         gunName,
357-
        if targetID is not None:
357+
         gunReload,
358-
            targ = BigWorld.entity(targetID)
358+
         visionRadius,
359-
            if targ is None:
359+
         iconName,
360-
                self.clearTarget()
360+
         hullArmor[0],
361-
                LOG_ERROR('Invalid target ID')
361+
         hullArmor[1],
362-
            else:
362+
         hullArmor[2],
363-
                state = _g_aimState['target']
363+
         turretArmor[0],
364-
                state['dist'] = int((targ.position - BigWorld.player().getOwnVehiclePosition()).length)
364+
         turretArmor[1],
365-
                state['health'] = math.ceil(100.0 * max(0, targ.health) / targ.typeDescriptor.maxHealth)
365+
         turretArmor[2],
366
         shellDamage[0],
367
         shellDamage[1],
368-
    def _flashCall(self, funcName, args = None):
368+
         shellDamage[2],
369-
        self.call('Aim.' + funcName, args)
369+
         shellPower[0],
370
         shellPower[1],
371
         shellPower[2],
372-
class StrategicAim(Aim):
372+
         shellType[0],
373
         shellType[1],
374-
    def __init__(self, offset, isPostMortem = False):
374+
         shellType[2]])
375-
        Aim.__init__(self, 'strategic', offset)
375+
376
377-
    def create(self):
377+
Aim.setTarget = new_setTarget
378-
        Aim.create(self)
378+
from AvatarInputHandler.DynamicCameras.SniperCamera import SniperCamera
379-
        self.__damageCtrl = _DamageIndicatorCtrl(self._offset)
379+
link_SniperCamera_init = SniperCamera.__init__
380
381-
    def onRecreateDevice(self):
381+
def new_SniperCamera_init(self, dataSec, aim, binoculars):
382-
        Aim.onRecreateDevice(self)
382+
    link_SniperCamera_init(self, dataSec, aim, binoculars)
383-
        self.__damageCtrl.onRecreateDevice()
383+
    ZI.Objects['SniperCamera'] = self
384
385-
    def destroy(self):
385+
386-
        Aim.destroy(self)
386+
SniperCamera.__init__ = new_SniperCamera_init
387-
        self.__damageCtrl.disable()
387+
import gui.Scaleform.Flash, AvatarInputHandler.control_modes
388-
        self.__damageCtrl = None
388+
389
def StrategyEraser():
390
391-
    def _enable(self, state, isFirstInit):
391+
    class MultiController:
392-
        self.__damageCtrl.enable()
392+
        target = None
393-
        if isFirstInit:
393+
        prevSpeed = 0.0
394
395
        def control(self):
396-
            Aim._flashCall(self, 'updateDistance', [self._getAimDistance()])
396+
            try:
397-
            hs = state['health']
397+
                gui.Scaleform.Flash.GUI.roots()[1].movie.invoke(('call', ['Aim.updateHeight', int(round(BigWorld.camera().position.y - AvatarInputHandler.control_modes.getFocalPoint()[1]))]))
398-
            self._setHealth(hs['cur'], hs['max'])
398+
                if BigWorld.player().inputHandler._AvatarInputHandler__targeting.getTargetEntity() != None:
399-
            rs = state['reload']
399+
                    self.target = BigWorld.player().inputHandler._AvatarInputHandler__targeting.getTargetEntity()
400-
            if rs['startTime'] is not None:
400+
                if self.target != None:
401-
                self._setReloading(rs['duration'], startTime=BigWorld.time() - rs['startTime'], correction=rs['correction'])
401+
                    if self.target.isDestroyed == False:
402-
            else:
402+
                        speed = self.target.getSpeed()
403-
                self._setReloading(rs['duration'], 0, False)
403+
                        gui.Scaleform.Flash.GUI.roots()[1].movie.invoke(('call', ['Aim.updateTargetSpeed', speed]))
404-
            capacity, burst = state['clip']
404+
                    else:
405-
            if capacity > 1:
405+
                        self.target = None
406-
                self._setClipParams(capacity, burst)
406+
            except:
407-
            self._setAmmoStock(*state['ammo'])
407+
                pass
408
409
            BigWorld.callback(0.05, lambda : self.control())
410-
    def _disable(self):
410+
411-
        self.__damageCtrl.disable()
411+
412
    mca1 = MultiController()
413-
    def _showHit(self, hitDesc):
413+
    mca1.control()
414-
        self.__damageCtrl.add(hitDesc)
414+
415
416-
    def _update(self):
416+
BigWorld.callback(10, lambda : StrategyEraser())