def LevelUpRod(self): self.SetState(self.STATE_IMPROVING_ROD) self.stopFishing() if self.isMoving: return #Unequip weapon if it is a rod val = OpenLib.isItemTypeOnSlot(item.ITEM_TYPE_ROD, player.EQUIPMENT, item.EQUIPMENT_WEAPON) if val: chat.AppendChat( 3, "[Fishing-Bot] Removing fishing rod from main weapon") net.SendItemUsePacket(player.EQUIPMENT, item.EQUIPMENT_WEAPON) return slot = OpenLib.GetItemByType(item.ITEM_TYPE_ROD) #Check if rod is already in inventory if slot == -1: chat.AppendChat(3, "[Fishing-Bot] Rod is not in inventory") return chat.AppendChat(3, "[Fishing-Bot] Request to shop sent") NPCInteraction.RequestGiveItemNPCAwayRestorePosition( [slot], NPCInteraction.GetFishermanUpgrade(), callback=_PositionRestoreCallback, pos=self.startPosition) self.isMoving = True
def UpdateFileList(self, mode): SearchName = str(self.PickSearchItemEditLine.GetText()) SelectedIndex = self.PickfileListBox.GetSelectedItem() self.__RefreshFileList() try: lines = open(app.GetLocalePath() + "/item_list.txt", "r").readlines() except IOError: OpenLog.DebugPrint( "Load Itemlist Error, you have so set the IDs manually") self.Close() for line in lines: tokens = str(line).split("\t") Index = str(tokens[0]) try: Itemname = item.GetItemName(item.SelectItem(int(Index))) except Exception: continue if mode == 1: if Index and str(Itemname) != "": self.PickfileListBox.AppendItem( OpenLib.Item(Index + " " + Itemname)) elif mode == 2: if str(Itemname).find(str(SearchName)) != -1: self.PickfileListBox.AppendItem( OpenLib.Item(Index + " " + Itemname)) elif mode == 3: if str(Itemname) == str( SelectedIndex.GetText().split(" ")[1]): ItemValue = Index.split(" ")[0] self.CreateItemDialog.UpdateItem(int(ItemValue)) self.Close() break
def GetNextMonster(self): (closest_vid, _dist) = (0, 999999999) my_pos = player.GetMainCharacterPosition() for vid in net_packet.InstancesList: if not chr.HasInstance(vid): continue if net_packet.IsDead(vid): continue _type = chr.GetInstanceType(vid) monst_pos = chr.GetPixelPosition(vid) if self.ignoreBlockedPosition and net_packet.IsPositionBlocked( monst_pos[0], monst_pos[1]): continue if _type != OpenLib.MONSTER_TYPE: continue if OpenLib.dist(self.startPosition[0], self.startPosition[1], monst_pos[0], monst_pos[1]) > self.Range: continue this_dist = OpenLib.dist(my_pos[0], my_pos[1], monst_pos[0], monst_pos[1]) if this_dist < _dist: _dist = this_dist closest_vid = vid return closest_vid
def DoAction(self): vid = self.SearchVIDClosest() if vid: OpenLog.DebugPrint("[NPC-ACTION] - Doing NPC Action") net.SendOnClickPacket(vid) OpenLib.skipAnswers(self.event_answer) return True return False
def checkReviveAndLogin(self): val, self.timerDead = OpenLib.timeSleep(self.timerDead, self.TIME_DEAD) if not val: return if self.restartHere and player.GetStatus(player.HP) <= 0: OpenLib.Revive() if self.autoLogin and OpenLib.GetCurrentPhase() == OpenLib.PHASE_LOGIN: net.DirectEnter(0, 0)
def CheckUsePotions(self): val, self.timerPots = OpenLib.timeSleep(self.timerPots, self.TIME_POTS) if val: if self.redPotions and (float(player.GetStatus(player.HP)) / (float(player.GetStatus(player.MAX_HP))) * 100) < int(self.minHealth): OpenLib.UseAnyItemByID(self.RED_POTIONS_IDS) if self.bluePotions and (float(player.GetStatus(player.SP)) / (float(player.GetStatus(player.MAX_SP))) * 100) < int(self.minMana): OpenLib.UseAnyItemByID(self.BLUE_POTIONS_IDS)
def DoChecks(self): if self.allowShopOnFullInv and OpenLib.isInventoryFull( ) and self.CanPause(): self.GoToShop() return True return False
def PlaceFireAndGrillFish(self): slot = OpenLib.GetItemByID(self.campFire) if slot != -1: net.SendItemUsePacket(slot) self.SetState(self.STATE_PLACE_FIRE) return chat.AppendChat(3, "[Fishing-bot] You need to buy a campfire first.")
def FollowTarget_1(self): x,y = chr.GetPixelPosition(TargetVid)[:2] chr.MoveToDestPosition(player.GetMainCharacterIndex(),int(x),int(y)) self.UpdateFollow = OpenLib.WaitingDialog() self.UpdateFollow.Open(1.0) self.UpdateFollow.SAFE_SetTimeOverEvent(self.FollowTarget_1)
def CreateShop(self): if OpenLib.GetItemByID(SHOP_PACKET_ID) == -1: chat.AppendChat(3, "[Shop-Creator] You need to buy a packet first.") return self.iniItems = [] self.initItems = list(self.items_ui.keys()) blocked_slots = set() #Avoid selecting the same item twice for i in range(0, self.MAX_NUM_SLOT): idx = player.GetItemIndex(i) if idx == SHOP_PACKET_ID or idx == PREMIUM_SHOP_PACKET_ID or idx == 0: continue if i in blocked_slots: continue item.SelectItem(idx) size = item.GetItemSize() if size > 1: for ii in range(1, size): blocked_slots.add(i + ii * 5) #if ItemValue == 50300: # ItemValue = 100000 + player.GetItemMetinSocket(i, 0) #if ItemValue != 0: self.SetItemPrice(i) shop.BuildPrivateShop(self.ShopNameEditline.GetText())
def OnUpdate(self): if self.State == self.STATE_NONE or not OpenLib.IsInGamePhase(): return val, self.generalTimer = OpenLib.timeSleep(self.generalTimer, TIME_WAIT_MAP_CHANGE) if not val: return if self.State == self.STATE_MOVING: OpenLog.DebugPrint("[MAP] - State Moving") if self.currLink.GetOriginMapName( ) != background.GetCurrentMapName(): self.SetStateMapChanging() return if self.State == self.STATE_MAPCHANGING: OpenLog.DebugPrint("[MAP] - State Map Changing") self.StateMapChanging()
def OnUpdate(self): if self.STATE_STOPPED == self.State: return val, self.generalTimer = OpenLib.timeSleep(self.generalTimer, self.time_wait) if not val: return if OpenLib.GetCurrentPhase() != OpenLib.PHASE_GAME: return if self.State == self.STATE_WATING: return if not self.DoChecks(): self.Frame()
def OnUpdate(self): val, self.lastTime = OpenLib.timeSleep(self.lastTime, TIME_WAIT) if not val or self.State == STATE_NONE or not OpenLib.IsInGamePhase(): return if self.State == STATE_WAITING_OPEN_SHOP: #chat.AppendChat(3,"Waiting for shop to be open.") if shop.IsOpen(): self.State = STATE_SELLING return self.OpenShop() if self.State == STATE_SELLING: val, self.lastTimeSell = OpenLib.timeSleep(self.lastTimeSell, TIME_SELL) if val: if len(self.sellItems_list) == 0: self.State = STATE_BUYING return slot = self.sellItems_list.pop(0) net.SendShopSellPacketNew(slot, player.GetItemCount(slot), 1) chat.AppendChat(3, "[NPC-SHOPER] Sold item at slot " + str(slot)) return if self.State == STATE_BUYING: val, self.lastTimeBuy = OpenLib.timeSleep(self.lastTimeBuy, TIME_BUY) if (val): if len(self.buyItems_list) == 0: self.State = STATE_FINISH_SHOPPING return slot = self.buyItems_list.pop(0) net.SendShopBuyPacket(slot) else: return if self.State == STATE_FINISH_SHOPPING: self.EndNPCBusiness() return if self.State == STATE_GIVING_ITEMS: val, self.lastTimeGive = OpenLib.timeSleep(self.lastTimeGive, TIME_GIVE_ITEM) if not val: return if len(self.giveItems_list) == 0: self.EndNPCGiveItem() return else: vid = self.npcAction.SearchVIDClosest() if vid == None: #chat.AppendChat(3,"[NPC-GIVER] No NPC with vid " +str(vid)+" is close.") self.EndNPCGiveItem() return else: slot = self.giveItems_list.pop() #chat.AppendChat(3,"[NPC-GIVER] Giving "+ str(player.GetItemCount(slot)) + " item(s) at slot " +str(slot)+" to VID " +str(vid)) net.SendGiveItemPacket(vid, player.SLOT_TYPE_INVENTORY, slot, player.GetItemCount(slot)) OpenLib.skipAnswers(self.npcAction.event_answer)
def UpdatePickFilterList(self): searchValue = self.PickSearchItemEditLine.GetText() self.PickfileListBox.RemoveAllItems() for filterItem in sorted(self.pickFilter): item.SelectItem(filterItem) name = item.GetItemName() if searchValue in name: self.PickfileListBox.AppendItem( OpenLib.Item(str(filterItem) + " " + name))
def UpdateFileList(self): self.ListBoxItems.RemoveAllItems() for i in xrange(100): ItemIndex = player.GetItemIndex(i) if ItemIndex != 0: ItemName = item.GetItemName(item.SelectItem(int(ItemIndex))) self.ListBoxItems.AppendItem( OpenLib.Item( str(i) + ' ' + str(player.GetItemIndex(i)) + ' ' + ItemName))
def SetItemPrice(self, slot): _id = player.GetItemIndex(slot) if _id == 0: return str_price = self.items_ui[_id]['item_price'].GetText() if self.MultiplicationButton.isOn: won, yang = OpenLib.ConvertPrice(str_price, player.GetItemCount(slot)) else: won, yang = OpenLib.ConvertPrice(str_price, 1) #Ignore items with price at 0 if won + yang <= 0.9: return shop.AddPrivateShopItemStock(player.SLOT_TYPE_INVENTORY, slot, slot, yang, won)
def TeleportToDest(self, aimx, aimy): global TeleportHackMode, timerrBlock val, timerrBlock = OpenLib.timeSleep( timerrBlock, 2) #Avoid multiple calls on same keypress if val == False: return if TeleportHackMode == "Walk": chat.AppendChat(3, str(aimx) + " " + str(aimy)) Movement.GoToPositionAvoidingObjects(aimx, aimy) else: Movement.TeleportToPosition(aimx, aimy)
def OnUpdate(self): val, self.generalTimer = OpenLib.timeSleep(self.generalTimer, TIME_WAIT) if not val or not OpenLib.IsInGamePhase(): return OpenLog.DebugPrint("[MOVEMENT] - State:" + str(self.state)) if not (self.state == STATE_MOVING) or len(self.path) == 0: return next_x, next_y = self.path[0] my_x, my_y, my_z = player.GetMainCharacterPosition() maxdst = 40 if (len(self.path) == 1): maxdst = self.maxDistanceToDest if OpenLib.dist(next_x, next_y, my_x, my_y) < maxdst: self.path.pop(0) if (len(self.path) == 0): #Destination Reached self.state = STATE_FINISH if (self.callback != None): self.callback() self.callback = None self.currDestinationX = 0 self.currDestinationY = 0 return else: next_x, next_y = self.path[0] if self.lastPlayerPos == (my_x, my_y): val, self.stoppedTimer = OpenLib.timeSleep(self.stoppedTimer, TIME_STOPPED_ALLOWED) if val: #If is stuck self.path = net_packet.FindPath(my_x, my_y, self.currDestinationX, self.currDestinationY) #player.ClickSkillSlot(9) self.lastPlayerPos = (my_x, my_y) self.GoStraightToPoint(next_x, next_y)
def TeleportStraightLine(start_x, start_y, end_x, end_y, max_packets=MAX_TELEPORT_PACKETS): dst = OpenLib.dist(start_x, start_y, end_x, end_y) step = int(dst / OpenLib.MAX_TELEPORT_DIST) if step + 1 > max_packets: step = max_packets - 1 x = start_x y = start_y for i in range(0, step + 1): _x, _y = OpenLib.getPointsDistance(x, y, end_x, end_y, OpenLib.MAX_TELEPORT_DIST) net_packet.SendStatePacket(_x, _y, 0, net_packet.CHAR_STATE_STOP, 0) #chat.AppendChat(3,"Straight Line Teleporting to X->" + str(_x) + " Y->" + str(_y) + " Distance->" + str(OpenLib.dist(x,y,_x,_y))) x, y = (_x, _y) return (step + 1, (x, y))
def __init__(self): ui.ScriptWindow.__init__(self) self.Show() self.path = list() self.currDestinationX = 0 self.currDestinationY = 0 self.state = STATE_STOPPED self.stoppedTimer = OpenLib.GetTime() self.lastPlayerPos = (0, 0) self.maxDistanceToDest = 50 #self.lastMoveX,lastMoveY = (0,0) self.generalTimer = 0
def OnUpdate(self): val, self.lastTime = OpenLib.timeSleep(self.lastTime,self.speed) if(val and self.enableButton.isOn and not self.pause): if OpenLib.GetCurrentPhase() != OpenLib.PHASE_GAME: return isArch = self.IsWeaponArch() main_vid = net.GetMainActorVID() x,y,z = chr.GetPixelPosition(main_vid) self.lastPos = (x,y) lst = list() chat.AppendChat(3,str(len(net_packet.InstancesList))) for vid in net_packet.InstancesList: if vid == main_vid: continue if not chr.HasInstance(vid): continue if self.playerClose.isOn and chr.GetInstanceType(vid) == OpenLib.PLAYER_TYPE and vid != net.GetMainActorVID(): return if self.MetinButton.isOn and chr.GetInstanceType(vid) != OpenLib.METIN_TYPE: continue if player.GetCharacterDistance(vid) < self.range and not net_packet.IsDead(vid): lst.append(vid) hit_counter = 0 i = 0 while len(lst) > 0 and hit_counter < self.maxMonster: vid = lst[0] mob_x, mob_y, mob_z = chr.GetPixelPosition(vid) if net_packet.IsPositionBlocked(mob_x,mob_y): lst.remove(vid) continue #Checking the distance between teleports might increase the range and make it more stable if isArch: hit_counter+=self.AttackArch(lst,mob_x, mob_y) else: hit_counter+=self.TeleportAttack(lst,mob_x, mob_y) i+=1 Movement.TeleportStraightLine(self.lastPos[0],self.lastPos[1],x,y)
def Frame(self): if self.levelState == self.STATE_LEVELING: if self.allowLocChanger and self.CheckChangeLocation(): return monster = self.GetNextMonster() if monster != 0: OpenLib.AttackTarget(monster) elif self.goToCenter: Movement.GoToPositionAvoidingObjects(self.startPosition[0], self.startPosition[1]) elif self.levelState == self.STATE_WAIT: return
def TeleportAttack(self,lst,x,y): Movement.TeleportStraightLine(self.lastPos[0],self.lastPos[1],x,y) self.lastPos = (x,y) net_packet.SendStatePacket(x,y,0,net_packet.CHAR_STATE_STOP,0) vid_hits = 0 for vid in lst: mob_x, mob_y, mob_z = chr.GetPixelPosition(vid) if OpenLib.dist(x,y,mob_x,mob_y) < ATTACK_MAX_DIST_NO_TELEPORT: #chat.AppendChat(3,"Sent Attack, X:" + str(mob_x) + " Y:" + str(mob_y) + "VID: " +str(vid)) net_packet.SendAttackPacket(vid,0) lst.remove(vid) vid_hits+=1 return vid_hits
def PickUp(self): if self.pickUp: val, self.pickUpTimer = OpenLib.timeSleep(self.pickUpTimer, self.pickUpSpeed) if not val: return if OpenLib.GetCurrentPhase() != OpenLib.PHASE_GAME: return x, y, z = player.GetMainCharacterPosition() vid, itemX, itemY = net_packet.GetCloseItemGround(x, y) if vid == 0: return dst = OpenLib.dist(x, y, itemX, itemY) allowedRange = max(self.pickUpRange, OpenLib.MAX_PICKUP_DIST) if dst <= allowedRange: #Teleport to item if dst >= OpenLib.MAX_PICKUP_DIST: if not self.useRangePickup: return Movement.TeleportStraightLine(x, y, itemX, itemY) net_packet.SendPickupItem(vid) Movement.TeleportStraightLine(itemX, itemY, x, y) else: net_packet.SendPickupItem(vid)
def GetNpcPositionClosest(self, npc_race, curr_x, curr_y): if npc_race not in self.npcs: return None min_dist = 1999999 x_result = 0 y_result = 0 for x, y in self.npcs[npc_race]: dst = OpenLib.dist(curr_x, curr_y, x, y) if dst < min_dist: min_dist = dst x_result = x y_result = y return (x_result, y_result)
def Update(self): if self.BuffStatus: player.SetTarget(int(self.TargetVID)) if self.Cooltime == 0: self.Cooltime = time.clock() else: Time = time.clock() if self.Cooltime == -1: TimeToWait = 0 else: TimeToWait = self.Cooltime + self.BuffDelay if TimeToWait < Time: if self.Segen: if player.IsSkillCoolTime(4) == 0: player.ClickSkillSlot(4) else: self.sk1 = 1 if self.Reflekt: if player.IsSkillCoolTime(5) == 0: player.ClickSkillSlot(5) else: self.sk2 = 1 if self.HDD: if player.IsSkillCoolTime(6) == 0: player.ClickSkillSlot(6) else: self.sk3 = 1 if self.Segen != 1: self.sk1 = 1 if self.Reflekt != 1: self.sk2=1 if self.HDD != 1: self.sk3 = 1 if self.sk1 == 1 and self.sk2 == 1 and self.sk3 == 1: self.Cooltime = 0 self.sk1 = 0 self.sk2 = 0 self.sk3 = 0 else: self.TargetVID = player.GetTargetVID() self.Name.SetText(chr.GetNameByVID(self.TargetVID)) self.UpdateBuff = OpenLib.WaitingDialog() self.UpdateBuff.Open(0.5) self.UpdateBuff.SAFE_SetTimeOverEvent(self.Update)
def ReloadInv(self): del self.items_ui if OpenLib.GetItemByID(PREMIUM_SHOP_PACKET_ID) != -1: self.MAX_NUM_SLOT = self.MAX_NUM_PREMIUM_SLOT else: self.MAX_NUM_SLOT = 40 self.items_ui = dict() self.currX = self.startX self.currY = self.startY for i in range(0, self.MAX_NUM_SLOT): _id = player.GetItemIndex(i) if _id in self.items_ui or _id == 0: continue val = FileManager.ReadConfig(str(_id), FileManager.CONFIG_SHOP_CREATOR) item.SelectItem(_id) item_name = item.GetItemName() #itemIcon = item.GetIconImageFileName() #self.images.append(self.comp.ExpandedImage(self.Board, self.currX, self.currY, str(itemIcon))) if val == "": val = "0" #UI stuff self.items_ui[_id] = dict() self.items_ui[_id]['items_label'] = self.comp.TextLine( self.Board, item_name, self.currX + self.sizeEditLine + 5, self.currY, self.comp.RGB(0, 229, 650)) slot, price = self.comp.EditLine(self.Board, val, self.currX, self.currY, self.sizeEditLine, 15, 10) self.items_ui[_id]['item_price'] = price self.items_ui[_id]['item_slot'] = slot self.currY += self.stepY if (self.currY > self.endY): self.currY = self.startY self.currX += self.stepX
def GoToPositionAvoidingObjects(self, x, y, maxDist=250, callback=None): self.maxDistanceToDest = maxDist self.callback = callback if (round(x) != round(self.currDestinationX) or round(y) != round(self.currDestinationY)): my_x, my_y, z = player.GetMainCharacterPosition() self.path = net_packet.FindPath(my_x, my_y, x, y) if (len(self.path) > 0): self.currDestinationX = x self.currDestinationY = y self.state = STATE_MOVING self.stoppedTimer = OpenLib.GetTime() return MOVING else: self.state = STATE_STOPPED self.currDestinationX = 0 self.currDestinationY = 0 return NO_PATH_FOUND else: if (self.state == STATE_FINISH): self.state = STATE_STOPPED return DESTINATION_REACHED return None
def GetCurrentMapSize(): global MapBuffer ActualMapName = background.GetCurrentMapName() if ActualMapName in MapBuffer: return MapBuffer[ActualMapName] else: (bGet, iSizeX, iSizeY) = miniMap.GetAtlasSize() GetMapData = str(OpenLib.EterPackOperator("atlasinfo.txt").read()) MapData = GetMapData.split("\n") for Map in MapData: try: MapName = Map.split("\t")[0] SizeX = int(Map.split("\t")[3]) SizeY = int(Map.split("\t")[4]) if MapName == ActualMapName: if iSizeX == 0 or iSizeY == 0: iSizeX = SizeX * 43 iSizeY = SizeY * 43 break except: pass MapBuffer[ActualMapName] = (iSizeX, iSizeY, SizeX, SizeY) return (iSizeX, iSizeY, SizeX, SizeY)
def OnUpdate(self): val, self.lastTime = OpenLib.timeSleep(self.lastTime, self.TIME_WAIT) if val: if len(self.toDropSlots) > 0: slot = self.toDropSlots.pop(0) net.SendItemDropPacketNew(slot, player.GetItemCount(slot)) return if len(self.toSellSlots) > 0: slot = self.toSellSlots.pop(0) net.SendShopSellPacketNew(slot, player.GetItemCount(slot), 1) return if len(self.toStackMoveActions) > 0: args = self.toStackMoveActions.pop(0) OpenLog.DebugPrint("[STACK] - Changing item position from " + str(args[0]) + " to " + str(args[1]) + " count " + str(args[2])) net.SendItemMovePacket(args[0], args[1], args[2]) return if len(self.toSortMoveActions) > 0: args = self.toSortMoveActions.pop(0) OpenLog.DebugPrint("[SORT] - Changing item position from " + str(args[0]) + " to " + str(args[1]) + " count " + str(args[2])) net.SendItemMovePacket(args[0], args[1], args[2]) return if len(self.toBuySlots) > 0: slot = self.toBuySlots.pop(0) net.SendShopBuyPacket(slot) return if self.callback != None: self.callback() self.callback = None