Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.30 KB | None | 0 0
  1. import BigWorld
  2. import random
  3. from Event import Event
  4. from items import vehicles
  5. from helpers import isPlayerAccount
  6. from adisp import async, process
  7. from account_helpers.AccountSettings import AccountSettings, CURRENT_VEHICLE
  8. from gui.ClientUpdateManager import g_clientUpdateManager
  9. from gui import prb_control, game_control, g_tankActiveCamouflage, SystemMessages
  10. from gui.shared import g_itemsCache, REQ_CRITERIA, g_eventsCache
  11. from gui.shared.utils.HangarSpace import g_hangarSpace
  12. from gui.shared.gui_items import GUI_ITEM_TYPE
  13. from gui.shared.gui_items.Vehicle import Vehicle
  14. from gui.Scaleform.locale.MENU import MENU
  15. from gui.Scaleform.Waiting import Waiting
  16. import io, os, json, codecs, math, ResMgr
  17. from items import tankmen
  18. from debug_utils import *
  19.  
  20. class _CurrentVehicle():
  21.  
  22. def __init__(self):
  23. self.__vehInvID = 0
  24. self.__changeCallbackID = None
  25. self.__historicalBattle = None
  26. self.onChanged = Event()
  27. self.onChangeStarted = Event()
  28. self.__crew = {}
  29.  
  30. def init(self):
  31. g_clientUpdateManager.addCallbacks({'inventory': self.onInventoryUpdate,
  32. 'cache.vehsLock': self.onLocksUpdate})
  33. game_control.g_instance.igr.onIgrTypeChanged += self.onIgrTypeChanged
  34. prbVehicle = self.__checkPrebattleLockedVehicle()
  35. storedVehInvID = AccountSettings.getFavorites(CURRENT_VEHICLE)
  36. self.selectVehicle(prbVehicle or storedVehInvID)
  37.  
  38. def destroy(self):
  39. self.__vehInvID = 0
  40. self.__clearChangeCallback()
  41. self.onChanged.clear()
  42. self.onChangeStarted.clear()
  43. g_clientUpdateManager.removeObjectCallbacks(self)
  44. game_control.g_instance.igr.onIgrTypeChanged -= self.onIgrTypeChanged
  45. g_hangarSpace.removeVehicle()
  46. self.selectNoVehicle()
  47.  
  48. def onIgrTypeChanged(self, *args):
  49. self.refreshModel()
  50.  
  51. def onInventoryUpdate(self, invDiff):
  52. vehsDiff = invDiff.get(GUI_ITEM_TYPE.VEHICLE, {})
  53. isVehicleSold = False
  54. isVehicleDescrChanged = False
  55. if 'compDescr' in vehsDiff and self.__vehInvID in vehsDiff['compDescr']:
  56. isVehicleSold = vehsDiff['compDescr'][self.__vehInvID] is None
  57. isVehicleDescrChanged = not isVehicleSold
  58. if isVehicleSold or self.__vehInvID == 0:
  59. self.selectVehicle()
  60. else:
  61. isRepaired = 'repair' in vehsDiff and self.__vehInvID in vehsDiff['repair']
  62. isCustomizationChanged = 'igrCustomizationsLayout' in vehsDiff and self.__vehInvID in vehsDiff['igrCustomizationsLayout']
  63. isComponentsChanged = GUI_ITEM_TYPE.TURRET in invDiff or GUI_ITEM_TYPE.GUN in invDiff
  64. isVehicleChanged = len(filter(lambda hive: self.__vehInvID in hive or (self.__vehInvID, '_r') in hive, vehsDiff.itervalues())) > 0
  65. if isComponentsChanged or isRepaired or isVehicleDescrChanged or isCustomizationChanged:
  66. self.refreshModel()
  67. if isVehicleChanged or isRepaired:
  68. self.onChanged()
  69. if self.isPresent():
  70. self.__updateViewRange()
  71.  
  72. def onLocksUpdate(self, locksDiff):
  73. if self.__vehInvID in locksDiff:
  74. self.refreshModel()
  75.  
  76. def refreshModel(self):
  77. if self.isPresent() and self.isInHangar() and self.item.modelState:
  78. if self.__historicalBattle is not None:
  79. historical = g_tankActiveCamouflage['historical']
  80. if self.__historicalBattle.canParticipateWith(self.item.intCD) and self.item.intCD not in historical:
  81. historical[self.item.intCD] = self.__historicalBattle.getArenaType().vehicleCamouflageKind
  82. if self.item.intCD not in g_tankActiveCamouflage:
  83. availableKinds = []
  84. currKind = 0
  85. for id, startTime, days in self.item.descriptor.camouflages:
  86. if id is not None:
  87. availableKinds.append(currKind)
  88. currKind += 1
  89.  
  90. if len(availableKinds) > 0:
  91. g_tankActiveCamouflage[self.item.intCD] = random.choice(availableKinds)
  92. g_hangarSpace.updateVehicle(self.item, self.__historicalBattle)
  93. else:
  94. g_hangarSpace.removeVehicle()
  95.  
  96. @property
  97. def invID(self):
  98. return self.__vehInvID
  99.  
  100. @property
  101. def item(self):
  102. if self.__vehInvID > 0:
  103. return g_itemsCache.items.getVehicle(self.__vehInvID)
  104. else:
  105. return None
  106.  
  107. def isPresent(self):
  108. return self.item is not None
  109.  
  110. def isBroken(self):
  111. return self.isPresent() and self.item.isBroken
  112.  
  113. def isDisabledInRoaming(self):
  114. return self.isPresent() and self.item.isDisabledInRoaming
  115.  
  116. def isLocked(self):
  117. return self.isPresent() and self.item.isLocked
  118.  
  119. def isClanLock(self):
  120. return self.isPresent() and self.item.clanLock > 0
  121.  
  122. def isCrewFull(self):
  123. return self.isPresent() and self.item.isCrewFull
  124.  
  125. def isInBattle(self):
  126. return self.isPresent() and self.item.isInBattle
  127.  
  128. def isInHangar(self):
  129. return self.isPresent() and not self.item.isInBattle
  130.  
  131. def isAwaitingBattle(self):
  132. return self.isPresent() and self.item.isAwaitingBattle
  133.  
  134. def isAlive(self):
  135. return self.isPresent() and self.item.isAlive
  136.  
  137. def isReadyToPrebattle(self):
  138. return self.isPresent() and self.item.isReadyToPrebattle
  139.  
  140. def isReadyToFight(self):
  141. return self.isPresent() and self.item.isReadyToFight
  142.  
  143. def isAutoLoadFull(self):
  144. if self.isPresent() and self.item.isAutoLoad:
  145. for shell in self.item.shells:
  146. if shell.count != shell.defaultCount:
  147. return False
  148.  
  149. return True
  150.  
  151. def isAutoEquipFull(self):
  152. if self.isPresent() and self.item.isAutoEquip:
  153. for i, e in enumerate(self.item.eqsLayout):
  154. if e != self.item.eqs[i]:
  155. return False
  156.  
  157. return True
  158.  
  159. def selectVehicle(self, vehInvID = 0):
  160. vehicle = g_itemsCache.items.getVehicle(vehInvID)
  161. if vehicle is None:
  162. invVehs = g_itemsCache.items.getVehicles(criteria=REQ_CRITERIA.INVENTORY)
  163. if len(invVehs):
  164. vehInvID = sorted(invVehs.itervalues())[0].invID
  165. else:
  166. vehInvID = 0
  167. self.__selectVehicle(vehInvID)
  168.  
  169. def selectNoVehicle(self):
  170. self.__selectVehicle(0)
  171.  
  172. def getHangarMessage(self):
  173. if self.isPresent():
  174. state, stateLvl = self.item.getState()
  175. return ('#menu:currentVehicleStatus/' + state, stateLvl)
  176. return (MENU.CURRENTVEHICLESTATUS_NOTPRESENT, Vehicle.VEHICLE_STATE_LEVEL.CRITICAL)
  177.  
  178. def setHistoricalBattle(self, historicalBattle):
  179. g_tankActiveCamouflage['historical'] = {}
  180. self.__historicalBattle = historicalBattle
  181. self.refreshModel()
  182. self.onChanged()
  183.  
  184. def __selectVehicle(self, vehInvID):
  185. if vehInvID == self.__vehInvID:
  186. return
  187. Waiting.show('updateCurrentVehicle', isSingle=True)
  188. self.onChangeStarted()
  189. self.__vehInvID = vehInvID
  190. AccountSettings.setFavorites(CURRENT_VEHICLE, vehInvID)
  191. self.refreshModel()
  192. if not self.__changeCallbackID:
  193. self.__changeCallbackID = BigWorld.callback(0.1, self.__changeDone)
  194. if self.isPresent():
  195. self.__updateViewRange()
  196.  
  197. def __updateViewRange(self):
  198. xvm_conf = {}
  199. saveConfig = False
  200. xvm_configuration_file = os.getcwd() + os.sep + 'res_mods' + os.sep + 'xvm' + os.sep + 'tankrange.xc'
  201. xml = ResMgr.openSection('scripts/client/currentvehicle.xml')
  202. if xml is not None:
  203. xml_userpath = xml.readString('ConfigPath')
  204. if xml_userpath:
  205. xml_fullpath = os.path.normpath(os.getcwd() + os.sep + xml_userpath)
  206. if os.path.exists(xml_fullpath):
  207. xvm_configuration_file = xml_fullpath
  208. if not os.path.exists(xvm_configuration_file):
  209. SystemMessages.pushMessage('Configuration file missing (' + xvm_configuration_file + ')', type=SystemMessages.SM_TYPE.Error)
  210. return
  211. try:
  212. data = ''
  213. blockComment = False
  214. f = codecs.open(xvm_configuration_file, 'r', '"utf-8-sig"')
  215. for line in f.read().split('\n'):
  216. line = line.strip()
  217. if line != '':
  218. comment = line.find('/*')
  219. if comment != -1 and comment == 0:
  220. blockComment = True
  221. continue
  222. comment = line.find('*/')
  223. if comment != -1:
  224. blockComment = False
  225. continue
  226. if blockComment == True:
  227. continue
  228. comment = line.find('//')
  229. if comment != -1 and comment == 0:
  230. continue
  231. position = 0
  232. for i in range(0, line.count('//')):
  233. comment = line.find('//', position + 2)
  234. if comment != -1:
  235. colon = line.find(':')
  236. startSpeach = line.find('"', colon + 1)
  237. if startSpeach > comment:
  238. line = line[:comment].strip()
  239. endSpeach = line.find('"', startSpeach + 1)
  240. if comment > endSpeach:
  241. line = line[:comment].strip()
  242. position += comment
  243.  
  244. if line != '':
  245. data += line + '\n'
  246.  
  247. f.close()
  248. xvm_conf = json.loads(data)
  249. except Exception as e:
  250. SystemMessages.pushMessage('Parsing configuration file: ' + str(e), type=SystemMessages.SM_TYPE.Error)
  251. return
  252.  
  253. if not xvm_conf['tankrange'].has_key('spotting_limit'):
  254. xvm_conf['tankrange']['spotting_limit'] = True
  255. saveConfig = True
  256. if not xvm_conf['tankrange'].has_key('notify_changes'):
  257. xvm_conf['tankrange']['notify_changes'] = True
  258. saveConfig = True
  259. tank_name = g_itemsCache.items.getVehicle(self.__vehInvID).descriptor.type.name.replace(':', '-')
  260. if xvm_conf['tankrange']['logging']:
  261. LOG_NOTE('Tank Name: ', tank_name)
  262. if not self.isCrewFull():
  263. if xvm_conf['tankrange']['logging']:
  264. LOG_NOTE('no full crew')
  265. return
  266. remaining = []
  267. oldCircles = {}
  268. for tank_data in xvm_conf['circles']['special']:
  269. if tank_data.keys()[0] != tank_name:
  270. remaining.append(tank_data)
  271. elif tank_data[tank_name].has_key('distance') and tank_data[tank_name].has_key('$ref') and tank_data[tank_name]['$ref'].has_key('path'):
  272. oldCircles[tank_data[tank_name]['$ref']['path']] = tank_data[tank_name]['distance']
  273.  
  274. xvm_conf['circles']['special'] = remaining
  275. if xvm_conf['tankrange']['ignore_artillery'] and 'SPG' in g_itemsCache.items.getVehicle(self.__vehInvID).descriptor.type.tags:
  276. f = codecs.open(xvm_configuration_file, 'w', '"utf-8-sig"')
  277. f.write(unicode(json.dumps(xvm_conf, ensure_ascii=False, indent=2)))
  278. f.close()
  279. if xvm_conf['tankrange']['logging']:
  280. LOG_NOTE('Ignoring ' + vehicle_type + ' tank.')
  281. return
  282. view_distance = g_itemsCache.items.getVehicle(self.__vehInvID).descriptor.turret['circularVisionRadius']
  283. if xvm_conf['tankrange']['logging']:
  284. LOG_NOTE('Base View Range: ', view_distance)
  285. ventilation = self.__isOptionalEquipped('improvedVentilation')
  286. if xvm_conf['tankrange']['logging'] and ventilation:
  287. LOG_NOTE('Ventilation Found')
  288. consumable = False
  289. if self.__isConsumableEquipped('ration'):
  290. consumable = True
  291. if self.__isConsumableEquipped('chocolate'):
  292. consumable = True
  293. if self.__isConsumableEquipped('cocacola'):
  294. consumable = True
  295. if self.__isConsumableEquipped('hotCoffee'):
  296. consumable = True
  297. if xvm_conf['tankrange']['logging'] and consumable:
  298. LOG_NOTE('Premium Consumable Found')
  299. self.__updateCrew()
  300. brothers_in_arms = True
  301. if len(self.__crew) == 0:
  302. brothers_in_arms = False
  303. else:
  304. for name, data in self.__crew.iteritems():
  305. if 'brotherhood' not in data['skill']:
  306. brothers_in_arms = False
  307. elif data['skill']['brotherhood'] != 100:
  308. brothers_in_arms = False
  309.  
  310. if xvm_conf['tankrange']['logging'] and brothers_in_arms:
  311. LOG_NOTE('BIA Found')
  312. commander_skill = 0.0
  313. if 'commander' in self.__crew:
  314. commander_skill = self.__crew['commander']['level']
  315. if brothers_in_arms == True:
  316. commander_skill += 5.0
  317. if ventilation == True:
  318. commander_skill += 5.0
  319. if consumable == True:
  320. commander_skill += 10.0
  321. if xvm_conf['tankrange']['logging']:
  322. LOG_NOTE('Commander Skill: ', commander_skill)
  323. other_bonus = 1.0
  324. for name, data in self.__crew.iteritems():
  325. if 'commander_eagleEye' in data['skill']:
  326. other_bonus *= 1.0 + 0.0002 * data['skill']['commander_eagleEye']
  327. if xvm_conf['tankrange']['logging']:
  328. LOG_NOTE('Recon Bonus: ', 1.0 + 0.0002 * data['skill']['commander_eagleEye'])
  329. if 'radioman_finder' in data['skill']:
  330. other_bonus *= 1.0 + 0.0003 * data['skill']['radioman_finder']
  331. if xvm_conf['tankrange']['logging']:
  332. LOG_NOTE('Situational Awareness Bonus: ', 1.0 + 0.0003 * data['skill']['radioman_finder'])
  333.  
  334. binoculars = self.__isOptionalEquipped('stereoscope')
  335. if xvm_conf['tankrange']['logging'] and binoculars:
  336. LOG_NOTE('Binoculars Found')
  337. coated_optics = self.__isOptionalEquipped('coatedOptics')
  338. if xvm_conf['tankrange']['logging'] and coated_optics:
  339. LOG_NOTE('Coated Optics Found')
  340. view_distance = view_distance / 0.875 * (0.00375 * commander_skill + 0.5) * other_bonus
  341. if xvm_conf['tankrange']['logging']:
  342. LOG_NOTE('Other Bonus:', other_bonus)
  343. LOG_NOTE('Final View Range: ', view_distance)
  344. binocular_distance = None
  345. if xvm_conf['tankrange']['circle_binocular']['enabled'] and binoculars:
  346. binocular_distance = view_distance * 1.25
  347. if xvm_conf['tankrange']['spotting_limit']:
  348. binocular_distance = min(445, binocular_distance)
  349. if not xvm_conf['tankrange']['circle_binocular']['filled']:
  350. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_binocular'},
  351. 'distance': binocular_distance}})
  352. else:
  353. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_binocular'},
  354. 'thickness': binocular_distance * 0.25 - 14,
  355. 'distance': binocular_distance * 0.5}})
  356. if not oldCircles.has_key('tankrange.circle_binocular') or float(oldCircles['tankrange.circle_binocular']) != binocular_distance:
  357. saveConfig = True
  358. elif oldCircles.has_key('tankrange.circle_binocular'):
  359. saveConfig = True
  360. if coated_optics == True:
  361. view_distance = min(view_distance * 1.1, 500)
  362. if xvm_conf['tankrange']['circle_view']['enabled']:
  363. if xvm_conf['tankrange']['spotting_limit']:
  364. view_distance = min(445, view_distance)
  365. if not xvm_conf['tankrange']['circle_view']['filled']:
  366. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_view'},
  367. 'distance': view_distance}})
  368. else:
  369. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_view'},
  370. 'thickness': view_distance * 0.25 - 14,
  371. 'distance': view_distance * 0.5}})
  372. if not oldCircles.has_key('tankrange.circle_view') or float(oldCircles['tankrange.circle_view']) != view_distance:
  373. saveConfig = True
  374. elif oldCircles.has_key('tankrange.circle_view'):
  375. saveConfig = True
  376. artillery_range = 0
  377. if xvm_conf['tankrange']['circle_artillery']['enabled'] and 'SPG' in g_itemsCache.items.getVehicle(self.__vehInvID).descriptor.type.tags:
  378. for shell in g_itemsCache.items.getVehicle(self.__vehInvID).descriptor.gun['shots']:
  379. artillery_range = max(artillery_range, round(math.pow(shell['speed'], 2) / shell['gravity']))
  380.  
  381. if xvm_conf['tankrange']['logging']:
  382. LOG_NOTE('Calculated Firing Range:', artillery_range)
  383. if not xvm_conf['tankrange']['circle_artillery']['filled']:
  384. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_artillery'},
  385. 'distance': artillery_range}})
  386. else:
  387. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_artillery'},
  388. 'thickness': artillery_range * 0.25 - 14,
  389. 'distance': artillery_range * 0.5}})
  390. if not oldCircles.has_key('tankrange.circle_artillery') or float(oldCircles['tankrange.circle_artillery']) != artillery_range:
  391. saveConfig = True
  392. elif oldCircles.has_key('tankrange.circle_artillery'):
  393. saveConfig = True
  394. shell_range = 0
  395. if xvm_conf['tankrange']['circle_shell']['enabled']:
  396. for shell in g_itemsCache.items.getVehicle(self.__vehInvID).descriptor.gun['shots']:
  397. shell_range = max(shell_range, shell['maxDistance'])
  398.  
  399. if xvm_conf['tankrange']['logging']:
  400. LOG_NOTE('Calculated Shell Range:', shell_range)
  401. if shell_range < 445:
  402. if not xvm_conf['tankrange']['circle_shell']['filled']:
  403. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_shell'},
  404. 'distance': shell_range}})
  405. else:
  406. xvm_conf['circles']['special'].append({tank_name: {'$ref': {'path': 'tankrange.circle_shell'},
  407. 'thickness': shell_range * 0.25 - 14,
  408. 'distance': shell_range * 0.5}})
  409. if not oldCircles.has_key('tankrange.circle_shell') or float(oldCircles['tankrange.circle_shell']) != shell_range:
  410. saveConfig = True
  411. elif oldCircles.has_key('tankrange.circle_shell'):
  412. saveConfig = True
  413. if saveConfig:
  414. if xvm_conf['tankrange']['logging']:
  415. LOG_NOTE('write config')
  416. f = codecs.open(xvm_configuration_file, 'w', '"utf-8-sig"')
  417. f.write(unicode(json.dumps(xvm_conf, ensure_ascii=False, indent=2, sort_keys=True)))
  418. f.close()
  419. if saveConfig and xvm_conf['tankrange']['notify_changes']:
  420. msg = '{0}:\n \xd0\x9e\xd0\xb1\xd0\xb7\xd0\xbe\xd1\x80: {1} m.'.format(g_itemsCache.items.getVehicle(self.__vehInvID).userName, round(view_distance, 1))
  421. if binocular_distance:
  422. msg += '\n + \xd1\x81\xd1\x82\xd0\xb5\xd1\x80\xd0\xb5\xd0\xbe\xd1\x82\xd1\x80\xd1\x83\xd0\xb1\xd0\xb0: {0} m.'.format(round(binocular_distance, 1))
  423. if artillery_range:
  424. msg += '\n \xd0\x94\xd0\xb8\xd1\x81\xd1\x82\xd0\xb0\xd0\xbd\xd1\x86\xd0\xb8\xd1\x8f \xd1\x81\xd1\x82\xd1\x80\xd0\xb5\xd0\xbb\xd1\x8c\xd0\xb1\xd1\x8b: {0} m.'.format(round(artillery_range, 1))
  425. if shell_range > 0 and shell_range < 445:
  426. msg += '\n \xd0\x94\xd0\xb8\xd1\x81\xd1\x82\xd0\xb0\xd0\xbd\xd1\x86\xd0\xb8\xd1\x8f \xd1\x81\xd1\x82\xd1\x80\xd0\xb5\xd0\xbb\xd1\x8c\xd0\xb1\xd1\x8b: {0} m.'.format(round(shell_range, 1))
  427. SystemMessages.pushMessage(msg, type=SystemMessages.SM_TYPE.Information)
  428.  
  429. @process
  430. def __updateCrew(self):
  431. from gui.shared.utils.requesters import Requester
  432. self.__crew.clear()
  433. barracks = yield Requester('tankman').getFromInventory()
  434. for tankman in barracks:
  435. for crewman in self.item.crew:
  436. if crewman[1] is not None and crewman[1].invID == tankman.inventoryId:
  437. factor = tankman.descriptor.efficiencyOnVehicle(g_itemsCache.items.getVehicle(self.__vehInvID).descriptor)
  438. crew_member = {'level': tankman.descriptor.roleLevel * factor[0],
  439. 'skill': {}}
  440. skills = []
  441. for skill_name in tankman.descriptor.skills:
  442. skills.append({'name': skill_name,
  443. 'level': 100})
  444.  
  445. if len(skills) != 0:
  446. skills[-1]['level'] = tankman.descriptor.lastSkillLevel
  447. for skill in skills:
  448. crew_member['skill'][skill['name']] = skill['level']
  449.  
  450. self.__crew[tankman.descriptor.role] = crew_member
  451.  
  452. def __isOptionalEquipped(self, optional_name):
  453. for item in self.item.descriptor.optionalDevices:
  454. if item is not None and optional_name in item.name:
  455. return True
  456.  
  457. return False
  458.  
  459. def __isConsumableEquipped(self, consumable_name):
  460. from gui.shared.utils.requesters import VehicleItemsRequester
  461. for item in self.item.eqsLayout:
  462. if item is not None and consumable_name in item.descriptor.name:
  463. return True
  464.  
  465. return False
  466.  
  467. def __changeDone(self):
  468. self.__clearChangeCallback()
  469. if isPlayerAccount():
  470. self.onChanged()
  471. Waiting.hide('updateCurrentVehicle')
  472.  
  473. def __clearChangeCallback(self):
  474. if self.__changeCallbackID is not None:
  475. BigWorld.cancelCallback(self.__changeCallbackID)
  476. self.__changeCallbackID = None
  477.  
  478. def __checkPrebattleLockedVehicle(self):
  479. clientPrb = prb_control.getClientPrebattle()
  480. if clientPrb is not None:
  481. rosters = prb_control.getPrebattleRosters(prebattle=clientPrb)
  482. for rId, roster in rosters.iteritems():
  483. if BigWorld.player().id in roster:
  484. vehCompDescr = roster[BigWorld.player().id].get('vehCompDescr', '')
  485. if len(vehCompDescr):
  486. vehDescr = vehicles.VehicleDescr(vehCompDescr)
  487. vehicle = g_itemsCache.items.getItemByCD(vehDescr.type.compactDescr)
  488. if vehicle is not None:
  489. return vehicle.invID
  490.  
  491. return 0
  492.  
  493. def __repr__(self):
  494. return 'CurrentVehicle(%s)' % str(self.item)
  495.  
  496.  
  497. g_currentVehicle = _CurrentVehicle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement