Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- (c) Dellux 2014
- """
- import BigWorld, GUI, 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.control_modes import _FlashGunMarker, _calcScale
- from gui.IngameSoundNotifications import ComplexSoundNotifications
- from debug_utils import *
- isAimingEnded = False
- def new_update(self):
- global isAimingEnded
- 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':
- fov = BigWorld.projection().fov
- zoom = 1.04719758034 / fov
- self._flashCall('sniperZoom', [zoom])
- 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
- saved_setReloading = Aim._setReloading
- def new_setReloading(self, duration, startTime = None, isReloading = True, correction = None, baseTime = None):
- saved_setReloading(self, duration, startTime, isReloading, correction)
- 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])
- vTypeDesc = BigWorld.player().vehicleTypeDescriptor
- gunName = vTypeDesc.gun['shortUserString']
- shellSpeed = vTypeDesc.shot['speed']
- shellGravity = vTypeDesc.shot['gravity']
- shellName = vTypeDesc.shot['shell']['userString']
- if vTypeDesc.shot['shell']['kind'] == 'ARMOR_PIERCING':
- shellType = vTypeDesc.shot['shell']['kind'].replace('ARMOR_PIERCING', 'AP')
- elif vTypeDesc.shot['shell']['kind'] == 'HIGH_EXPLOSIVE':
- shellType = vTypeDesc.shot['shell']['kind'].replace('HIGH_EXPLOSIVE', 'HE')
- elif vTypeDesc.shot['shell']['kind'] == 'ARMOR_PIERCING_CR':
- shellType = vTypeDesc.shot['shell']['kind'].replace('ARMOR_PIERCING_CR', 'CR')
- else:
- shellType = vTypeDesc.shot['shell']['kind'].replace('HOLLOW_CHARGE', 'HC')
- vehicleName = vTypeDesc.type.userString
- try:
- shellSplash = vTypeDesc.shot['shell']['explosionRadius']
- except:
- shellSplash = 0
- self._flashCall('vehicleParams', [gunName,
- shellSpeed,
- shellGravity,
- shellName,
- shellSplash,
- vehicleName,
- shellType])
- return
- Aim._setReloading = new_setReloading
- 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
- 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
- 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_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_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
- mscfg = ResMgr.openSection('scripts/client/mods/MS.xml')
- if mscfg:
- curSize = mscfg.readFloat('curSize')
- else:
- curSize = 1.0
- 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 / curSize, relaxTime)
- if BigWorld.player().inputHandler.aim != None:
- aimMode = BigWorld.player().inputHandler.aim.mode
- self.call('Crosshair.AimMode', [aimMode])
- return
- _FlashGunMarker.update = new_gm_update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement