qleaKz

Metin2 Auto-Potions

Feb 23rd, 2014
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.74 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() - 45, wndMgr.GetScreenHeight() / 4 + 30)
  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("Potions")
  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 = [72723,72725,72726]
  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.             BluePotions = [72727,72729,72730]
  46.             blue_active = 0
  47.             for i in xrange(90,-1,-1):
  48.                 if player.GetItemIndex(i) in BluePotions and player.GetItemMetinSocket(i, 0) == 1:
  49.                     blue_active = 1
  50.                     break
  51.             if blue_active == 0:
  52.                 for i in xrange(90,-1,-1):
  53.                     if player.GetItemIndex(i) in BluePotions:
  54.                         net.SendItemUsePacket(i)
  55.                         break
  56.  
  57.             self.delay = WaitingDialog()
  58.             self.delay.Open(1)
  59.             self.delay.SAFE_SetTimeOverEvent(self.AutoPotion)
  60.  
  61. class WaitingDialog(ui.ScriptWindow):
  62.  
  63.     def __init__(self):
  64.         ui.ScriptWindow.__init__(self)
  65.         self.eventTimeOver = lambda *arg: None
  66.         self.eventExit = lambda *arg: None
  67.  
  68.     def __del__(self):
  69.         ui.ScriptWindow.__del__(self)
  70.  
  71.     def Open(self, waitTime):
  72.         import time
  73.         curTime = time.clock()
  74.         self.endTime = curTime + waitTime
  75.         self.Show()    
  76.  
  77.     def Close(self):
  78.         self.Hide()
  79.  
  80.     def Destroy(self):
  81.         self.Hide()
  82.  
  83.     def SAFE_SetTimeOverEvent(self, event):
  84.         self.eventTimeOver = ui.__mem_func__(event)
  85.  
  86.     def SAFE_SetExitEvent(self, event):
  87.         self.eventExit = ui.__mem_func__(event)
  88.        
  89.     def OnUpdate(self):
  90.         import time
  91.         lastTime = max(0, self.endTime - time.clock())
  92.         if 0 == lastTime:
  93.             self.Close()
  94.             self.eventTimeOver()
  95.         else:
  96.             return
  97.        
  98.     def OnPressExitKey(self):
  99.         self.Close()
  100.         return TRUE
  101.  
  102. StartDialog = AutoPotions()
  103. StartDialog.Show()
Advertisement
Add Comment
Please, Sign In to add comment