Guest User

autopotion.py

a guest
Aug 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. import ui, wndMgr, player, net
  2.  
  3. class AutoPotions(ui.ScriptWindow):
  4.  
  5. def __init__(self):
  6. ui.ScriptWindow.__init__(self)
  7.  
  8. self.PotionButton = ui.Button()
  9. self.PotionButton.SetPosition(wndMgr.GetScreenWidth() - 87, wndMgr.GetScreenHeight() / 5 + 10)
  10. self.PotionButton.SetUpVisual("d:/ymir work/ui/public/small_Button_01.sub")
  11. self.PotionButton.SetOverVisual("d:/ymir work/ui/public/small_Button_02.sub")
  12. self.PotionButton.SetDownVisual("d:/ymir work/ui/public/small_Button_03.sub")
  13. self.PotionButton.SetText("Potar")
  14. self.PotionButton.SetEvent(self.SetPotions)
  15. self.PotionButton.Show()
  16.  
  17. self.AutoPotionStatus = 0
  18.  
  19. def __del__(self):
  20. ui.ScriptWindow.__del__(self)
  21.  
  22. def SetPotions(self):
  23. if self.AutoPotionStatus == 1:
  24. self.AutoPotionStatus = 0
  25. self.PotionButton.SetUpVisual("d:/ymir work/ui/public/small_Button_01.sub")
  26. else:
  27. self.AutoPotionStatus = 1
  28. self.PotionButton.SetUpVisual("d:/ymir work/ui/public/small_Button_03.sub")
  29. self.AutoPotion()
  30.  
  31. def AutoPotion(self):
  32. if self.AutoPotionStatus == 1:
  33. RedPotions = [70020]
  34. red_active = 0
  35. for i in xrange(90,-1,-1):
  36. if player.GetItemIndex(i) in RedPotions and player.GetItemMetinSocket(i, 0) == 1:
  37. red_active = 1
  38. break
  39. if red_active == 0:
  40. for i in xrange(90,-1,-1):
  41. if player.GetItemIndex(i) in RedPotions:
  42. net.SendItemUsePacket(i)
  43. break
  44.  
  45. self.delay = WaitingDialog()
  46. self.delay.Open(0)
  47. self.delay.SAFE_SetTimeOverEvent(self.AutoPotion)
  48.  
  49. class WaitingDialog(ui.ScriptWindow):
  50.  
  51. def __init__(self):
  52. ui.ScriptWindow.__init__(self)
  53. self.eventTimeOver = lambda *arg: None
  54. self.eventExit = lambda *arg: None
  55.  
  56. def __del__(self):
  57. ui.ScriptWindow.__del__(self)
  58.  
  59. def Open(self, waitTime):
  60. import time
  61. curTime = time.clock()
  62. self.endTime = curTime + waitTime
  63. self.Show()
  64.  
  65. def Close(self):
  66. self.Hide()
  67.  
  68. def Destroy(self):
  69. self.Hide()
  70.  
  71. def SAFE_SetTimeOverEvent(self, event):
  72. self.eventTimeOver = ui.__mem_func__(event)
  73.  
  74. def SAFE_SetExitEvent(self, event):
  75. self.eventExit = ui.__mem_func__(event)
  76.  
  77. def OnUpdate(self):
  78. import time
  79. lastTime = max(0, self.endTime - time.clock())
  80. if 0 == lastTime:
  81. self.Close()
  82. self.eventTimeOver()
  83. else:
  84. return
  85.  
  86. def OnPressExitKey(self):
  87. self.Close()
  88. return TRUE
  89.  
  90. StartDialog = AutoPotions()
  91. StartDialog.Show()
Add Comment
Please, Sign In to add comment