Jump to content
It's_Matra

[DISCONTINUED] MatraMod Customisable DamageLog

Recommended Posts

13 hours ago, sr360 said:

Does this work without XVM?

Yes, instructions are included (link to Google Doc) and you will need to install the fonts file as mentioned above

Share this post


Link to post
Share on other sites
5 minutes ago, BlackAdder said:

@It's_Matra is it possible to have damage log (received) without XVM? Just to have advantage of knowing exactly who camps bush? DyMHxFK.pngDyMHxFK.png

Yes, using this

By default I think it shows who hit you, ammo type and how much for.

It will also show all the helpful stuff for missions (platoon dmg, damage bounced, total damage received/done)

 

I've updated the first post to show that it does not require XVM

Share this post


Link to post
Share on other sites
12 minutes ago, It's_Matra said:

Yes, using this

By default I think it shows who hit you, ammo type and how much for.

It will also show all the helpful stuff for missions (platoon dmg, damage bounced, total damage received/done)

 

I've updated the first post to show that it does not require XVM

 

Now last request, how to get this Hitlog_example.png

without everything else :)

Share this post


Link to post
Share on other sites
1 hour ago, BlackAdder said:

Now last request, how to get this Hitlog_example.png

without everything else :)

Follow instructions to turn off everything except 

log.cfg

Share this post


Link to post
Share on other sites
7 hours ago, It's_Matra said:

Yes, instructions are included (link to Google Doc) and you will need to install the fonts file as mentioned above

Thanks, got it working right away. It's excellent work, dispenses with the clutter of other hitlogs and keeps it simple (and legal).

Share this post


Link to post
Share on other sites
2 hours ago, sr360 said:

Thanks, got it working right away. It's excellent work, dispenses with the clutter of other hitlogs and keeps it simple (and legal).

Thanks, feedback is always good to hear!

 

All my mods work on that theory... to remove the clutter and keep things simple and looking like how they should. It was designed to be as flexible as possible across all servers whilst preserving legality

Share this post


Link to post
Share on other sites
On ‎2‎.‎3‎.‎2016 at 7:11 PM, It's_Matra said:

So I have been asked about adding a 'last shot' detail to this, here is what I could do from a quick play this afternoon, if enough of you like it then I will add it (as an option) to the main release for the next patch

Last_Shot.png

Last shot damage is shown in brackets, nothing is shown when there is no recognisable shot

Needs updating, atleast this one doesnt work.

Share this post


Link to post
Share on other sites
14 minutes ago, Shriv3r said:

Needs updating, atleast this one doesnt work.

I know... it takes time for these things, be patient

 

UPDATE: There is a 'working' version available but it's buggy as hell and causes instability issues when run alongside XVM. I won't be releasing a variant of the buggy version. I will wait until XVM (and other mods) are fixed

Share this post


Link to post
Share on other sites
52 minutes ago, It's_Matra said:

I know... it takes time for these things, be patient

 

UPDATE: There is a 'working' version available but it's buggy as hell and causes instability issues when run alongside XVM. I won't be releasing a variant of the buggy version. I will wait until XVM (and other mods) are fixed

No worries, just wanted to give headsup :)

Keep up the good work buddy!

Share this post


Link to post
Share on other sites
1 hour ago, It's_Matra said:

I know... it takes time for these things, be patient

 

UPDATE: There is a 'working' version available but it's buggy as hell and causes instability issues when run alongside XVM. I won't be releasing a variant of the buggy version. I will wait until XVM (and other mods) are fixed

Do you have a dmg counter only version available (non-XVM). Trying to do the -15.4 missions without a dmg counter is tough!

Share this post


Link to post
Share on other sites
7 hours ago, sr360 said:

Do you have a dmg counter only version available (non-XVM). Trying to do the -15.4 missions without a dmg counter is tough!

Not yet, will probably be a couple of days now (as I am a fairly new father, holding a full time job and a trip away to a wedding this weekend :P )

 

Will do what I can tomorrow but can't make any promises. I try not to release mods that conflict with other more commonly used mods (such as XVM)

Share this post


Link to post
Share on other sites
5 hours ago, It's_Matra said:

Not yet, will probably be a couple of days now (as I am a fairly new father, holding a full time job and a trip away to a wedding this weekend :P )

 

Will do what I can tomorrow but can't make any promises. I try not to release mods that conflict with other more commonly used mods (such as XVM)

No worries mate, take your time. 

Share this post


Link to post
Share on other sites

As I'm going to be away from the game for a couple of days I have uploaded a TEST VERSION of the DamageLog.

DO NOT USE IT WITH A NIGHTLY BUILD OF XVM - XVM is still VERY much bugged and they are working hard to fix it. It will likely cause issues if you use XVM

Share this post


Link to post
Share on other sites

From non-wotlabs testers and some replay testing it seems pretty ok so far... XVM causes stability issues and conflicts at the moment but that should be fixed soon (a lot of work involved in getting XVM AS3 ready!!).

Share this post


Link to post
Share on other sites

I noticed that I could not type anything into the chat once yesterday.

Is this the bug you are talking about or anything else?

Other than that the damagelog does what it's supposed to for me. It's the only mod I run atm.

Share this post


Link to post
Share on other sites
18 minutes ago, rindorbrot said:

I noticed that I could not type anything into the chat once yesterday.

Is this the bug you are talking about or anything else?

Other that that the damagelog does what it's supposed to for me. It's the only mod I run atm.

It locks the chat until you enter the postmortem state. Once dead you can type away freely. Yes that is the bug I am talking about

Share this post


Link to post
Share on other sites
10 minutes ago, It's_Matra said:

It locks the chat until you enter the postmortem state. Once dead you can type away freely. Yes that is the bug I am talking about

You can also click the chat box to start typing. As in press Enter to make the chatbox open, then click in the chatbox, and type away. After that first time it works normally.

Share this post


Link to post
Share on other sites
7 hours ago, SchwarzerPeter said:

Besides the chat bug it seems to work normal.

Thanks, I think I may have a fix for the chat bug too but will check it out myself before releasing it. It's a 'rough around the edges' fix but it should work.

 

Nope, chat still bugged but it is a tiny bit more stable now

Share this post


Link to post
Share on other sites

Updated test version to rc2 which has some minor performance tweaks and bug fixes, chat bug still exists and I can't actually see what's causing it... which is incredibly annoying!

Here is the decompiled source if anyone fancies a go

# Embedded file name: C:/World_of_Tanks/res_mods/0.9.15.1/scripts/client\gui\mods\mod_damagelog.py
exec 'eJytUsFu2zAMvfsreLMcGO69ww7dWmwG1iWI0/ZQDIEsyY5WWXIpeln/flJSJ14TDBswnki+R/GJZIOuA+eLntMGdNc7JNBeagTugSdNhJfK37Y4oq5XtlKCtLORU+85H3T74NDIkbVt162iBTo5CLpX6F/pTZI0DqEGbaFmaVFcxM6++NmZNHtMFzFIvxU/uBmUZ9llAq+mG+CsLrivCLVtJ8hoHN7DkfAOalT8KUmkakCy5xy2OahJGQZ6kMiJkO2gA0IBMbyrJYcZz2E2e7qEZ4b5GB2ZflKfh7ogkl56xTALQwTrCHoM80J6AWW8OkSMsmyvTP2zMh8ALTpFGyfZH2X+T52CNYMVE5ExadmMY+t33bbRO7OVyOvYhltpFJ7BR4vPj7T4hd/fPSlDRQNa6JI3CZskwnDv4WG+Wt+tyi/VseXt/LoKA0wv0uK705Y9hjmlXqDuyafBFUYrS9HrnAxXeOy6uFp9DpX8kLi/WVbl/GvI0dAbxTreM20ph4Zlhe+NpnDbaTZZwae7cv33AtpBn9MxD32X5fXN2zMQTGanrHW1ulqVH0/Jar9VA6F/nYPIQe4Oo/kFHXkf/w=='.decode('base64').decode('zlib')
import BigWorld
import GUI
import Math
import ResMgr
import nations
import game
import re
import json
import Keys
from Vehicle import Vehicle
from gui import g_guiResetters
from gui.InputHandler import g_instance
from gui.Scaleform.Flash import Flash
from gui.battle_control import g_sessionProvider
from gui.battle_control.controllers.crosshair_proxy import CrosshairDataProxy
from VehicleEffects import DamageFromShotDecoder
from gui.shared import g_eventBus, EVENT_BUS_SCOPE
from gui.shared.events import GameEvent
from items import _xml
from constants import ITEM_DEFS_PATH
from debug_utils import *
from gui.app_loader.loader import g_appLoader, _AppLoader

class info_DL():

    def __init__(self):
        self.Flash = None
        self._flash = None
        self.Title = 'damageLog'
        self.Version = '0.4.0'
        self.Date = '24.05.2016'
        self.Author = 'GambitER'
        return


class setup_DL():

    def __init__(self):
        self.CONFIG_ELEM = ('TIMER', 'LOG', 'MESSAGE', 'BLOCKED', 'DAMAGED', 'FIRE')
        self.CONFIG = {}

    def loadConfig(self, elem):
        try:
            configFile = './res_mods/configs/damageLog/%s.cfg' % elem.capitalize()

            def JSON_MINIFY(string, strip_space = True):
                tokenizer = re.compile('"|(/\\*)|(\\*/)|(//)|\n|\r')
                end_slashes_re = re.compile('(\\\\)*$')
                in_string = False
                in_multi = False
                in_single = False
                new_str = []
                index = 0
                for match in re.finditer(tokenizer, string):
                    if not (in_multi or in_single):
                        tmp = string[index:match.start()]
                        if not in_string and strip_space:
                            tmp = re.sub('[ \t\n\r]+', '', tmp)
                        new_str.append(tmp)
                    index = match.end()
                    val = match.group()
                    if val == '"' and not (in_multi or in_single):
                        escaped = end_slashes_re.search(string, 0, match.start())
                        if not in_string or escaped is None or len(escaped.group()) % 2 == 0:
                            in_string = not in_string
                        index -= 1
                    elif not (in_string or in_multi or in_single):
                        if val == '/*':
                            in_multi = True
                        elif val == '//':
                            in_single = True
                    elif val == '*/' and in_multi and not (in_string or in_single):
                        in_multi = False
                    elif val in '\r\n' and not (in_multi or in_string) and in_single:
                        in_single = False
                    elif not (in_multi or in_single or val in ' \r\n\t' and strip_space):
                        new_str.append(val)

                new_str.append(string[index:])
                return ''.join(new_str)

            with open(configFile) as openFile:
                readFile = openFile.read()
            CONF = json.loads(JSON_MINIFY(readFile))
        except Exception as Error:
            strLog = '%s (%s.cfg) %s' % (info_DL.Title, elem.capitalize(), str(Error))
            LOG_WARNING(strLog)
            CONF = {}

        return CONF

    def _setupBattle(self):
        for elem in self.CONFIG_ELEM:
            self.CONFIG[elem] = self.loadConfig(elem)

        self.setupSettings()
        self.setupVisible()
        self.setupSize()
        self.setupPosition()
        self.getTextDAMAGED()
        self.getTextBLOCKED()
        self.getTextFIRE()

    def setupVisible(self):
        for elem in self.CONFIG_ELEM:
            bool = self.CONFIG.get(elem, {}).get(elem, {}).get('enable', False)
            info_DL._flash.flashObject.as_setVisible(elem, bool)

    def setupSize(self):
        for elem in self.CONFIG_ELEM:
            elemWidth = self.CONFIG.get(elem, {}).get(elem, {}).get('size', {}).get('width', 0)
            elemHeight = self.CONFIG.get(elem, {}).get(elem, {}).get('size', {}).get('height', 0)
            info_DL._flash.flashObject.as_setSize(elem, elemWidth, elemHeight)

    def setupPosition(self):
        for elem in self.CONFIG_ELEM:
            screenGUI = GUI.screenResolution()
            screenX = {'left': 0,
             'center': screenGUI[0] / 2,
             'right': screenGUI[0]}
            screenY = {'top': 0,
             'center': screenGUI[1] / 2,
             'bottom': screenGUI[1]}
            alignX = self.CONFIG.get(elem, {}).get(elem, {}).get('position', {}).get('align', {}).get('x', 'left')
            alignY = self.CONFIG.get(elem, {}).get(elem, {}).get('position', {}).get('align', {}).get('y', 'top')
            elemX = self.CONFIG.get(elem, {}).get(elem, {}).get('position', {}).get('x', 0) + screenX.get(alignX, 0)
            elemY = self.CONFIG.get(elem, {}).get(elem, {}).get('position', {}).get('y', 0) + screenY.get(alignY, 0)
            info_DL._flash.flashObject.as_setPosition(elem, elemX, elemY)

    def setupSettings(self):
        setFire = self.CONFIG.get('FIRE', {}).get('FIRE', {})
        info_DL._flash.flashObject.as_setFire(setFire.get('debug', False), setFire.get('animation', True))
        setTimer = self.CONFIG.get('TIMER', {}).get('TIMER', {})
        info_DL._flash.flashObject.as_setTimer(setTimer.get('debug', False), setTimer.get('animation', True), setTimer.get('delay', 5))
        setLog = self.CONFIG.get('LOG', {}).get('LOG', {})
        info_DL._flash.flashObject.as_setLog(setLog.get('debug', False), setLog.get('animation', True), setLog.get('invert', True), setLog.get('line', {}).get('number', 11), setLog.get('line', {}).get('spacing', 0), setLog.get('line', {}).get('indents', []))
        setMessage = self.CONFIG.get('MESSAGE', {}).get('MESSAGE', {})
        info_DL._flash.flashObject.as_setMessage(setMessage.get('debug', False), setMessage.get('animation', True), setMessage.get('delay', 5))
        setDamaged = self.CONFIG.get('DAMAGED', {}).get('DAMAGED', {})
        info_DL._flash.flashObject.as_setDamaged(setDamaged.get('debug', False), setDamaged.get('animation', True))
        setBlocked = self.CONFIG.get('BLOCKED', {}).get('BLOCKED', {})
        info_DL._flash.flashObject.as_setBlocked(setBlocked.get('debug', False), setBlocked.get('animation', True))

    def setupVisibleElems(self, camera):
        if camera != 'postmortem':
            return

        def isVisible(elem):
            if not self.CONFIG.get(elem, {}).get(elem, {}).get('enable', False):
                return False
            if not self.CONFIG.get(elem, {}).get(elem, {}).get('showPostmortem', False):
                return False
            return True

        for elem in self.CONFIG_ELEM:
            isShow = isVisible(elem)
            info_DL._flash.flashObject.as_setVisible(elem, isShow)

    def getTextDAMAGED(self):
        try:
            CONFIG = self.CONFIG.get('DAMAGED', {}).get('DAMAGED', {})
            if not CONFIG.get('enable'):
                return
            DAMAGED_PreText = CONFIG.get('format', {}).get('pretext', '')
            DAMAGED_PreTextAlt = CONFIG.get('format', {}).get('altpretext', '')
            TEXT_DAMAGED = damageLog.get_formatText('DAMAGED', [DAMAGED_PreText, DAMAGED_PreTextAlt])
            if TEXT_DAMAGED[0] == damageLog.get_htmlText('') and TEXT_DAMAGED[1] == damageLog.get_htmlText(''):
                return
            info_DL._flash.flashObject.as_getDamaged(TEXT_DAMAGED[0], TEXT_DAMAGED[1])
        except Exception as Error:
            strLog = '%s (getTextDAMAGED) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

    def getTextBLOCKED(self):
        try:
            CONFIG = self.CONFIG.get('BLOCKED', {}).get('BLOCKED', {})
            if not CONFIG.get('enable'):
                return
            BLOCKED_PreText = CONFIG.get('format', {}).get('pretext', '')
            BLOCKED_PreTextAlt = CONFIG.get('format', {}).get('altpretext', '')
            TEXT_BLOCKED = damageLog.get_formatText('BLOCKED', [BLOCKED_PreText, BLOCKED_PreTextAlt])
            if TEXT_BLOCKED[0] == damageLog.get_htmlText('') and TEXT_BLOCKED[1] == damageLog.get_htmlText(''):
                return
            info_DL._flash.flashObject.as_getBlocked(TEXT_BLOCKED[0], TEXT_BLOCKED[1])
        except Exception as Error:
            strLog = '%s (getTextBLOCKED) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

    def getTextFIRE(self):
        try:
            CONFIG = self.CONFIG.get('FIRE', {}).get('FIRE', {})
            if not CONFIG.get('enable'):
                return
            FIRE_Text = CONFIG.get('format', {}).get('text', '')
            TEXT_FIRE = damageLog.get_formatText('FIRE', [FIRE_Text])
            if TEXT_FIRE[0] == damageLog.get_htmlText(''):
                return
            info_DL._flash.flashObject.as_getFire(TEXT_FIRE[0])
        except Exception as Error:
            strLog = '%s (getTextFIRE) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)


class damageLog():
    CALLBACK_INTERVAL = 0.15
    TYPES_TEAM_PLAYER = {0: 'player',
     1: 'ally',
     2: 'enemy'}
    TYPES_DAMAGE_REASONS = {0: 'damage',
     1: 'nodamage'}
    TYPES_ATTACK_REASONS = {0: 'shot',
     1: 'fire',
     2: 'ramming',
     3: 'world_collision',
     4: 'death_zone',
     5: 'drowning',
     6: 'gas_attack',
     24: 'art_attack',
     25: 'air_strike'}
    TYPES_HIT_EFFECT = {0: 'ricochet',
     1: 'ricochet',
     2: 'armor',
     3: 'resisted',
     4: 'damage'}
    TYPES_SHELL_COST = {0: 'credits',
     1: 'gold'}
    TYPES_SHELL_INDEX = {'ARMOR_PIERCING': 'AP',
     'ARMOR_PIERCING_CR': 'APC',
     'HIGH_EXPLOSIVE': 'HE',
     'HOLLOW_CHARGE': 'HC'}
    TYPES_VEHICLE_CLASSES = ('lightTank', 'mediumTank', 'heavyTank', 'SPG', 'AT-SPG')
    TYPES_COMPONENT_NAMES = {'chassis',
     'hull',
     'turret',
     'gun'}

    def _setFireInVehicle(self, battle, bool):
        self.isShowFire(bool)
        CONFIG = setup_DL.CONFIG.get('FIRE', {}).get('FIRE', {})
        showFireIcon = CONFIG.get('showFireIcon', True)
        if showFireIcon:
            DL_orig_Battle_setFireInVehicle(battle, bool)

    def isShowFire(self, bool):
        info_DL._flash.flashObject.as_showFire(bool)

    def __init__(self):
        self.isTempHit = None
        self.infoHealth = {}
        self.infoHit = {}
        self.infoPrevHit = {}
        self.infoBattle = {}
        self.isPlayer = None
        self.INFO_HIT = {}
        return

    def _clearInfo(self):
        self.isTempHit = None
        self.infoHealth.clear()
        self.infoHit.clear()
        self.infoPrevHit.clear()
        self.infoBattle.clear()
        self.INFO_HIT.clear()
        self.isShowFire(False)
        return

    def _showShooting(self, vehicle, burstCount, isPredictedShot):
        if not vehicle.isStarted or not vehicle.isPlayerVehicle or not vehicle.isAlive():
            return
        elif isPredictedShot or BigWorld.player().isWaitingForShot:
            return
        else:
            self.infoBattle['shotsPlayer'] = self.infoBattle.get('shotsPlayer', 0) + 1
            self.INFO_HIT['shotsPlayer'] = self.infoBattle.get('shotsPlayer', 0)
            self.infoBattle['killPlayer'] = None
            self.INFO_HIT['killPlayer'] = self.infoBattle.get('killPlayer')
            self.CALL_DAMAGED()
            return

    def _initVehicle(self, vehicle):
        self.infoHealth[vehicle.id] = vehicle.health

    def _onHealthChanged(self, vehicle, newHealth, attackerID, attackReasonID):
        if not vehicle.isStarted:
            return
        else:
            newHealth = max(0, newHealth)
            vehicleHealth = self.infoHealth.get(vehicle.id, vehicle.typeDescriptor.maxHealth)
            isDamage = vehicleHealth - newHealth
            self.infoHealth[vehicle.id] = newHealth
            if newHealth == 0:
                self.isShowFire(False)
            ATTACK_REASONS = self.TYPES_ATTACK_REASONS.get(attackReasonID, '[reason_%s]' % attackReasonID if attackReasonID is not None else None)
            vehicleKill = None if newHealth != 0 else ATTACK_REASONS
            self.DAMAGER_SQUAD(vehicle, attackerID, attackReasonID, isDamage, vehicleKill)
            if not vehicle.isPlayerVehicle:
                return
            self.infoHit['isDamage'] = isDamage
            self.infoHit['attackerID'] = attackerID
            self.infoHit['indexReason'] = ATTACK_REASONS
            self.infoHit['indexHit'] = self.TYPES_HIT_EFFECT[4] if attackReasonID == 0 else None
            self.infoHit['compName'] = self.infoHit.get('compName') if attackReasonID == 0 else None
            self.infoHit['isBlocked'] = False
            self.PLAYER_GET_HIT()
            return

    def _showDamageFromExplosion(self, vehicle, attackerID, center, effectsIndex, damageFactor):
        if not vehicle.isStarted or not vehicle.isPlayerVehicle:
            return
        self.onTempHit()
        self.infoHit['isDamage'] = 0
        self.infoHit['attackerID'] = attackerID
        self.infoHit['indexEffects'] = effectsIndex
        self.infoHit['indexReason'] = self.TYPES_ATTACK_REASONS[0]
        self.infoHit['indexHit'] = self.TYPES_HIT_EFFECT[3]
        self.infoHit['isSplash'] = True
        self.infoHit['isCritical'] = False
        self.infoHit['isBlocked'] = False
        self.isTempHit = vehicle.isAlive()
        BigWorld.callback(self.CALLBACK_INTERVAL, self.onTempHit)

    def _showDamageFromShot(self, vehicle, attackerID, points, effectsIndex, damageFactor):
        if not vehicle.isStarted or not vehicle.isPlayerVehicle:
            return
        else:
            self.onTempHit()
            indexHit, decodeCompName = DamageFromShotDecoder.decodeHitPoints(points, vehicle.typeDescriptor)
            compName = decodeCompName[0].componentName if decodeCompName else None

            def blockedArmorHit(vehicle, decodeCompName):
                canHitPrimaryArmor = None
                compMatrix = Math.Matrix(vehicle.appearance.compoundModel.node(decodeCompName.componentName))
                firstHitDirLocal = decodeCompName.matrix.applyToAxis(2)
                firstHitDir = compMatrix.applyVector(firstHitDirLocal)
                firstHitPoint = decodeCompName.matrix.translation
                firstHitPos = compMatrix.applyPoint(firstHitPoint)
                worldToVehMatrix = Math.Matrix(vehicle.model.matrix)
                worldToVehMatrix.invert()
                startPoint = worldToVehMatrix.applyPoint(firstHitPos - firstHitDir)
                endPoint = worldToVehMatrix.applyPoint(firstHitPos + firstHitDir.scale(10.0))
                for compDescr, compMatrix, isAttached in vehicle.getComponents():
                    if not isAttached:
                        continue
                    collisions = compDescr['hitTester'].localHitTest(compMatrix.applyPoint(startPoint), compMatrix.applyPoint(endPoint))
                    if collisions is None:
                        continue
                    for dist, _, hitAngleCos, matKind in collisions:
                        matInfo = compDescr['materials'].get(matKind)
                        canHitPrimaryArmor = True if matInfo is not None and matInfo.useArmorHomogenization else False
                        if canHitPrimaryArmor:
                            break

                    if canHitPrimaryArmor:
                        break

                return canHitPrimaryArmor

            self.infoHit['isDamage'] = 0
            self.infoHit['attackerID'] = attackerID
            self.infoHit['indexEffects'] = effectsIndex
            self.infoHit['indexReason'] = self.TYPES_ATTACK_REASONS[0]
            self.infoHit['indexHit'] = self.TYPES_HIT_EFFECT.get(indexHit if indexHit != 5 else 3, '[index_%s]' % indexHit if indexHit is not None else None)
            self.infoHit['compName'] = compName
            self.infoHit['isSplash'] = False
            self.infoHit['isCritical'] = False if indexHit != 5 else True
            self.infoHit['isBlocked'] = blockedArmorHit(vehicle, decodeCompName[0]) if decodeCompName else False
            if indexHit == 5:
                self.isTempHit = vehicle.isAlive()
                BigWorld.callback(self.CALLBACK_INTERVAL, self.onTempHit)
            elif indexHit < 4 and vehicle.isAlive():
                self.PLAYER_GET_HIT()
            return

    def onTempHit(self):
        if self.isTempHit:
            self.PLAYER_GET_HIT()

    def onData_VehicleGun(self, attacker):
        _CLIP_SIZE = _CLIP_RELOAD = _GUN_BURST = _GUN_RELOAD = None
        try:
            if 'clip' in attacker['vehicleType'].gun:
                gunClip = attacker['vehicleType'].gun['clip']
                _CLIP_SIZE = gunClip[0] if gunClip[0] > 1 else None
                _CLIP_RELOAD = '{0:.1f}'.format(gunClip[1]) if gunClip[0] > 1 else None
            if 'burst' in attacker['vehicleType'].gun:
                gunBurst = attacker['vehicleType'].gun['burst']
                _GUN_BURST = gunBurst[0] if gunBurst[0] > 1 else None
            if 'reloadTime' in attacker['vehicleType'].gun:
                loader_skill = 126.5
                other_bonus = 1.0
                for item in attacker['vehicleType'].optionalDevices:
                    if item is not None and 'improvedVentilation' in item.name:
                        loader_skill = 132.0
                    if item is not None and 'TankRammer' in item.name:
                        other_bonus *= 0.9

                _GUN_RELOAD = '{0:.1f}'.format(attacker['vehicleType'].gun['reloadTime'] * 0.875 / (0.00375 * loader_skill + 0.5) * other_bonus)
            return (_CLIP_SIZE,
             _CLIP_RELOAD,
             _GUN_BURST,
             _GUN_RELOAD)
        except Exception as Error:
            return (_CLIP_SIZE,
             _CLIP_RELOAD,
             _GUN_BURST,
             _GUN_RELOAD)

        return

    def onData_Shell(self, attacker, indexEffects):
        _SHELL_TYPE = _SHELL_VALUE = _SHELL_COST = None
        try:
            price = {}
            for shell in attacker['vehicleType'].gun['shots']:
                if indexEffects == shell['shell']['effectsIndex']:
                    _SHELL_TYPE = self.TYPES_SHELL_INDEX.get(shell['shell']['kind'], shell['shell']['kind'])
                    _SHELL_VALUE = int(shell['shell']['damage'][0])
                    nationID = shell['shell']['id'][0]
                    shellID = shell['shell']['id'][1]
                    xmlPath = ITEM_DEFS_PATH + 'vehicles/' + nations.NAMES[nationID] + '/components/shells.xml'
                    for name, subsection in ResMgr.openSection(xmlPath).items():
                        if name != 'icons':
                            xmlCtx = (None, xmlPath + '/' + name)
                            if _xml.readInt(xmlCtx, subsection, 'id', 0, 65535) == shellID:
                                price = _xml.readPrice(xmlCtx, subsection, 'price')
                                _SHELL_COST = self.TYPES_SHELL_COST[1] if price[1] != 0 else self.TYPES_SHELL_COST[0]
                                break

                    ResMgr.purge(xmlPath, True)
                    break

            return (_SHELL_TYPE, _SHELL_VALUE, _SHELL_COST)
        except Exception as Error:
            return (_SHELL_TYPE, _SHELL_VALUE, _SHELL_COST)

        return

    def DAMAGER_SQUAD(self, vehicle, attackerID, attackReasonID, isDamage, vehicleKill):
        self.infoBattle['killPlayer'] = None
        isDamaged = -1
        player = BigWorld.player()
        attacker = player.arena.vehicles.get(attackerID, dict())
        attacked = player.arena.vehicles.get(vehicle.id, dict())
        if attacker.get('team') != attacked.get('team'):
            if attackerID == player.playerVehicleID:
                isDamaged = 0
                infoDamager = attacker.get('name')
                self.infoBattle['damagePlayer'] = isDamage
                self.infoBattle['damagesPlayer'] = self.infoBattle.get('damagesPlayer', 0) + isDamage
                if attackReasonID == 0:
                    self.infoBattle['shotPlayer'] = self.infoBattle.get('shotPlayer', 0) + 1
                self.infoBattle['killPlayer'] = vehicleKill
            elif g_sessionProvider.getArenaDP().isSquadMan(attackerID):
                isDamaged = 1
                infoDamager = attacker.get('name')
                self.infoBattle['damageSquad'] = isDamage
                self.infoBattle['damagesSquad'] = self.infoBattle.get('damagesSquad', 0) + isDamage
        if isDamaged < 0:
            return
        else:
            self.INFO_HIT['killPlayer'] = self.infoBattle.get('killPlayer')
            self.INFO_HIT['shotPlayer'] = self.infoBattle.get('shotPlayer', 0)
            self.INFO_HIT['damagePlayer'] = self.infoBattle.get('damagePlayer', 0)
            self.INFO_HIT['damagesPlayer'] = self.infoBattle.get('damagesPlayer', 0)
            self.INFO_HIT['damageSquad'] = self.infoBattle.get('damageSquad', 0)
            self.INFO_HIT['damagesSquad'] = self.infoBattle.get('damagesSquad', 0)
            self.INFO_HIT['damagesTotal'] = self.infoBattle.get('damagesPlayer', 0) + self.infoBattle.get('damagesSquad', 0)
            if isDamaged == 0:
                self.INFO_HIT['totalDamages'] = self.INFO_HIT.get('totalDamages', 0) + self.infoBattle.get('damagePlayer', 0)
                self.CALL_BLOCKED()
            self.CALL_DAMAGED()
            return

    def PLAYER_GET_HIT(self):
        self.isTempHit = False
        HIT_DAMAGE = self.infoHit.get('isDamage')
        HIT_ATTACKER = self.infoHit.get('attackerID')
        HIT_EFFECTS = self.infoHit.get('indexEffects')
        HIT_REASON = self.infoHit.get('indexReason')
        HIT_INDEX = self.infoHit.get('indexHit')
        HIT_COMPNAME = self.infoHit.get('compName')
        HIT_SPLASH = self.infoHit.get('isSplash')
        HIT_CRITICAL = self.infoHit.get('isCritical')
        HIT_BLOCKED = self.infoHit.get('isBlocked')
        self.infoHit.clear()
        player = BigWorld.player()
        attacker = player.arena.vehicles.get(HIT_ATTACKER, dict())
        ATTACKER_NICKNAME = attacker.get('name')
        ATTACKER_TEAM = None if attacker.get('team') is None else (self.TYPES_TEAM_PLAYER[2] if player.team != attacker.get('team') else (self.TYPES_TEAM_PLAYER[1] if HIT_ATTACKER != player.playerVehicleID else self.TYPES_TEAM_PLAYER[0]))
        VEHICLE_LEVEL = None if attacker.get('vehicleType') is None else attacker['vehicleType'].level
        VEHICLE_NAME = None if attacker.get('vehicleType') is None else unicode(attacker['vehicleType'].type.userString, 'utf-8')
        VEHICLE_SHORTNAME = None if attacker.get('vehicleType') is None else unicode(attacker['vehicleType'].type.shortUserString, 'utf-8')
        VEHICLE_CLASS = g_sessionProvider.getArenaDP().getVehicleInfo(HIT_ATTACKER).vehicleType.classTag
        VEHICLE_ICON = None if attacker.get('vehicleType') is None else attacker['vehicleType'].name.replace(':', '-')
        CLIP_SIZE, CLIP_RELOAD, GUN_BURST, GUN_RELOAD = self.onData_VehicleGun(attacker)
        SHELL_TYPE, SHELL_VALUE, SHELL_COST = self.onData_Shell(attacker, HIT_EFFECTS)
        if HIT_EFFECTS == 24 or HIT_EFFECTS == 25:
            HIT_REASON = self.TYPES_ATTACK_REASONS[HIT_EFFECTS]

        def boolNewHit():
            if HIT_REASON == self.TYPES_ATTACK_REASONS[0]:
                return True
            elif self.infoPrevHit.get('attackerID') is None or self.infoPrevHit.get('attackerID') != HIT_ATTACKER:
                return True
            elif self.infoPrevHit.get('indexReason') is None or self.infoPrevHit.get('indexReason') != HIT_REASON:
                return True
            else:
                return False

        NEW_HIT = boolNewHit()
        HIT_DAMAGES = HIT_DAMAGE + self.infoPrevHit.get('isDamage', 0) if not NEW_HIT else HIT_DAMAGE
        self.infoPrevHit['isDamage'] = HIT_DAMAGES
        self.infoPrevHit['attackerID'] = HIT_ATTACKER
        self.infoPrevHit['indexReason'] = HIT_REASON if HIT_REASON != self.TYPES_ATTACK_REASONS[0] else None

        def typesHit():
            if HIT_DAMAGE > 0:
                return self.TYPES_DAMAGE_REASONS[0]
            return self.TYPES_DAMAGE_REASONS[1]

        HIT_TYPES = typesHit()

        def boolBlocked():
            if not HIT_BLOCKED:
                return False
            elif SHELL_TYPE is None or SHELL_TYPE == 'HE':
                return False
            elif ATTACKER_TEAM != 'enemy':
                return False
            else:
                return True

        HIT_BLOCKED = boolBlocked()
        if HIT_BLOCKED:
            self.infoBattle['numberBlock'] = self.infoBattle.get('numberBlock', 0) + 1
            self.infoBattle['damageBlock'] = self.infoBattle.get('damageBlock', 0) + (SHELL_VALUE or 0)
            TOTAL_DAMAGES = self.INFO_HIT.get('totalDamages', 0) + (SHELL_VALUE or 0)
        else:
            TOTAL_DAMAGES = self.INFO_HIT.get('totalDamages', 0) + (HIT_DAMAGE or 0)
        if HIT_REASON == self.TYPES_ATTACK_REASONS[0]:
            if HIT_TYPES == 'damage':
                self.infoBattle['numberDamage'] = self.infoBattle.get('numberDamage', 0) + 1
            if HIT_TYPES == 'nodamage':
                self.infoBattle['numberNoDamage'] = self.infoBattle.get('numberNoDamage', 0) + 1
            self.infoBattle['numberShot'] = self.infoBattle.get('numberShot', 0) + 1
        playerHealth = player.vehicle.health if hasattr(player, 'vehicle') and hasattr(player.vehicle, 'health') else None
        playerMaxHealth = player.vehicleTypeDescriptor.maxHealth if hasattr(player, 'vehicleTypeDescriptor') and hasattr(player.vehicleTypeDescriptor, 'maxHealth') else None
        playerLostHealth = playerMaxHealth - playerHealth if playerMaxHealth is not None and playerHealth is not None else 0
        RATIO_VALUE = 100 * HIT_DAMAGE / SHELL_VALUE if SHELL_VALUE is not None and HIT_DAMAGE > 0 else None
        RATIO_DAMAGE = 100 * HIT_DAMAGE / playerMaxHealth if HIT_DAMAGE is not None and playerMaxHealth is not None else None
        RATIO_DAMAGES = 100 * HIT_DAMAGES / playerMaxHealth if HIT_DAMAGES is not None and playerMaxHealth is not None else None
        self.INFO_HIT['typesHit'] = HIT_TYPES
        self.INFO_HIT['damageHit'] = HIT_DAMAGE
        self.INFO_HIT['damagesHit'] = HIT_DAMAGES
        self.INFO_HIT['lostHealth'] = playerLostHealth
        self.INFO_HIT['reasonHit'] = HIT_REASON
        self.INFO_HIT['indexHit'] = HIT_INDEX
        self.INFO_HIT['compHit'] = HIT_COMPNAME
        self.INFO_HIT['splashHit'] = HIT_SPLASH
        self.INFO_HIT['criticalHit'] = HIT_CRITICAL
        self.INFO_HIT['blockedHit'] = HIT_BLOCKED
        self.INFO_HIT['nickAttacker'] = ATTACKER_NICKNAME
        self.INFO_HIT['teamAttacker'] = ATTACKER_TEAM
        self.INFO_HIT['levelVehicle'] = VEHICLE_LEVEL
        self.INFO_HIT['nameVehicle'] = VEHICLE_NAME
        self.INFO_HIT['shortVehicle'] = VEHICLE_SHORTNAME
        self.INFO_HIT['classVehicle'] = VEHICLE_CLASS
        self.INFO_HIT['iconVehicle'] = VEHICLE_ICON
        self.INFO_HIT['sizeClip'] = CLIP_SIZE
        self.INFO_HIT['reloadClip'] = CLIP_RELOAD
        self.INFO_HIT['burstGun'] = GUN_BURST
        self.INFO_HIT['reloadGun'] = GUN_RELOAD
        self.INFO_HIT['typeShell'] = SHELL_TYPE
        self.INFO_HIT['valueShell'] = SHELL_VALUE
        self.INFO_HIT['costShell'] = SHELL_COST
        self.INFO_HIT['damagesBlocked'] = self.infoBattle.get('damageBlock', 0)
        self.INFO_HIT['numberBlocked'] = self.infoBattle.get('numberBlock', 0)
        self.INFO_HIT['numberShot'] = self.infoBattle.get('numberShot', 0)
        self.INFO_HIT['numberDamage'] = self.infoBattle.get('numberDamage', 0)
        self.INFO_HIT['numberNoDamage'] = self.infoBattle.get('numberNoDamage', 0)
        self.INFO_HIT['totalDamages'] = TOTAL_DAMAGES
        self.INFO_HIT['damageRatio'] = RATIO_DAMAGE
        self.INFO_HIT['damagesRatio'] = RATIO_DAMAGES
        self.INFO_HIT['valueRatio'] = RATIO_VALUE
        self.INFO_HIT['numberLog'] = None
        self.INFO_HIT['timerHit'] = None
        self.INFO_HIT['newHit'] = NEW_HIT
        self.CALL_BLOCKED()
        self.CALL_MESSAGE()
        self.CALL_LOG()
        self.CALL_TIMER()
        return

    def CALL_DAMAGED(self):
        try:
            CONFIG = setup_DL.CONFIG.get('DAMAGED', {}).get('DAMAGED', {})
            if not CONFIG.get('enable'):
                return
            DAMAGED_Text = CONFIG.get('format', {}).get('text', '')
            DAMAGED_TextAlt = CONFIG.get('format', {}).get('alttext', '')
            TEXT_DAMAGED = self.get_formatText('DAMAGED', [DAMAGED_Text, DAMAGED_TextAlt])
            if TEXT_DAMAGED[0] == self.get_htmlText('') and TEXT_DAMAGED[1] == self.get_htmlText(''):
                return
            info_DL._flash.flashObject.as_getDamaged(TEXT_DAMAGED[0], TEXT_DAMAGED[1])
        except Exception as Error:
            strLog = '%s (CALL_DAMAGED) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

    def CALL_BLOCKED(self):
        try:
            CONFIG = setup_DL.CONFIG.get('BLOCKED', {}).get('BLOCKED', {})
            if not CONFIG.get('enable'):
                return
            BLOCKED_Text = CONFIG.get('format', {}).get('text', '')
            BLOCKED_TextAlt = CONFIG.get('format', {}).get('alttext', '')
            TEXT_BLOCKED = self.get_formatText('BLOCKED', [BLOCKED_Text, BLOCKED_TextAlt])
            if TEXT_BLOCKED[0] == self.get_htmlText('') and TEXT_BLOCKED[1] == self.get_htmlText(''):
                return
            info_DL._flash.flashObject.as_getBlocked(TEXT_BLOCKED[0], TEXT_BLOCKED[1])
        except Exception as Error:
            strLog = '%s (CALL_BLOCKED) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

    def CALL_MESSAGE(self):
        try:
            CONFIG = setup_DL.CONFIG.get('MESSAGE', {}).get('MESSAGE', {})
            if not CONFIG.get('enable'):
                return
            CALL_MESSAGE = True if self.INFO_HIT['typesHit'] != 'nodamage' else CONFIG.get('showHitNoDamage')
            if not CALL_MESSAGE:
                return
            MESSAGE_Text = CONFIG.get('format', {}).get('text', '')
            TEXT_MESSAGE = self.get_formatText('MESSAGE', [MESSAGE_Text])
            if TEXT_MESSAGE[0] == self.get_htmlText(''):
                return
            info_DL._flash.flashObject.as_getMessage(TEXT_MESSAGE[0])
        except Exception as Error:
            strLog = '%s (CALL_MESSAGE) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

    def CALL_LOG(self):
        try:
            CONFIG = setup_DL.CONFIG.get('LOG', {}).get('LOG', {})
            if not CONFIG.get('enable'):
                return
            CALL_LOG = True if self.INFO_HIT['typesHit'] != 'nodamage' else CONFIG.get('showHitNoDamage')
            if not CALL_LOG:
                return
            NEW_HIT_LOG = not CONFIG.get('totalDamage') or self.INFO_HIT['newHit']
            if NEW_HIT_LOG:
                self.infoBattle['numberLog'] = self.infoBattle.get('numberLog', 0) + 1
            self.INFO_HIT['numberLog'] = self.infoBattle.get('numberLog', 0)
            LOG_Text = CONFIG.get('format', {}).get('text', '')
            LOG_TextAlt = CONFIG.get('format', {}).get('alttext', '')
            TEXT_LOG = self.get_formatText('LOG', [LOG_Text, LOG_TextAlt])
            if TEXT_LOG[0] == self.get_htmlText('') and TEXT_LOG[1] == self.get_htmlText(''):
                return
            info_DL._flash.flashObject.as_getLog(TEXT_LOG[0], TEXT_LOG[1], NEW_HIT_LOG, self.INFO_HIT['typesHit'])
        except Exception as Error:
            strLog = '%s (CALL_LOG) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

    def CALL_TIMER(self):
        try:
            CONFIG = setup_DL.CONFIG.get('TIMER', {})
            if not CONFIG.get('TIMER', {}).get('enable'):
                return
            if self.INFO_HIT['reasonHit'] != self.TYPES_ATTACK_REASONS[0]:
                return
            self.INFO_HIT['timerHit'] = '<t>'
            TIMER_Text = CONFIG.get('TIMER', {}).get('format', {}).get('text', '')
            TIMER_EndText = CONFIG.get('TIMER', {}).get('format', {}).get('endtext', '')
            TIMER_TextAlt = CONFIG.get('TIMER', {}).get('format', {}).get('alttext', '')
            TIMER_EndTextAlt = CONFIG.get('TIMER', {}).get('format', {}).get('altendtext', '')
            TEXT_TIMER = self.get_formatText('TIMER', [TIMER_Text,
             TIMER_EndText,
             TIMER_TextAlt,
             TIMER_EndTextAlt])
            if TEXT_TIMER[0] == self.get_htmlText('') and TEXT_TIMER[1] == self.get_htmlText('') and TEXT_TIMER[2] == self.get_htmlText('') and TEXT_TIMER[3] == self.get_htmlText(''):
                return
            if self.INFO_HIT['reloadGun'] > 0:
                info_DL._flash.flashObject.as_getTimer(TEXT_TIMER[0], TEXT_TIMER[1], TEXT_TIMER[2], TEXT_TIMER[3], self.INFO_HIT['reloadGun'])
        except Exception as Error:
            strLog = '%s (CALL_TIMER) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

    def get_formatText(self, elem, textList):
        CONFIG = setup_DL.CONFIG.get(elem, {})
        cfgMacros = CONFIG.get('MACROS', {})
        getMacros = self.get_macrosHit(cfgMacros)
        cfgBG = CONFIG.get(elem, {}).get('background', {})
        imageBG, alphaBG, heightBG, widthBG, offsetxBG, offsetyBG = self.get_bgText(cfgBG, getMacros)
        info_DL._flash.flashObject.as_setBg(elem, imageBG, alphaBG, heightBG, widthBG, offsetxBG, offsetyBG)
        cfgShadow = CONFIG.get(elem, {}).get('shadow', {})
        alphaSHADOW, colorSHADOW, angleSHADOW, strengthSHADOW, distanceSHADOW, sizeSHADOW = self.get_shadowText(cfgShadow, getMacros)
        info_DL._flash.flashObject.as_setShadow(elem, alphaSHADOW, colorSHADOW, angleSHADOW, strengthSHADOW, distanceSHADOW, sizeSHADOW)
        cfgList = []
        for getList in textList:
            getText = self.get_macrosText(str(getList), getMacros)
            getText = self.get_htmlText(getText)
            cfgList.append(getText)

        return cfgList

    def get_bgText(self, BG, MACROS):
        image = self.get_macrosText(str(BG.get('image', 'default')), MACROS)
        alpha = self.get_macrosText(str(BG.get('alpha', 0)), MACROS)
        height = self.get_macrosText(str(BG.get('height', 25)), MACROS)
        width = self.get_macrosText(str(BG.get('width', 100)), MACROS)
        offsetx = self.get_macrosText(str(BG.get('offset', {}).get('x', 0)), MACROS)
        offsety = self.get_macrosText(str(BG.get('offset', {}).get('y', 0)), MACROS)
        return (image,
         alpha,
         height,
         width,
         offsetx,
         offsety)

    def get_shadowText(self, SHADOW, MACROS):
        alpha = self.get_macrosText(str(SHADOW.get('alpha', 100)), MACROS)
        color = self.get_macrosText(str(SHADOW.get('color', 0)), MACROS)
        angle = self.get_macrosText(str(SHADOW.get('angle', 90)), MACROS)
        strength = self.get_macrosText(str(SHADOW.get('strength', 200)), MACROS)
        distance = self.get_macrosText(str(SHADOW.get('distance', 0)), MACROS)
        size = self.get_macrosText(str(SHADOW.get('size', 3)), MACROS)
        return (alpha,
         color,
         angle,
         strength,
         distance,
         size)

    def get_macrosHit(self, MACROS):
        INFO_HIT_MACROS = {}
        try:
            for macros in MACROS:
                value = [ v for m, v in self.INFO_HIT.iteritems() if m in macros ]
                value = value[0] if len(value) > 0 else None
                INFO_HIT_MACROS[macros] = MACROS[macros].get(str(value), value)

        except Exception as Error:
            strLog = '%s (get_macrosHit) %s' % (info_DL.Title, str(Error))
            LOG_ERROR(strLog)

        return INFO_HIT_MACROS

    def get_macrosText(self, TEXT, MACROS):
        try:
            i = 9
            while i > 0 and '{' in TEXT and '}' in TEXT:
                i = i - 1
                TEXT = TEXT.format(**MACROS)

        except Exception as Error:
            strLog = '%s (get_macrosText) %s (%s)' % (info_DL.Title, str(Error), str(TEXT))
            LOG_ERROR(strLog)
            TEXT = '[ Error: Text Formatting ]'

        return TEXT

    def get_htmlText(self, string):
        return '<font face="$UniversCondC" color="#FFFFFF" size="14">{text}</font>'.format(text=string)


info_DL = info_DL()
setup_DL = setup_DL()
damageLog = damageLog()

@WOT_UTILS.OVERRIDE(_AppLoader, 'showBattle')
def hooked_showBattle(baseMethod, baseObject):
    baseMethod(baseObject)
    g_appLoader.getDefBattleApp().loadView('damageLogInjector')


@WOT_UTILS.OVERRIDE(_AppLoader, 'destroyBattle')
def hooked_destroyBattle(baseMethod, baseObject):
    if not info_DL._flash:
        return baseMethod(baseObject)
    else:
        damageLog._clearInfo()
        info_DL._flash = None
        baseMethod(baseObject)
        return


@WOT_UTILS.OVERRIDE(Vehicle, '__init__')
def hooked_vehicleInit(baseMethod, baseObject):
    baseMethod(baseObject)
    damageLog._initVehicle(baseObject)


@WOT_UTILS.OVERRIDE(Vehicle, 'onHealthChanged')
def hooked_onHealthChanged(baseMethod, baseObject, newHealth, attackerID, attackReasonID):
    baseMethod(baseObject, newHealth, attackerID, attackReasonID)
    if not info_DL._flash:
        return
    damageLog._onHealthChanged(baseObject, newHealth, attackerID, attackReasonID)


@WOT_UTILS.OVERRIDE(Vehicle, 'showDamageFromExplosion')
def hooked_showDamageFromExplosion(baseMethod, baseObject, attackerID, center, effectsIndex, damageFactor):
    baseMethod(baseObject, attackerID, center, effectsIndex, damageFactor)
    if not info_DL._flash:
        return
    damageLog._showDamageFromExplosion(baseObject, attackerID, center, effectsIndex, damageFactor)


@WOT_UTILS.OVERRIDE(Vehicle, 'showDamageFromShot')
def hooked_showDamageFromShot(baseMethod, baseObject, attackerID, points, effectsIndex, damageFactor):
    baseMethod(baseObject, attackerID, points, effectsIndex, damageFactor)
    if not info_DL._flash:
        return
    damageLog._showDamageFromShot(baseObject, attackerID, points, effectsIndex, damageFactor)


@WOT_UTILS.OVERRIDE(Vehicle, 'showShooting')
def hooked_showShooting(baseMethod, baseObject, burstCount, isPredictedShot = False):
    baseMethod(baseObject, burstCount, isPredictedShot)
    if not info_DL._flash:
        return
    damageLog._showShooting(baseObject, burstCount, isPredictedShot)


def hooked_setFireInVehicle(baseMethod, baseObject, bool):
    baseMethod(baseObject, bool)
    if not info_DL._flash:
        return
    damageLog._setFireInVehicle(baseObject, bool)


@WOT_UTILS.OVERRIDE(CrosshairDataProxy, '_CrosshairDataProxy__onAvatarControlModeChanged')
def hooked_onAvatarControlModeChanged(baseMethod, baseObject, ctrlMode):
    baseMethod(baseObject, ctrlMode)
    if not info_DL._flash:
        return
    setup_DL.setupVisibleElems(ctrlMode)


import GUI
from gui import g_guiResetters
from gui.app_loader.loader import g_appLoader, _AppLoader
from gui.battle_control import g_sessionProvider
from gui.Scaleform.genConsts.BATTLE_VIEW_ALIASES import BATTLE_VIEW_ALIASES
from gui.Scaleform.framework import g_entitiesFactories, ViewSettings, ViewTypes, ScopeTemplates
from gui.Scaleform.framework.entities.View import View
from gui.Scaleform.framework.entities.BaseDAAPIComponent import BaseDAAPIComponent
from gui.shared import g_eventBus, events, EVENT_BUS_SCOPE

class damageLogUI(BaseDAAPIComponent):

    def _populate(self):
        super(damageLogUI, self)._populate()
        info_DL._flash = self
        setup_DL._setupBattle()
        g_guiResetters.add(setup_DL.setupPosition)
        g_instance.onKeyDown += self.__onKey
        g_instance.onKeyUp += self.__onKey
        g_eventBus.addListener(GameEvent.SHOW_EXTENDED_INFO, self.__showAlt, scope=EVENT_BUS_SCOPE.BATTLE)
        g_eventBus.addListener(GameEvent.GUI_VISIBILITY, self.__showGUI, scope=EVENT_BUS_SCOPE.BATTLE)

    def _dispose(self):
        g_guiResetters.discard(setup_DL.setupPosition)
        g_instance.onKeyDown -= self.__onKey
        g_instance.onKeyUp -= self.__onKey
        g_eventBus.removeListener(GameEvent.SHOW_EXTENDED_INFO, self.__showAlt, scope=EVENT_BUS_SCOPE.BATTLE)
        g_eventBus.removeListener(GameEvent.GUI_VISIBILITY, self.__showGUI, scope=EVENT_BUS_SCOPE.BATTLE)
        super(damageLogUI, self)._dispose()

    def __onKey(self, event):
        pass

    def __showGUI(self, event):
        pass

    def __showAlt(self, event):
        isDown = event.ctx['isDown']
        self.flashObject.as_setAlt(isDown)

    def logS(self, args):
        print 'logS', args


class damageLogInjector(View):

    def _populate(self):
        super(damageLogInjector, self)._populate()
        g_eventBus.addListener(events.ComponentEvent.COMPONENT_REGISTERED, self.onComponentRegistered, scope=EVENT_BUS_SCOPE.DEFAULT)

    def _dispose(self):
        g_eventBus.removeListener(events.ComponentEvent.COMPONENT_REGISTERED, self.onComponentRegistered, scope=EVENT_BUS_SCOPE.DEFAULT)
        super(damageLogInjector, self)._dispose()

    def onComponentRegistered(self, event):
        if event.alias == BATTLE_VIEW_ALIASES.BATTLE_STATISTIC_DATA_CONTROLLER:
            if self._isDAAPIInited():
                BigWorld.callback(0.0, self.flashObject.as_inject)

    def pyLog(self, args):
        print 'pyLog', args


g_entitiesFactories.addSettings(ViewSettings('damageLogInjector', damageLogInjector, '../../scripts/client/gui/mods/mod_damagelog.swf', ViewTypes.WINDOW, None, ScopeTemplates.GLOBAL_SCOPE))
g_entitiesFactories.addSettings(ViewSettings('damageLogUI', damageLogUI, None, ViewTypes.COMPONENT, None, ScopeTemplates.DEFAULT_SCOPE))

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...