Guest User

BOT DO ROS ~ KoYGeR

a guest
Jan 19th, 2016
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.37 KB | None | 0 0
  1. import ui
  2. import player
  3. import net
  4. import shop
  5. import chat
  6.  
  7. roska = 0
  8. status = 0
  9. cena_roski = 5000000 #USTAW CENE ROSKI
  10.  
  11. class BotDoRosPL(ui.Board):
  12.     def __init__(self):
  13.         ui.Board.__init__(self)
  14.         self.ZbudujOkno()
  15.        
  16.     def __del__(self):
  17.         ui.Board.__del__(self)
  18.  
  19.     def Destroy(self):
  20.         self.Hide()
  21.         return TRUE
  22.  
  23.     def ZbudujOkno(self):
  24.         self.SetCenterPosition(-100, -170)
  25.         self.SetSize(200, 350)
  26.         self.Show()
  27.         self.AddFlag("float")
  28.         self.AddFlag("movable")
  29.  
  30.         self.LoadButtons()
  31.  
  32.     def LoadButtons(self):
  33.         self.CloseButton = ui.Button()
  34.         self.CloseButton.SetParent(self)
  35.         self.CloseButton.SetPosition(self.GetWidth()-23, 8)
  36.         self.CloseButton.SetToolTipText("Zamknij")
  37.         self.CloseButton.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  38.         self.CloseButton.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  39.         self.CloseButton.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  40.         self.CloseButton.SetEvent(ui.__mem_func__(self.Close))
  41.         self.CloseButton.Show()
  42.  
  43.         self.Rosa1 = ui.ExpandedImageBox()
  44.         self.Rosa1.SetParent(self)
  45.         self.Rosa1.SetPosition(40, 40)
  46.         self.Rosa1.LoadImage(str("icon/item/50821.tga"))
  47.         self.Rosa1.Show()
  48.         self.Rosa1Button = ui.Button()
  49.         self.Rosa1Button.SetParent(self.Rosa1)
  50.         self.Rosa1Button.SetToolTipText("Czerwona rosa", 16, -5)
  51.         self.Rosa1Button.SetPosition(0, 0)
  52.         self.Rosa1Button.SetSize(30, 30)
  53.         self.Rosa1Button.SetEvent(self.Wybierz1)
  54.         self.Rosa1Button.Show()
  55.        
  56.         self.Rosa2 = ui.ExpandedImageBox()
  57.         self.Rosa2.SetParent(self)
  58.         self.Rosa2.SetPosition(82, 40)
  59.         self.Rosa2.LoadImage(str("icon/item/50822.tga"))
  60.         self.Rosa2.Show()
  61.         self.Rosa2Button = ui.Button()
  62.         self.Rosa2Button.SetParent(self.Rosa2)
  63.         self.Rosa2Button.SetToolTipText("Różowa rosa", 16, -5)
  64.         self.Rosa2Button.SetPosition(0, 0)
  65.         self.Rosa2Button.SetSize(30, 30)
  66.         self.Rosa2Button.SetEvent(self.Wybierz2)
  67.         self.Rosa2Button.Show()
  68.        
  69.         self.Rosa3 = ui.ExpandedImageBox()
  70.         self.Rosa3.SetParent(self)
  71.         self.Rosa3.SetPosition(124, 40)
  72.         self.Rosa3.LoadImage(str("icon/item/50823.tga"))
  73.         self.Rosa3.Show()
  74.         self.Rosa3Button = ui.Button()
  75.         self.Rosa3Button.SetParent(self.Rosa3)
  76.         self.Rosa3Button.SetToolTipText("Żółta rosa", 16, -5)
  77.         self.Rosa3Button.SetPosition(0, 0)
  78.         self.Rosa3Button.SetSize(30, 30)
  79.         self.Rosa3Button.SetEvent(self.Wybierz3)
  80.         self.Rosa3Button.Show()
  81.        
  82.         self.Rosa4 = ui.ExpandedImageBox()
  83.         self.Rosa4.SetParent(self)
  84.         self.Rosa4.SetPosition(40, 110)
  85.         self.Rosa4.LoadImage(str("icon/item/50824.tga"))
  86.         self.Rosa4.Show()
  87.         self.Rosa4Button = ui.Button()
  88.         self.Rosa4Button.SetParent(self.Rosa4)
  89.         self.Rosa4Button.SetToolTipText("Zielona rosa", 16, -5)
  90.         self.Rosa4Button.SetPosition(0, 0)
  91.         self.Rosa4Button.SetSize(30, 30)
  92.         self.Rosa4Button.SetEvent(self.Wybierz4)
  93.         self.Rosa4Button.Show()
  94.        
  95.         self.Rosa5 = ui.ExpandedImageBox()
  96.         self.Rosa5.SetParent(self)
  97.         self.Rosa5.SetPosition(82, 110)
  98.         self.Rosa5.LoadImage(str("icon/item/50825.tga"))
  99.         self.Rosa5.Show()
  100.         self.Rosa5Button = ui.Button()
  101.         self.Rosa5Button.SetParent(self.Rosa5)
  102.         self.Rosa5Button.SetToolTipText("Niebieska rosa", 16, -5)
  103.         self.Rosa5Button.SetPosition(0, 0)
  104.         self.Rosa5Button.SetSize(30, 30)
  105.         self.Rosa5Button.SetEvent(self.Wybierz5)
  106.         self.Rosa5Button.Show()
  107.        
  108.         self.Rosa6 = ui.ExpandedImageBox()
  109.         self.Rosa6.SetParent(self)
  110.         self.Rosa6.SetPosition(124, 110)
  111.         self.Rosa6.LoadImage(str("icon/item/50826.tga"))
  112.         self.Rosa6.Show()
  113.         self.Rosa6Button = ui.Button()
  114.         self.Rosa6Button.SetParent(self.Rosa6)
  115.         self.Rosa6Button.SetToolTipText("Biała rosa", 16, -5)
  116.         self.Rosa6Button.SetPosition(0, 0)
  117.         self.Rosa6Button.SetSize(30, 30)
  118.         self.Rosa6Button.SetEvent(self.Wybierz6)
  119.         self.Rosa6Button.Show()
  120.        
  121.         self.Title = ui.TextLine()
  122.         self.Title.SetParent(self)
  123.         self.Title.SetPosition(50, 15)
  124.         self.Title.SetText("|cFFddb30dBot do ros ~ KoYGeR")
  125.         self.Title.Show()
  126.        
  127.         self.Napis2 = ui.TextLine()
  128.         self.Napis2.SetParent(self)
  129.         self.Napis2.SetPosition(67, 170)
  130.         self.Napis2.SetFontColor(0.0, 0.7, 0.7)
  131.         self.Napis2.SetText("Wybrana rosa:")
  132.         self.Napis2.Show()
  133.        
  134.         self.Napis3 = ui.TextLine()
  135.         self.Napis3.SetParent(self)
  136.         self.Napis3.SetPosition(93, 185)
  137.         self.Napis3.SetFontColor(1.0, 1.0, 1.0)
  138.         self.Napis3.SetText("---")
  139.         self.Napis3.Show()
  140.        
  141.         self.Napis = ui.TextLine()
  142.         self.Napis.SetParent(self)
  143.         self.Napis.SetPosition(60, 210)
  144.         self.Napis.SetFontColor(0.0, 0.7, 0.7)
  145.         self.Napis.SetText("Minimalna wartość:")
  146.         self.Napis.Show()
  147.  
  148.         self.WartoscBar = ui.SlotBar()
  149.         self.WartoscBar.SetParent(self)
  150.         self.WartoscBar.SetSize(30, 15)
  151.         self.WartoscBar.SetPosition(85, 225)
  152.         self.WartoscBar.Show()
  153.         self.WartoscRoski = ui.EditLine()
  154.         self.WartoscRoski.SetParent(self.WartoscBar)
  155.         self.WartoscRoski.SetSize(110, 15)
  156.         self.WartoscRoski.SetPosition(5, 0)
  157.         self.WartoscRoski.SetMax(3)
  158.         self.WartoscRoski.SetNumberMode()
  159.         self.WartoscRoski.SetFocus()
  160.         self.WartoscRoski.SetText("0")
  161.         self.WartoscRoski.Show()
  162.        
  163.         self.Napis1 = ui.TextLine()
  164.         self.Napis1.SetParent(self)
  165.         self.Napis1.SetPosition(75, 255)
  166.         self.Napis1.SetFontColor(0.0, 0.7, 0.7)
  167.         self.Napis1.SetText("Czas trwania:")
  168.         self.Napis1.Show()
  169.  
  170.         self.CzasBar = ui.SlotBar()
  171.         self.CzasBar.SetParent(self)
  172.         self.CzasBar.SetSize(30, 15)
  173.         self.CzasBar.SetPosition(85, 270)
  174.         self.CzasBar.Show()
  175.         self.CzasRoski = ui.EditLine()
  176.         self.CzasRoski.SetParent(self.CzasBar)
  177.         self.CzasRoski.SetSize(110, 15)
  178.         self.CzasRoski.SetPosition(5, 0)
  179.         self.CzasRoski.SetMax(2)
  180.         self.CzasRoski.SetNumberMode()
  181.         self.CzasRoski.SetFocus()
  182.         self.CzasRoski.SetText("0")
  183.         self.CzasRoski.Show()
  184.  
  185.         self.StartButton = ui.Button()
  186.         self.StartButton.SetParent(self)
  187.         self.StartButton.SetPosition(75, 295)
  188.         self.StartButton.SetUpVisual("d:/ymir work/ui/public/big_Button_01.sub")
  189.         self.StartButton.SetOverVisual("d:/ymir work/ui/public/big_Button_02.sub")
  190.         self.StartButton.SetDownVisual("d:/ymir work/ui/public/big_Button_03.sub")
  191.         self.StartButton.SetEvent(self.Kupuj)
  192.         self.StartButton.SetText("Start")
  193.         self.StartButton.Show()
  194.  
  195.     def Close(self):
  196.         self.Hide()
  197.  
  198.     def Wybierz1(self):
  199.         global roska
  200.         self.Napis3.SetText("Czerwona")
  201.         self.Napis3.SetFontColor(1.0, 0, 0)
  202.         self.Napis3.SetPosition(78, 185)
  203.         roska = 50821
  204.     def Wybierz2(self):
  205.         global roska
  206.         self.Napis3.SetText("Różowa")
  207.         self.Napis3.SetFontColor(1.0, 0.4, 0)
  208.         self.Napis3.SetPosition(80, 185)
  209.         roska = 50822
  210.     def Wybierz3(self):
  211.         global roska
  212.         self.Napis3.SetText("Żółta")
  213.         self.Napis3.SetFontColor(1.0, 0.8, 0)
  214.         self.Napis3.SetPosition(88, 185)
  215.         roska = 50823
  216.     def Wybierz4(self):
  217.         global roska
  218.         self.Napis3.SetText("Zielona")
  219.         self.Napis3.SetFontColor(0.1, 1.0, 0)
  220.         self.Napis3.SetPosition(82, 185)
  221.         roska = 50824
  222.     def Wybierz5(self):
  223.         global roska
  224.         self.Napis3.SetText("Niebieska")
  225.         self.Napis3.SetFontColor(0.0, 0.2, 1.0)
  226.         self.Napis3.SetPosition(78, 185)
  227.         roska = 50825
  228.     def Wybierz6(self):
  229.         global roska
  230.         self.Napis3.SetText("Biała")
  231.         self.Napis3.SetFontColor(1.0, 1.0, 1.0)
  232.         self.Napis3.SetPosition(88, 185)
  233.         roska = 50826
  234.  
  235.     def Kupuj(self):
  236.         global status
  237.         if status == 0:
  238.             status = 1
  239.             self.StartButton.SetText("Zatrzymaj")
  240.             self.KupowanieRosek()
  241.         else:
  242.             status = 0
  243.             self.StartButton.SetText("Start")
  244.  
  245.     def KupowanieRosek(self):
  246.         global status
  247.         Yang = player.GetMoney()
  248.         if status == 1:
  249.             if roska == 0:
  250.                 chat.AppendChat(chat.CHAT_TYPE_NOTICE, "[Błąd] Wybierz którąś z rosek!")
  251.                 status = 0
  252.                 self.StartButton.SetText("Start")
  253.                 return
  254.             if Yang <= cena_roski:
  255.                 chat.AppendChat(chat.CHAT_TYPE_NOTICE, "[Błąd] Nie masz wystarczająco kasy :(")
  256.                 status = 0
  257.                 self.StartButton.SetText("Start")
  258.                 return
  259.             for slot in xrange(shop.SHOP_SLOT_COUNT):
  260.                 ShopItemValue = shop.GetItemID(slot)
  261.                 lel = roska
  262.                 if ShopItemValue == int(lel):
  263.                     net.SendShopBuyPacket(slot)
  264.                     self.Czekaj = WaitingDialog()
  265.                     self.Czekaj.Open(0.5)
  266.                     self.Czekaj.SAFE_SetTimeOverEvent(self.KupowanieRosek)
  267.        
  268.             ItemIndex = roska
  269.             MinValue = int(self.WartoscRoski.GetText())
  270.             MinTime = int(self.CzasRoski.GetText())
  271.             for InventorySlot in xrange(player.INVENTORY_PAGE_SIZE*2):
  272.                 ItemIndex = player.GetItemIndex(InventorySlot)
  273.                 ItemValue = roska
  274.                 (Value0, Value, Time) = [ player.GetItemMetinSocket(InventorySlot, i) for i in xrange(player.METIN_SOCKET_MAX_NUM) ]
  275.                 if ItemIndex == ItemValue and (Value < MinValue or Time < MinTime):
  276.                     net.SendShopSellPacket(InventorySlot)
  277.                 else:
  278.                     pass
  279.                    
  280.  
  281. class WaitingDialog(ui.ScriptWindow):
  282.     def __init__(self):
  283.         ui.ScriptWindow.__init__(self)
  284.         self.eventTimeOver = lambda *arg: None
  285.         self.eventExit = lambda *arg: None
  286.  
  287.     def __del__(self):
  288.         ui.ScriptWindow.__del__(self)
  289.  
  290.     def Open(self, waitTime):
  291.         import time
  292.         curTime = time.clock()
  293.         self.endTime = curTime + waitTime
  294.  
  295.         self.Show()    
  296.  
  297.     def Close(self):
  298.         self.Hide()
  299.  
  300.     def Destroy(self):
  301.         self.Hide()
  302.  
  303.     def SAFE_SetTimeOverEvent(self, event):
  304.         self.eventTimeOver = ui.__mem_func__(event)
  305.  
  306.     def SAFE_SetExitEvent(self, event):
  307.         self.eventExit = ui.__mem_func__(event)
  308.        
  309.     def OnUpdate(self):
  310.         import time
  311.         lastTime = max(0, self.endTime - time.clock())
  312.         if 0 == lastTime:
  313.             self.Close()
  314.             self.eventTimeOver()
  315.         else:
  316.             return
  317.        
  318.     def OnPressExitKey(self):
  319.         self.Close()
  320.         return TRUE
  321.  
  322. StartDialog = BotDoRosPL()
  323. StartDialog.Show()
Advertisement
Add Comment
Please, Sign In to add comment