ktulho 5,791 #334313 Posted June 24, 2016 народ, помогите с одной хренью, как узнать что игрок стрельнул голдовым снарядом , а что известно об этом снаряде? Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #334316 Posted June 24, 2016 (edited) , а что известно об этом снаряде? from items import _xml as shell_xml from constants import ITEM_DEFS_PATH import nations from ResMgr import purge from ResMgr import openSection from Avatar import PlayerAvatar def shell_price(nationID, shellID): price = {} xmlPath = ITEM_DEFS_PATH + 'vehicles/' + nations.NAMES[nationID] + '/components/shells.xml' for name, subsection in openSection(xmlPath).items(): if name != 'icons': xmlCtx = (None, xmlPath + '/' + name) if shell_xml.readInt(xmlCtx, subsection, 'id', 0, 65535) == shellID: price = shell_xml.readPrice(xmlCtx, subsection, 'price') break purge(xmlPath, True) return price def show_damage_shot_tracer(self, attackerID, effectsIndex): attacker = self.arena.vehicles.get(attackerID) current = self.arena.vehicles.get(self.playerVehicleID) if attacker is not None: player_name = attacker['name'] player_vehicle = attacker['vehicleType'].type.shortUserString player_clan = '[' + attacker['clanAbbrev'] + ']' if '[' + attacker['clanAbbrev'] + ']' != '[]' else '' for shell in attacker['vehicleType'].gun['shots']: if effectsIndex == shell['shell']['effectsIndex']: if not attackerID == self.playerVehicleID: price = shell_price(shell['shell']['id'][0], shell['shell']['id'][1]) if price[1] != 0: print '{name} стрельнул голдой'.format(name=player_name) PlayerAvatar.show_damage_shot_tracer = show_damage_shot_tracer def new_showTracer(self, shooterID, shotID, isRicochet, effectsIndex, refStartPoint, velocity, gravity, maxShotDist): old_showTracer(self, shooterID, shotID, isRicochet, effectsIndex, refStartPoint, velocity, gravity, maxShotDist) self.show_damage_shot_tracer(shooterID, effectsIndex) old_showTracer = PlayerAvatar.showTracer PlayerAvatar.showTracer = new_showTracer любой снаряд арты считает за голдовый, что за хрень Edited June 24, 2016 by Ekspoint Quote Share this post Link to post Short link Share on other sites
ktulho 5,791 #334319 Posted June 24, 2016 @Ekspoint, а выведи в лог вот это: price = shell_price(shell['shell']['id'][0], shell['shell']['id'][1]) Предположу, что вот это: if effectsIndex == shell['shell']['effectsIndex']: и для голдового, и для не голдового фугаса равно True. Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #334322 Posted June 24, 2016 @ktulho, не, не в этом дело Quote Share this post Link to post Short link Share on other sites
ktulho 5,791 #334324 Posted June 24, 2016 ktulho, не, не в этом дело , уверен?Вот снаряды FV207: ('shots', ({'shell': {'itemTypeName': 'shell', 'caliber': 152.39999389648438, 'piercingPowerRandomization': 0.25, 'isTracer': True, 'effectsIndex': 19, 'compactDescr': 24666, 'userString': 'HE Mk. V', 'id': (5, 96), 'description': '', 'damageRandomization': 0.25, 'kind': 'HIGH_EXPLOSIVE', 'name': '_6inch_HE', 'damage': (1250.0, 203.0), 'explosionRadius': 3.6700000762939453, 'icon': ('HIGH_EXPLOSIVE.png', 0, 0)}, 'speed': 384.0000057220459, 'piercingPower': (90, 90), 'defaultPortion': 1.0, 'gravity': 104.96000312805178, 'maxDistance': 10000.0}, {'shell': {'itemTypeName': 'shell', 'caliber': 152.39999389648438, 'piercingPowerRandomization': 0.25, 'isTracer': True, 'effectsIndex': 18, 'compactDescr': 24922, 'userString': 'AP Mk. V', 'id': (5, 97), 'description': '', 'damageRandomization': 0.25, 'kind': 'ARMOR_PIERCING', 'name': '_6inch_AP', 'damage': (750.0, 203.0), 'icon': ('ARMOR_PIERCING.png', 0, 0)}, 'speed': 384.0000057220459, 'piercingPower': (258, 248), 'defaultPortion': 0.0, 'gravity': 104.96000312805178, 'maxDistance': 10000.0}, {'shell': {'itemTypeName': 'shell', 'caliber': 152.39999389648438, 'piercingPowerRandomization': 0.25, 'isTracer': True, 'effectsIndex': 19, 'compactDescr': 25946, 'userString': 'HE Mk. VI', 'id': (5, 101), 'description': '', 'damageRandomization': 0.25, 'kind': 'HIGH_EXPLOSIVE', 'name': '_6inch_HE_Mk_6', 'damage': (1250.0, 203.0), 'explosionRadius': 5.260000228881836, 'icon': ('HIGH_EXPLOSIVE_PREMIUM.png', 0, 0)}, 'speed': 384.0000057220459, 'piercingPower': (90, 90), 'defaultPortion': 0.0, 'gravity': 104.96000312805178, 'maxDistance': 10000.0})), 'effectsIndex' у двух из них совпадает. Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #334325 Posted June 24, 2016 , уверен? Вот снаряды FV207: ('shots', ({'shell': {'itemTypeName': 'shell', 'caliber': 152.39999389648438, 'piercingPowerRandomization': 0.25, 'isTracer': True, 'effectsIndex': 19, 'compactDescr': 24666, 'userString': 'HE Mk. V', 'id': (5, 96), 'description': '', 'damageRandomization': 0.25, 'kind': 'HIGH_EXPLOSIVE', 'name': '_6inch_HE', 'damage': (1250.0, 203.0), 'explosionRadius': 3.6700000762939453, 'icon': ('HIGH_EXPLOSIVE.png', 0, 0)}, 'speed': 384.0000057220459, 'piercingPower': (90, 90), 'defaultPortion': 1.0, 'gravity': 104.96000312805178, 'maxDistance': 10000.0}, {'shell': {'itemTypeName': 'shell', 'caliber': 152.39999389648438, 'piercingPowerRandomization': 0.25, 'isTracer': True, 'effectsIndex': 18, 'compactDescr': 24922, 'userString': 'AP Mk. V', 'id': (5, 97), 'description': '', 'damageRandomization': 0.25, 'kind': 'ARMOR_PIERCING', 'name': '_6inch_AP', 'damage': (750.0, 203.0), 'icon': ('ARMOR_PIERCING.png', 0, 0)}, 'speed': 384.0000057220459, 'piercingPower': (258, 248), 'defaultPortion': 0.0, 'gravity': 104.96000312805178, 'maxDistance': 10000.0}, {'shell': {'itemTypeName': 'shell', 'caliber': 152.39999389648438, 'piercingPowerRandomization': 0.25, 'isTracer': True, 'effectsIndex': 19, 'compactDescr': 25946, 'userString': 'HE Mk. VI', 'id': (5, 101), 'description': '', 'damageRandomization': 0.25, 'kind': 'HIGH_EXPLOSIVE', 'name': '_6inch_HE_Mk_6', 'damage': (1250.0, 203.0), 'explosionRadius': 5.260000228881836, 'icon': ('HIGH_EXPLOSIVE_PREMIUM.png', 0, 0)}, 'speed': 384.0000057220459, 'piercingPower': (90, 90), 'defaultPortion': 0.0, 'gravity': 104.96000312805178, 'maxDistance': 10000.0})), 'effectsIndex' у двух из них совпадает. причем тут effectsIndex когда речь о shell_price если у меня effectsIndex равен shell['shell']['effectsIndex'] то уже дальше идет проверка на цену снаряда Quote Share this post Link to post Short link Share on other sites
ktulho 5,791 #334326 Posted June 24, 2016 @Ekspoint, так ты не тот shell['shell'] определяешь. Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #334327 Posted June 24, 2016 @Ekspoint, так ты не тот shell['shell'] определяешь. а где надо Quote Share this post Link to post Short link Share on other sites
ktulho 5,791 #334328 Posted June 24, 2016 (edited) if price[1] != 0: print '{name} стрельнул голдой'.format(name=player_name) else: print '{name} стрельнул не голдой'.format(name=player_name) Добавь эти две строчки, и увидишь, что после попадания в логе будет появляться две строчки. а где надо , я не говорил, что не там, я говорил, что не тот. Точнее они оба подходят под: if effectsIndex == shell['shell']['effectsIndex']: Edited June 24, 2016 by ktulho Quote Share this post Link to post Short link Share on other sites
Slava7572 1,685 #334621 Posted June 27, 2016 Добавил с помощью neLeax в эту панельку танчик вместо перевернутой V и расчет разницы по ХП между команд цифрой(при отрицательных значениях перед цифрой стоит минус) с цветовой дифференциацией.Ну чтоб в уме не высчитывать в бою)) В архиве файлики,скриптик,скрины и коротенькое ридми.Забираем,кому надо. neLeax_TeamHP_tank_dif.rar Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #334650 Posted June 27, 2016 Добавил с помощью neLeax в эту панельку танчик вместо перевернутой V и расчет разницы по ХП между команд цифрой(при отрицательных значениях перед цифрой стоит минус) с цветовой дифференциацией.Ну чтоб в уме не высчитывать в бою)) В архиве файлики,скриптик,скрины и коротенькое ридми. Забираем,кому надо. возьми из того поста в котором я переписал код чуток http://www.koreanrandom.com/forum/topic/31856-динамические-макросы-в-python/?p=334081 Quote Share this post Link to post Short link Share on other sites
Slava7572 1,685 #334666 Posted June 27, 2016 (edited) возьми из того поста в котором я переписал код чуток http://www.koreanrandom.com/forum/topic/31856-динамические-макросы-в-python/?p=334081 Окей,но надо у себя погонять,добавить изменения(танчик,разницу в цифре). П.С:Андрей,чет не хочет,там точно ошибок нет,заметил что в родном import BigWorld закомичен,а в твоем рабочий,в остальном я не особо разбираюсь))) А может повлияло то,что я добавил(вся последняя секция и в superiority еще один индикатор(танчик с дулом в другую сторону))?Вот весь код: from xvm_battle.python import fragCorrelationPanel as panel import BigWorld from Avatar import PlayerAvatar from Vehicle import Vehicle from gui.Scaleform.Battle import Battle from xfw import * class Battle_Info(object): def __init__(self): self.damage = 0 self.section = 20 self.enemy_hp = {} self.max_hp = [0, 0] self.textBar = ["c", "b"] self.actual_arenaUniqueID = None battle_info = Battle_Info() @registerEvent(Battle, 'beforeDelete') def beforeDelete(self): battle_info.damage = 0 battle_info.enemy_hp.clear() battle_info.max_hp = [0, 0] battle_info.actual_arenaUniqueID = None def IsLive(vehicleID): player = BigWorld.player() vehicles = player.arena.vehicles return vehicles[vehicleID]['isAlive'] if player is not None else None def IsFriendly(vehicleID): player = BigWorld.player() vehicles = player.arena.vehicles return vehicles[player.playerVehicleID]['team'] == vehicles[vehicleID]['team'] if player is not None else None def getVehicleHealth(): for vehicleID in BigWorld.entities.values(): if type(vehicleID) is Vehicle: if IsLive(vehicleID.id) and not IsFriendly(vehicleID.id): battle_info.enemy_hp[vehicleID.id] = vehicleID.health def New_onEnterWorld(self, vehicle): Old_onEnterWorld(self, vehicle) getVehicleHealth() Old_onEnterWorld = PlayerAvatar.vehicle_onEnterWorld PlayerAvatar.vehicle_onEnterWorld = New_onEnterWorld @registerEvent(Vehicle, 'onHealthChanged') def onHealthChanged(self, newHealth, attackerID, attackReasonID): if self.id in battle_info.enemy_hp.keys(): if attackerID == BigWorld.player().playerVehicleID: battle_info.damage += battle_info.enemy_hp[self.id] - newHealth battle_info.enemy_hp[self.id] = newHealth getVehicleHealth() return battle_info.damage @xvm.export('nelx.total_hp', deterministic=False) def total_hp(team): arenaUniqueID = BigWorld.player().arenaUniqueID if battle_info.actual_arenaUniqueID != arenaUniqueID: battle_info.actual_arenaUniqueID = arenaUniqueID battle_info.max_hp[0] = panel.teams_totalhp[0] battle_info.max_hp[1] = panel.teams_totalhp[1] return panel.teams_totalhp[team] @xvm.export('nelx.total_hp.color', deterministic=False) def color(): return panel.total_hp_color @xvm.export('nelx.total_hp.sign', deterministic=False) def sign(): return '<' if panel.total_hp_sign == '<' else '>' if panel.total_hp_sign == '>' else panel.total_hp_sign @xvm.export('nelx.total_hp.healthBar', deterministic=False) def healthBar(team): bar = int(round( (panel.teams_totalhp[team] * battle_info.section) / float(max(battle_info.max_hp)) )) return '<font face="xvm"><b>' + battle_info.textBar[team] * bar + '</b></font>' @xvm.export('nelx.total_hp.healthBar_background', deterministic=True) def healthBar_background(team): return '<font face="xvm"><b>' + battle_info.textBar[team] * battle_info.section + '</b></font>' @xvm.export('nelx.total_hp.superiority', deterministic=False) def superiority(): al = panel.teams_totalhp[0] en = panel.teams_totalhp[1] max_hp_now = float( max(panel.teams_totalhp) ) superiority = int(round( abs((al - en) / max_hp_now) * 500. , 2 )) fill = '<font size="4" alpha="#00">' + (' ' * superiority ) + '</font>' indicator = "*" if en > al: indicator = "'" indicator, fill = fill, indicator return indicator + fill @xvm.export('nelx.total_hp.superiority_text', deterministic=False) def superiority_text(): al = panel.teams_totalhp[0] en = panel.teams_totalhp[1] max_hp_now = float( max(panel.teams_totalhp) ) result = round( ((al - en) / max_hp_now) * 100. , 2) return "<font color='#%s'>%s%</font>" % (color(), result) @xvm.export('nelx.mainGun', deterministic=False) def mainGun(): battletype = BigWorld.player().arena.guiType if battletype != 1: return else: result = int(max(round(battle_info.max_hp[1] * 0.2), 1000)) - battle_info.damage if result <= 0: result = "<font face='xvm' color='#96FF00' size='21'>x</font>" return "<img src='img://gui/maps/icons/achievement/32x32/mainGun.png' width='32' height='32' align='middle' vspace='-9'>%s" % (result) @xvm.export('nelx.damagePercent', deterministic=False) def damagePercent(): if battle_info.damage == 0: result = 0 else: result = round (100. / battle_info.max_hp[1] * battle_info.damage , 1) return "%s% <img src='img://gui/maps/icons/vehParams/damageAvgPerMinute.png' width='24' height='24' align='middle' vspace='-4'>" % (result) @xvm.export('total_hp.sub', deterministic=False) def total_hp_sub(): result = panel.teams_totalhp[0] - panel.teams_totalhp[1] return "<img src='img://gui/maps/icons/achievement/32x32/winnerLaurels1.png' width='32' height='32' align='middle' vspace='-9'><font color='#%s'>%s</font>" % (color(), result) Глянул в логе ХВМ,похоже проблема в новом индикаторе: 2016-06-27 22:31:05: [ERROR] Traceback (most recent call last):File "xvm_main/python_macro.py", line 127, in load_macros_lib File "xvm_main/python_macro.py", line 101, in load File "xvm_main/python_macro.py", line 91, in parse File "scripts/common/Lib/ast.py", line 37, in parse File "", line 106 indicator, fill = fill, indicator ^ IndentationError: unindent does not match any outer indentation level Посмотри код,что там не так?Вроде эта часть вообще идентична родной. Да,и еще в логе было много раз это: 2016-06-27 22:31:26: [ERROR] Traceback (most recent call last):File "xvm_main/python_macro.py", line 154, in process_python_macro File "xvm_main/python_macro.py", line 145, in get_function TypeError: 'NoneType' object is not iterable arg='nelx.total_hp(0)' 2016-06-27 22:31:26: [ERROR] Traceback (most recent call last): File "xvm_main/python_macro.py", line 154, in process_python_macro File "xvm_main/python_macro.py", line 145, in get_function TypeError: 'NoneType' object is not iterable arg='nelx.total_hp(1)' Edited June 27, 2016 by Slava7572 Quote Share this post Link to post Short link Share on other sites
Сербия 12 #335344 Posted July 3, 2016 @neLeax, можно ли реализовать средний урон на танк в ваш код? http://www.koreanrandom.com/forum/topic/31856-%D0%B4%D0%B8%D0%BD%D0%B0%D0%BC%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B5-%D0%BC%D0%B0%D0%BA%D1%80%D0%BE%D1%81%D1%8B-%D0%B2-python/page-9#entry331548 Quote Share this post Link to post Short link Share on other sites
night_dragon_on 5,601 #336306 Posted July 9, 2016 (edited) Макросы макросами, а так и никто не проверил их работу в ангарном интерфейсе (в карусели). + Исправлено в новых билдах. Edited September 5, 2016 by night_dragon_on 1 Quote Share this post Link to post Short link Share on other sites
Kapany3uk 948 #336316 Posted July 9, 2016 (edited) никто не проверил их работу в ангарном интерфейсе ну почему же :)) Например, вывод своего сообщения в системный канал вполне работает в ру-макросах (код идентичен обычному из мода, даже не надо декоратора) # Всплывающее сообщение в ангаре import BigWorld from gui import SystemMessages class Message(object): def __init__(self): msg = '<img src="img://../mods/shared_resources/xvm/res/icons/xvm/16x16t.png" vspace="-3"> config edited by <font color="#D7D7A7">Kapany3uk</font>' SystemMessages.pushMessage(msg, SystemMessages.SM_TYPE.Information) g_message = Message() Предположу, что и вывод pop-up, а возможно, и tooltips, также не "за горами". Пару часов "покорпел" над работоспособностью вызова браузера из под ру-макросов: пока никак... Отдельным модом ок, а в хвм не хочет :(( Edited July 9, 2016 by Kapany3uk Quote Share this post Link to post Short link Share on other sites
0kosmo 15 #336806 Posted July 14, 2016 Пара вопросов. 1. В http://www.koreanrandom.com/forum/topic/31856-%D0%B4%D0%B8%D0%BD%D0%B0%D0%BC%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B5-%D0%BC%D0%B0%D0%BA%D1%80%D0%BE%D1%81%D1%8B-%D0%B2-python/page-10?do=findComment&comment=331673 не нравится регулярный вызов arenaUniqueID = BigWorld.player().arenaUniqueID Это случайно не перестраховка при наличии @registerEvent(Battle, 'beforeDelete') def beforeDelete(self): battle_info.actual_arenaUniqueID = None 2. Вижу два варианта реализации вывода данных. Либо формировать всю выводимую строку в динамическом макросе либо по приципу конструктора - рассчитывать в динамическом макросе отдельные параметры, а затем в battleLabelsTemplates.xc стыковать их в нужном порядке. Типа // Урон до получения медали "Основной Калибр". "mainGun": { ... "format": "<font face='$TitleFont'>{{py:my.mainGun()}} ({{py:my.percent()}}%)</font>" } Будет ли существенным в первом случае выигрыш в производительности? Если нет - то делаем динамический макрос в котором рассчитываем кучу параметров, а затем желающие берут то что необходимо и выводят в виде который им нравится. Quote Share this post Link to post Short link Share on other sites
ktulho 5,791 #336828 Posted July 14, 2016 @0kosmo, по 2 вопросу, ИМХО, лучше в питоне формировать всю строку. Quote Share this post Link to post Short link Share on other sites
Slava7572 1,685 #336900 Posted July 15, 2016 Интересно,есть ли возможность того,чтоб ХП команд показывал всегда правильно?У обычных танков показывает в пределах дальности,а у арты тоже такая система?У нее же вся карта в отрисовке. Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #336902 Posted July 15, 2016 (edited) Интересно,есть ли возможность того,чтоб ХП команд показывал всегда правильно?У обычных танков показывает в пределах дальности,а у арты тоже такая система?У нее же вся карта в отрисовке. нет, дольше твоей видимости картошка не передает инфу, а для арты это только в арт режиме, вроде Edited July 15, 2016 by Ekspoint Quote Share this post Link to post Short link Share on other sites
Slava7572 1,685 #336903 Posted July 15, 2016 нет, дольше твоей видимости картошка не передает инфу, а для арты это только в арт режиме, вроде Печалька. Quote Share this post Link to post Short link Share on other sites