Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- WOT VERSION: 0.9.0
- WOT SERVER : EU/NA/RU
- ----------------------
- WWIIHWA Script v1.1
- ----------------------
- (c) Kriegstreiber 2014
- ----------------------
- """
- import BigWorld
- import ResMgr
- from debug_utils import *
- from gui import SystemMessages
- CFG = {}
- msg_info = ''
- msg_error =''
- def push_system_messages():
- try:
- if len(msg_info) != 0:
- if SystemMessages.g_instance is None:
- BigWorld.callback(4.0, push_system_messages)
- else:
- SystemMessages.pushMessage(msg_info, type=SystemMessages.SM_TYPE.Information)
- if len(msg_error) != 0:
- if SystemMessages.g_instance is None:
- BigWorld.callback(4.0, push_system_messages)
- else:
- SystemMessages.pushMessage(msg_error, type=SystemMessages.SM_TYPE.Error)
- except:
- LOG_CURRENT_EXCEPTION()
- return
- try:
- WWIIHWA = ResMgr.openSection('gui/WWIIHWA.xml')
- if WWIIHWA is not None:
- CFG['autoequip'] = WWIIHWA.readBool('autoequip')
- CFG['battletimer'] = WWIIHWA.readBool('battletimer')
- print '[NOTE] WWIIHWA Ambiente v3.5 succesfully loaded.'
- msg_info = 'Welcome to the WWIIHWA Mod.'
- else:
- CFG['autoequip'] = True
- CFG['battletimer'] = True
- print '[WARNING] WWIIHWA Ambiente v3.5 XMLs not found or invalid !'
- msg_error = 'Something wrong by initializing WWIIHWA. Please check Python log file.'
- except:
- print '[ERROR] XML (".../gui/WWIIHWA.xml") not found or invalid !'
- if CFG['battletimer'] is True:
- try:
- import BattleReplay
- from gui.shared.utils.sound import Sound
- from gui.Scaleform import Battle
- from string import Template
- from Avatar import PlayerAvatar as pa
- pa.snd3min = None
- pa.snd1min = None
- pa.snd30sec = None
- pa.snd5sec = None
- delay = 2
- arenaLength = 0
- try:
- CONFIG = ResMgr.openSection('gui/battletimer.xml')
- if CONFIG is not None:
- CFG['3mins'] = CONFIG.readString('t3mins')
- CFG['1min'] = CONFIG.readString('t1min')
- CFG['30secs'] = CONFIG.readString('t30secs')
- CFG['5secs'] = CONFIG.readString('t5secs')
- else:
- CFG['3mins'] = '/GUI/notifications_FX/battle_timer/EN/3mins'
- CFG['1min'] = '/GUI/notifications_FX/battle_timer/EN/1min'
- CFG['30secs'] = '/GUI/notifications_FX/battle_timer/EN/30secs'
- CFG['5secs'] = '/GUI/notifications_FX/battle_timer/EN/5secs'
- except:
- print '[ERROR]WWIIHWA XML (".../gui/battletimer.xml") not found or invalid !'
- def stopSounds():
- pa.snd3min.stop()
- pa.snd1min.stop()
- pa.snd30sec.stop()
- pa.snd5sec.stop()
- def checktime(arenaLength, period):
- if period != 3:
- stopSounds()
- # initial()
- return
- if arenaLength == 180 and not pa.snd3min.isPlaying:
- pa.snd3min.play()
- elif arenaLength == 60 and not pa.snd1min.isPlaying:
- pa.snd1min.play()
- elif arenaLength == 30 and not pa.snd30sec.isPlaying:
- pa.snd30sec.play()
- elif arenaLength == 5 and not pa.snd5sec.isPlaying:
- pa.snd5sec.play()
- old_setArenaTime = Battle.Battle._Battle__setArenaTime
- def newsetArenaTime(self):
- if hasattr(BigWorld.player(), 'shop') or BigWorld.player().arena is None:
- old_setArenaTime(self)
- return
- else:
- period = BigWorld.player().arena.period
- replayCtrl = BattleReplay.g_replayCtrl
- if replayCtrl.isPlaying:
- arenaLength = int(replayCtrl.getArenaLength())
- else:
- arenaLength = int(BigWorld.player().arena.periodEndTime - BigWorld.serverTime())
- checktime(arenaLength, period)
- old_setArenaTime(self)
- return
- Battle.Battle._Battle__setArenaTime = newsetArenaTime
- def __startBattleL():
- pa.snd3min = Sound(CFG['3mins'])
- pa.snd1min = Sound(CFG['1min'])
- pa.snd30sec = Sound(CFG['30secs'])
- pa.snd5sec = Sound(CFG['5secs'])
- except:
- LOG_CURRENT_EXCEPTION()
- if CFG['autoequip'] is True:
- try:
- from CurrentVehicle import g_currentVehicle
- from gui.Scaleform.daapi.view.lobby.hangar.AmmunitionPanel import AmmunitionPanel
- from gui.shared import g_itemsCache, REQ_CRITERIA
- from gui.shared.utils.requesters import Requester
- from debug_utils import *
- from adisp import process
- g_or_setVehicleModule = None
- g_xmlSetting = None
- g_prevVehicle = None
- def getDeviceInventoryCounts(inventoryDevices, device):
- invCount = 0
- try:
- invCount = inventoryDevices[inventoryDevices.index(device)].count
- except Exception:
- pass
- return invCount
- def equipAllRemovableDevicesOnVehicle(vehicle):
- global g_xmlSetting
- def callback(resultID):
- pass
- if g_xmlSetting[vehicle.name]:
- for slotIdx in range(0, 3):
- device = vehicle.descriptor.optionalDevices[slotIdx]
- if not device:
- deviceCompactDescr = g_xmlSetting[vehicle.name].readInt('slot' + str(slotIdx + 1), 0)
- if deviceCompactDescr is not 0:
- BigWorld.player().inventory.equipOptionalDevice(vehicle.invID, deviceCompactDescr, slotIdx, False, callback)
- @process
- def removeAllRemovableDevicesFromAllVehicle(curVehicle):
- def callback(resultID):
- pass
- deviceAllInventory = yield Requester('optionalDevice').getFromInventory()
- alreadyRemoved = []
- vehicles = g_itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY).values()
- for vehicle in vehicles:
- if curVehicle is not vehicle:
- if not vehicle.isInBattle:
- for slotIdx in range(0, 3):
- device = vehicle.descriptor.optionalDevices[slotIdx]
- if device and device.removable:
- devCount = getDeviceInventoryCounts(deviceAllInventory, device)
- if devCount is 0 and device.compactDescr not in alreadyRemoved:
- BigWorld.player().inventory.equipOptionalDevice(vehicle.invID, 0, slotIdx, False, callback)
- alreadyRemoved.append(device.compactDescr)
- def onCurrentVehicleChanged(prevVehicle, curVehicle):
- removeAllRemovableDevicesFromAllVehicle(curVehicle)
- equipAllRemovableDevicesOnVehicle(curVehicle)
- def vehicleCheckCallback():
- global g_prevVehicle
- if g_currentVehicle.isInHangar:
- curVehicle = g_currentVehicle.item
- if g_prevVehicle is not curVehicle:
- if g_prevVehicle and curVehicle:
- if g_prevVehicle.name is not curVehicle.name:
- onCurrentVehicleChanged(g_prevVehicle, curVehicle)
- g_prevVehicle = curVehicle
- BigWorld.callback(0.1, vehicleCheckCallback)
- def saveDeviceOnVehicle(vehicle, deviceId, slotId, isRemove):
- g_xmlSetting.write(vehicle.name, '')
- if isRemove:
- g_xmlSetting[vehicle.name].writeInt('slot' + str(slotId + 1), 0)
- else:
- g_xmlSetting[vehicle.name].writeInt('slot' + str(slotId + 1), int(deviceId))
- g_xmlSetting.save()
- def hook_setVehicleModule(self, newId, slotIdx, oldId, isRemove):
- global g_or_setVehicleModule
- g_or_setVehicleModule(self, newId, slotIdx, oldId, isRemove)
- vehicle = g_currentVehicle.item
- saveDeviceOnVehicle(vehicle, newId, slotIdx, isRemove)
- def init():
- global g_or_setVehicleModule
- global g_xmlSetting
- g_xmlSetting = ResMgr.openSection('gui/AutoEquip.xml', True)
- if not g_xmlSetting:
- g_xmlSetting.save()
- g_or_setVehicleModule = AmmunitionPanel.setVehicleModule
- AmmunitionPanel.setVehicleModule = hook_setVehicleModule
- vehicleCheckCallback()
- init()
- except:
- LOG_CURRENT_EXCEPTION()
- BigWorld.callback(6.0, push_system_messages)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement