Jump to content
Korean Random
goodman

Динамические макросы в Python

Recommended Posts

winsEfficiency = itemsCache.items.getAccountDossier().getRandomStats().getWinsEfficiency() * 100 
wrn = round(winsEfficiency, 2) + 0.005 

- вероятно опечатка: если 'getWinsEfficiency() * 100', то почему во второй строке '+ 0.005'? (имхо надо писать 0.5)

 

- и если просто округлять wrn то будут ситуации, когда winsEfficiency==wrn из-за особенностей округления 0.5 в питоне. Даже если по факту равенства не будет, то за счет округления до 2 знаков после запятой отображаться могут одинаковые числа...

 

имхо нужно вставлять условие

winsEfficiency = itemsCache.items.getAccountDossier().getRandomStats().getWinsEfficiency() * 100
    f = winsEfficiency - int(winsEfficiency)
    if  f < 0.5:
        wrn = int(winsEfficiency) + 0.5
    else:
        wrn = int(winsEfficiency) + 1
Edited by Kapany3uk

Share this post


Link to post

Short link
Share on other sites
почему во второй строке '+ 0.005'? (имхо надо писать 0.5)

потому что меня интересует увеличение отображаемого процента побед на 0,01. так что тут нет опечатки.

 

а вот с округлением действительно беда была. я проверял округление только до целых чисел. и оно работает как математическое. а сейчас проверил для дробных и оказалось что round(x,2) - это уже банковское округление.

переделал:

...
#    wrn = round(winsEfficiency,2) + 0.005
     wrn = (round(winsEfficiency*100) + 0.5) / 100
...
#    return '( {}{}{:0.2f}% )'.format(int(wn),header,round(wrn,2))
     return '( {}{}{:0.2f}% )'.format(int(wn),header,(round(wrn*100))/100)

теперь всегда правильно.

спасибо.

 

UPD:

немного изменил. теперь так  post-15661-0-14394600-1501994191.jpg

текущий процент побед и кол-во поражений/ничьих (4) и побед (9) до изменения процента на 0,01

    wrn = (round(winsEfficiency*100) + 0.5) / 100
    wn = math.ceil((100 * winsCount - wrn * battlesCount) / (wrn - 100))
    wrp = wrn - 0.01
    bn = math.ceil(winsCount*100 / wrp - battlesCount)
    return '( -{} )  {:0.2f}%  ( +{} )'.format(int(bn),round(winsEfficiency*100)/100,int(wn))

вот теперь точно как я и хотел :)

Edited by CrazyST
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

Hi,

I'm trying to develop some macros in Python, for hangar and carousel, and i have a question. I read all this topic, very interesting indeed, without finding a solution.

I search also in game code source, available on this forum, but this doesn't helped me a lot. 

 

How is it possible to access tank stats and data (xp, frags, damages,..) in Python, like in personal tab?

 

Thanks.

Share this post


Link to post

Short link
Share on other sites

Hi,

I'm trying to develop some macros in Python, for hangar and carousel, and i have a question. I read all this topic, very interesting indeed, without finding a solution.

I search also in game code source, available on this forum, but this doesn't helped me a lot. 

 

How is it possible to access tank stats and data (xp, frags, damages,..) in Python, like in personal tab?

 

Thanks.

Could it help?

Share this post


Link to post

Short link
Share on other sites

Yes, it helped me and i tested it this afertoon, but it's seem that's player stats, not tanks stats.

 

Edit: I would like to retrieve this stats.

 

3bnuue-PROKtS8TO4eh0AQ.png

Edited by Seki

Share this post


Link to post

Short link
Share on other sites

на сколько я понял это данные с сервера XVM, а значит многие из них не актуальны. особенно {{mystat.b}} {{mystat.w}} и т.д. а значит на их основании нельзя посчитать корректное значение "осталось побед до". можно в ангаре как-то получить текущее количество боёв и побед? {{battles}} и {{wins}} в ангаре не работают :(

Сделал из текущего досье

  • Upvote 2

Share this post


Link to post

Short link
Share on other sites

Сделал из текущего досье

а что с динамической окраской, будет?

Share this post


Link to post

Short link
Share on other sites

Yes, it helped me and i tested it this afertoon, but it's seem that's player stats, not tanks stats.   Edit: I would like to retrieve this stats.

 

 

Пример вывода количество боев для всей техники на которой вы играли:

from helpers import dependency
from skeletons.gui.shared import IItemsCache
from gui.Scaleform.daapi.view.lobby.hangar.Hangar import Hangar
from xvm_main.python.logger import *


@registerEvent(Hangar, '_Hangar__updateParams')
def Hangar__updateParams(self):
    itemsCache = dependency.instance(IItemsCache)
    for intCD, dossier in itemsCache.items.getVehicleDossiersIterator():
        log('intCD = %s   BattlesCount %s' % (intCD, itemsCache.items.getVehicleDossier(intCD).getRandomStats().getBattlesCount()))

itemsCache.items.getVehicleDossier(intCD).getBlock() 
                                         .getClanStats() 
                                         .getCompactDescriptor() 
                                         .getCompanyStats() 
                                         .getDossierDescr() 
                                         .getDossierType() 
                                         .getFalloutStats() 
                                         .getFortBattlesStats() 
                                         .getFortSortiesStats() 
                                         .getGlobalMapStats() 
                                         .getGlobalStats() 
                                         .getHistoricalStats() 
                                         .getPlayerDBID() 
                                         .getRandomStats()
                                         .getRankedCurrentSeason() 
                                         .getRankedStats() 
                                         .getRated7x7Stats() 
                                         .getRecordValue() 
                                         .getTeam7x7Stats() 
                                         .getTotalStats()  

   itemsCache.items.getVehicleDossier(intCD).getRandomStats().getAchievement() 
                                                             .getAchievements() 
                                                             .getArmorUsingEfficiency() 
                                                             .getAvgDamage() 
                                                             .getAvgDamageAssistedStun() 
                                                             .getAvgDamageBlocked() 
                                                             .getAvgDamageReceived() 
                                                             .getAvgEnemiesSpotted() 
                                                             .getAvgFrags() 
                                                             .getAvgStunNumber() 
                                                             .getAvgXP() 
                                                             .getBattlesCount() 
                                                             .getBattlesCountBefore8_8() 
                                                             .getBattlesCountBefore9_0() 
                                                             .getBattlesCountVer2() 
                                                             .getBattlesCountVer3() 
                                                             .getBattlesCountWithStun() 
                                                             .getCapturePoints() 
                                                             .getDamageAssistedEfficiency() 
                                                             .getDamageAssistedRadio() 
                                                             .getDamageAssistedStun() 
                                                             .getDamageAssistedTrack() 
                                                             .getDamageBlockedByArmor() 
                                                             .getDamageDealt() 
                                                             .getDamageEfficiency() 
                                                             .getDamageReceived() 
                                                             .getDeathsCount() 
                                                             .getDrawsCount() 
                                                             .getDroppedCapturePoints() 
                                                             .getFrags8p() 
                                                             .getFragsCount() 
                                                             .getFragsEfficiency() 
                                                             .getHeHits() 
                                                             .getHeHitsReceived() 
                                                             .getHitsCount() 
                                                             .getHitsEfficiency() 
                                                             .getLossesCount() 
                                                             .getLossesEfficiency() 
                                                             .getMaxDamage() 
                                                             .getMaxFrags() 
                                                             .getMaxXp() 
                                                             .getNearestAchievements() 
                                                             .getNoDamageShotsReceived() 
                                                             .getOriginalXP() 
                                                             .getPierced() 
                                                             .getPiercedReceived() 
                                                             .getPotentialDamageReceived() 
                                                             .getRecord() 
                                                             .getShotsCount() 
                                                             .getShotsReceived() 
                                                             .getSignificantAchievements() 
                                                             .getSpottedEnemiesCount() 
                                                             .getStunNumber() 
                                                             .getSurvivalEfficiency() 
                                                             .getSurvivedBattlesCount() 
                                                             .getTopAchievements() 
                                                             .getWinAndSurvived() 
                                                             .getWinsCount() 
                                                             .getWinsEfficiency() 
                                                             .getXP() 
                                                             .getXpBefore8_8() 

Edited by ktulho

Share this post


Link to post

Short link
Share on other sites

Пример вывода количество боев для всей техники на которой вы играли:

from helpers import dependency
from skeletons.gui.shared import IItemsCache
from gui.Scaleform.daapi.view.lobby.hangar.Hangar import Hangar
from xvm_main.python.logger import *


@registerEvent(Hangar, '_Hangar__updateParams')
def Hangar__updateParams(self):
    itemsCache = dependency.instance(IItemsCache)
    for intCD, dossier in itemsCache.items.getVehicleDossiersIterator():
        log('intCD = %s   BattlesCount %s' % (intCD, itemsCache.items.getVehicleDossier(intCD).getRandomStats().getBattlesCount()))

itemsCache.items.getVehicleDossier(intCD).getBlock() 
                                         .getClanStats() 
                                         .getCompactDescriptor() 
                                         .getCompanyStats() 
                                         .getDossierDescr() 
                                         .getDossierType() 
                                         .getFalloutStats() 
                                         .getFortBattlesStats() 
                                         .getFortSortiesStats() 
                                         .getGlobalMapStats() 
                                         .getGlobalStats() 
                                         .getHistoricalStats() 
                                         .getPlayerDBID() 
                                         .getRandomStats()
                                         .getRankedCurrentSeason() 
                                         .getRankedStats() 
                                         .getRated7x7Stats() 
                                         .getRecordValue() 
                                         .getTeam7x7Stats() 
                                         .getTotalStats()  

   itemsCache.items.getVehicleDossier(intCD).getRandomStats().getAchievement() 
                                                             .getAchievements() 
                                                             .getArmorUsingEfficiency() 
                                                             .getAvgDamage() 
                                                             .getAvgDamageAssistedStun() 
                                                             .getAvgDamageBlocked() 
                                                             .getAvgDamageReceived() 
                                                             .getAvgEnemiesSpotted() 
                                                             .getAvgFrags() 
                                                             .getAvgStunNumber() 
                                                             .getAvgXP() 
                                                             .getBattlesCount() 
                                                             .getBattlesCountBefore8_8() 
                                                             .getBattlesCountBefore9_0() 
                                                             .getBattlesCountVer2() 
                                                             .getBattlesCountVer3() 
                                                             .getBattlesCountWithStun() 
                                                             .getCapturePoints() 
                                                             .getDamageAssistedEfficiency() 
                                                             .getDamageAssistedRadio() 
                                                             .getDamageAssistedStun() 
                                                             .getDamageAssistedTrack() 
                                                             .getDamageBlockedByArmor() 
                                                             .getDamageDealt() 
                                                             .getDamageEfficiency() 
                                                             .getDamageReceived() 
                                                             .getDeathsCount() 
                                                             .getDrawsCount() 
                                                             .getDroppedCapturePoints() 
                                                             .getFrags8p() 
                                                             .getFragsCount() 
                                                             .getFragsEfficiency() 
                                                             .getHeHits() 
                                                             .getHeHitsReceived() 
                                                             .getHitsCount() 
                                                             .getHitsEfficiency() 
                                                             .getLossesCount() 
                                                             .getLossesEfficiency() 
                                                             .getMaxDamage() 
                                                             .getMaxFrags() 
                                                             .getMaxXp() 
                                                             .getNearestAchievements() 
                                                             .getNoDamageShotsReceived() 
                                                             .getOriginalXP() 
                                                             .getPierced() 
                                                             .getPiercedReceived() 
                                                             .getPotentialDamageReceived() 
                                                             .getRecord() 
                                                             .getShotsCount() 
                                                             .getShotsReceived() 
                                                             .getSignificantAchievements() 
                                                             .getSpottedEnemiesCount() 
                                                             .getStunNumber() 
                                                             .getSurvivalEfficiency() 
                                                             .getSurvivedBattlesCount() 
                                                             .getTopAchievements() 
                                                             .getWinAndSurvived() 
                                                             .getWinsCount() 
                                                             .getWinsEfficiency() 
                                                             .getXP() 
                                                             .getXpBefore8_8() 

 

 

Thanks, that's what i need! :ok:

Now, will trying to get stats by tank name or Id.

Share this post


Link to post

Short link
Share on other sites

I found how to get name or ID for tanks in the carousel, with this code:

import BigWorld
from Avatar import PlayerAvatar
from helpers import dependency
from skeletons.gui.shared import IItemsCache
from gui.Scaleform.daapi.view.lobby.hangar.Hangar import Hangar
from xvm_main.python.logger import *
from debug_utils import LOG_ERROR
from gui.Scaleform.daapi.view.lobby.vehicle_carousel.carousel_data_provider import CarouselDataProvider
from gui.shared.utils.requesters import REQ_CRITERIA

@registerEvent(Hangar, '_Hangar__updateParams')
def Hangar__updateParams(self):
    itemsCache = dependency.instance(IItemsCache)
    inventory_vehicles_dict = dict(itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY))
    for vehicle in inventory_vehicles_dict.values():
        LOG_ERROR('vehicle name: %s' % vehicle.name)
        LOG_ERROR('vehicle intCD: %s' % vehicle.intCD)

Now, how can i get a list of properties for vehicle (like vehicle.name, vehicle.intCD,...)?

I tried to use night_dragon_on method https://koreanrandom.com/forum/topic/31856-динамические-макросы-в-python/?p=398696

 but this doesn't work.

 

Edit: found this.

 

actionPrc
altPrice
ammoMaxSize
battleBooster
battleBoosterLayout
bonuses
buyPrice
canNotBeSold
canSell
canTradeIn
canTradeOff
chassis
clanLock
clearCustomState
crew
crewIndices
dailyXPFactor
defaultAltPrice
defaultPrice
defaultSellPrice
descriptor
engine
eqs
eqsLayout
eventsCache
falloutCtrl
fuelTank
fullDescription
fullyConfigured
getAutoUnlockedItems
getAutoUnlockedItemsMap
getBonusIcon
getBuyPrice
getBuyPriceCurrency
getConflictedEquipments
getCrewBySkillLevels
getCrewWithoutSkill
getCustomState
getCustomizedDescriptor
getGUIEmblemID
getInstalledVehicles
getParams
getPerfectCrew
getRentPackage
getRentPackageActionPrc
getSellPriceCurrency
getShortInfo
getState
getTarget
getUnlockDescrByIntCD
getUnlocksDescr
getUnlocksDescrs
gun
hasBattleTurrets
hasCrew
hasEquipments
hasLimitedRestore
hasLockMode
hasModulesToSelect
hasOptionalDevices
hasRentPackages
hasRestoreCooldown
hasShells
hasTurrets
health
icon
iconContour
iconSmall
iconUnique
iconUniqueLight
igrCtrl
igrCustomizationsLayout
innationID
intCD
intCompactDescr
invID
inventoryCount
inventoryID
isAlive
isAmmoFull
isAutoBattleBoosterEquip
isAutoEquip
isAutoEquipFull
isAutoLoad
isAutoLoadFull
isAutoRepair
isAwaitingBattle
isBoughtForCredits
isBroken
isCrewFull
isCrewLocked
isCustomStateSet
isDisabledForBuy
isDisabledInPremIGR
isDisabledInRoaming
isElite
isEvent
isExcludedFromSandbox
isFalloutAvailable
isFalloutOnly
isFalloutSelected
isFavorite
isFullyElite
isGroupReady
isHidden
isInBattle
isInInventory
isInPrebattle
isInUnit
isInfiniteRotationGroup
isInitiallyUnlocked
isInstalled
isLocked
isObserver
isOnlyForEventBattles
isPremium
isPremiumIGR
isPreviewAllowed
isPurchased
isReadyToFight
isReadyToPrebattle
isRecentlyRestored
isRemovable
isRentAvailable
isRentable
isRented
isRestoreAvailable
isRestorePossible
isRotationApplied
isRotationGroupLocked
isSecret
isSelected
isSpecial
isTelecom
isTelecomDealOver
isUnique
isUnlocked
isUnrecoverable
isXPToTman
itemTypeID
itemTypeName
itemsFactory
lastCrew
level
lobbyContext
lock
longUserName
maxRentDuration
mayInstall
mayObtainForMoney
mayObtainWithMoneyExchange
mayPurchase
mayPurchaseWithExchange
mayRemove
mayRent
mayRestore
mayRestoreWithExchange
minRentDuration
minRentPrice
modelState
name
nationID
nationName
optDevices
radio
rentCompensation
rentExpiryState
rentExpiryTime
rentInfo
rentLeftBattles
rentLeftTime
rentPackages
rentalIsActive
rentalIsOver
repairCost
restoreInfo
restorePrice
rotationBattlesLeft
rotationGroupIdx
rotationGroupNum
searchableUserName
sellActionPrc
sellForGold
sellPrice
setCustomState
settings
shells
shellsLayoutIdx
shortDescription
shortUserName
strCD
strCompactDescr
tags
tradeOffPrice
tradeOffPriceFactor
turret
type
typeOfLockingArena
typeUserName
userName
userType
xp
Edited by Seki

Share this post


Link to post

Short link
Share on other sites

Всем привет.

Подскажите, может кто знает: для получения "Основного калибра" нельзя задевать союзников прямыми выстрелами. Труп союзника тоже нельзя задевать?


На данный момент при попадание в труп союзника mainGun в голубой цвет окрашивается.

Share this post


Link to post

Short link
Share on other sites

 

 

Подскажите, может кто знает: для получения "Основного калибра" нельзя задевать союзников прямыми выстрелами. Труп союзника тоже нельзя задевать? На данный момент при попадание в труп союзника mainGun в голубой цвет окрашивается.
, запулил исправление. 
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites
В 13.08.2017 в 17:25, Okxa сказал:
Is there a way to make this per config, like use one config for videos and other for gameplay
В 13.08.2017 в 15:36, Okxa сказал:

What are the current ID:s for these:

1. The messages when module or crew takes damage, located over ammo and consumables.

Old keys: vehicleErrorsPanel and vehicleMessagesPanel

2. Kill log, (frag log, kill feed?) -used to be: playerMessangersPanel

 

I need to know them to set them invisible for videos.

 

Script: setttingsForReplay.zip

 

To run the script, you need to add the configuration to your config file "battle.xc":

"battle": {
  "setttingsForReplay": true,

Disabled:

  • vehicleErrorsPanel
  • vehicleMessagesPanel
  • playerMessangersPanel
Edited by night_dragon_on

Share this post


Link to post

Short link
Share on other sites

ребят, чего-то я совсем туплю... есть {{mystat.ts}}. он возвращает timestamp. а как из него получить нормальные дату и время?

Share this post


Link to post

Short link
Share on other sites

ребят, чего-то я совсем туплю... есть {{mystat.ts}}. он возвращает timestamp. а как из него получить нормальные дату и время?

 

вот тема с датой

Share this post


Link to post

Short link
Share on other sites

I wrote this code for testing some stuff:

#! /usr/bin/env Python
# -*- coding: utf-8 -*-

#############################
# Addons for XVM carousel by Ikes
#############################

#############################
# Imports

# Imports - WoT
import BigWorld
from helpers import dependency
from skeletons.gui.shared import IItemsCache
from gui.Scaleform.daapi.view.lobby.hangar.Hangar import Hangar
from gui.shared.utils.requesters import REQ_CRITERIA

# Imports - XVM
from xfw import *
from xvm_main.python.logger import *

# Imports - Other
import simplejson
import traceback

#############################
# Private

class VehiclesList:

        def __init__(self):
                self.playerName = self.__getPlayerName()
		log('[TEST] {}'.format(self.playerName)
		    
	def __getPlayerName(self):
		return BigWorld.player().name
		





###
def __player_vehicles_list():
        itemsCache = dependency.instance(IItemsCache)
	vehiclesList = dict(itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY))
	log('[ADDONS] Vehicles list: {}'.format(vehiclesList.values()))
	return

#############################
# Events

#
@registerEvent(Hangar, '_Hangar__updateParams')
def Hangar__updateParams(self):
        __player_vehicles_list()
        log('[ADDONS] Hangar updated' )

vehiclesList2 = VehiclesList()

But i have an error in xvm log, and i don't understand why. When i wrote class VehiclesList under Python shell, i have no error and code work fine. Why?

2017-08-18 23:55:34: [ERROR] Traceback (most recent call last):
  File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 127, in load_macros_lib
    code = load(file_name)
  File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 101, in load
    return parse(source, file_name)
  File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 91, in parse
    node = ast.parse(source)
  File "scripts/common/Lib/ast.py", line 37, in parse
  File "<unknown>", line 35
    def __getPlayerName(self):
      ^
SyntaxError: invalid syntax
Edited by Seki

Share this post


Link to post

Short link
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...