Advertisement
deutscher_Adler

Untitled

Oct 11th, 2015
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.42 KB | None | 0 0
  1. import BigWorld
  2. import ResMgr, Keys
  3. from PlayerEvents import g_playerEvents
  4. from helpers import getClientLanguage
  5. import sys, os
  6. curTime = None
  7. xml = ResMgr.openSection('scripts/client/mods/Walhalla_Laser_0910.xml')
  8. if xml:
  9. LaserModActive = xml.readBool('LaserModActive')
  10. ColoredLaserModActive = xml.readBool('ColoredLaserModActive')
  11. clrkey = xml.readString('ColoredLaser')
  12. togglekey = xml.readString('activatekey')
  13. print 'Walhalla_Laser_0910.xml Config successfully loaded'
  14. else:
  15. print 'Can`t open Walhalla_Laser_0910.xml'
  16. LaserModActive = True
  17. ColoredLaserModActive = True
  18. clrkey = 'KEY_NUMPAD7'
  19. togglekey = 'KEY_NUMPAD8'
  20. clr_key = getattr(Keys, clrkey)
  21. toggle_key = getattr(Keys, togglekey)
  22.  
  23. def CheckVersion():
  24. import Account
  25. funcs = dir(Account.PlayerAccount)
  26. import re
  27. for s in funcs:
  28. if not str(s).find('version') == -1:
  29. return int(re.sub('[^\\d-]+', '', s))
  30.  
  31.  
  32. if not hasattr(BigWorld, 'Version'):
  33. BigWorld.Version = CheckVersion()
  34.  
  35. def DebugMsg087(textRU, textEN = '', doHighlight = False):
  36. from helpers import getClientLanguage
  37. if getClientLanguage() == 'ru':
  38. text = textRU
  39. else:
  40. text = textEN
  41. player = BigWorld.player()
  42. import Avatar, Account
  43. if player is not None:
  44. if type(BigWorld.player()) is Account.PlayerAccount:
  45. from gui import SystemMessages
  46. SystemMessages.pushI18nMessage(text, type=SystemMessages.SM_TYPE.Information)
  47. elif type(BigWorld.player()) is Avatar.PlayerAvatar:
  48. from messenger.gui import MessengerDispatcher
  49. MessengerDispatcher.g_instance.battleMessenger.addFormattedMessage(text, doHighlight, False)
  50. return
  51.  
  52.  
  53. def DebugMsg088(textRU, textEN = '', color = '#00cdcd'):
  54. from helpers import getClientLanguage
  55. if getClientLanguage() == 'ru':
  56. text = textRU
  57. else:
  58. text = textEN
  59. player = BigWorld.player()
  60. htmlMessage = "<font color='{color}'>{text}</font>".format(color=color, text=text)
  61. import Avatar, Account
  62. if player is not None:
  63. if type(BigWorld.player()) is Account.PlayerAccount:
  64. from gui import SystemMessages
  65. SystemMessages.pushI18nMessage(htmlMessage, type=SystemMessages.SM_TYPE.Information)
  66. elif type(BigWorld.player()) is Avatar.PlayerAvatar:
  67. from messenger import MessengerEntry
  68. MessengerEntry.g_instance.gui.addClientMessage(htmlMessage)
  69. return
  70.  
  71.  
  72. if not hasattr(BigWorld, 'DebugMsg'):
  73. if BigWorld.Version == 8701:
  74. BigWorld.DebugMsg = DebugMsg087
  75. else:
  76. BigWorld.DebugMsg = DebugMsg088
  77. entries = {}
  78.  
  79. def initLasers():
  80. global ColoredLaserModActive
  81. global curTime
  82. global entries
  83. global LaserModActive
  84. import Account
  85. if hasattr(BigWorld.player(), 'isOnArena'):
  86. if BigWorld.player().isOnArena:
  87. if curTime is None or curTime + 1 < BigWorld.time():
  88. if BigWorld.isKeyDown(toggle_key):
  89. curTime = BigWorld.time()
  90. if LaserModActive:
  91. LaserModActive = False
  92. BigWorld.DebugMsg('Der Laserpointer ist deaktiviert', 'Laser Sight Mod OFF')
  93. else:
  94. LaserModActive = True
  95. BigWorld.DebugMsg('Der Laserpointer ist aktiviert', 'Laser Sight Mod ON')
  96. if BigWorld.isKeyDown(clr_key):
  97. curTime = BigWorld.time()
  98. if ColoredLaserModActive:
  99. ColoredLaserModActive = False
  100. BigWorld.DebugMsg('Farbige Laser deaktiviert', 'Colored Laser OFF')
  101. else:
  102. ColoredLaserModActive = True
  103. BigWorld.DebugMsg('Farbige Laser aktiviert', 'Colored Laser ON')
  104. import Vehicle
  105. if LaserModActive:
  106. playerHealth = BigWorld.player().vehicleTypeDescriptor.maxHealth
  107. for v in BigWorld.entities.values():
  108. if type(v) is Vehicle.Vehicle:
  109. if v.isAlive():
  110. if v.publicInfo['team'] is not BigWorld.player().team:
  111. if not entries.has_key(v.id):
  112. if ColoredLaserModActive:
  113. shotsToKill = playerHealth / v.typeDescriptor.gun['shots'][0]['shell']['damage'][0]
  114. if shotsToKill < 3.0:
  115. laserColor = 'red'
  116. elif shotsToKill > 8.0:
  117. laserColor = 'green'
  118. else:
  119. laserColor = 'yellow'
  120. else:
  121. laserColor = 'red'
  122. listi = v.appearance
  123. newModel = BigWorld.Model('objects/%sgun.model' % laserColor)
  124. servo = BigWorld.Servo(listi.modelsDesc['gun']['model'].matrix)
  125. newModel.addMotor(servo)
  126. entries[v.id] = dict({'model': newModel,
  127. 'vehicle': v,
  128. 'lasttime': BigWorld.time()})
  129. v.addModel(newModel)
  130. else:
  131. entries[v.id]['lasttime'] = BigWorld.time()
  132.  
  133. currentTime = BigWorld.time()
  134. for k in entries.keys():
  135. if entries[k]['lasttime'] + 0.5 < currentTime or not LaserModActive:
  136. ModelToDel = entries[k]
  137. try:
  138. ModelToDel['vehicle'].delModel(ModelToDel['model'])
  139. except:
  140. pass
  141.  
  142. del entries[k]
  143.  
  144. if type(BigWorld.player()) is not Account.PlayerAccount:
  145. BigWorld.callback(0.1, lambda : initLasers())
  146. return
  147.  
  148.  
  149. def reloadLasers():
  150. global entries
  151. aih = BigWorld.player().inputHandler
  152. if not hasattr(aih, 'ctrl'):
  153. BigWorld.callback(0.1, lambda : reloadLasers())
  154. else:
  155. entries = {}
  156. initLasers()
  157.  
  158.  
  159. g_playerEvents.onAvatarReady += reloadLasers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement