Exemple #1
0
    def start(self, combatInst):
        if self.running:
            roplus.log("Bot is already running !")
            return

        if not combatInst:
            roplus.log("Error : No combat script !")
            return

        self.currentCombat = combatInst
        self.currentCombat.handleMove = True

        if not self.currentProfile:
            roplus.log("Error : No profile loaded !")
            return

        if len(self.currentProfile["hotspots"]) < 3:
            roplus.log("Error : profile require at least 3 hotspots !")
            return
            
        self.engine = fsm.Engine()
        self.engine.states.append(states.combat.Combat(self))
        self.engine.states.append(states.roaming.Roaming(self))

        self.running = True
        roplus.log("Bot started !")
Exemple #2
0
    def onDrawGuiCallback(self, args):
        if self.visible:
            if imgui.begin("Combat Assist##combatassist_mainwindo", (450,300)):
                player = BigWorld.player()

                imgui.text("Combat script : ")
                selectedChanged, self.combatSelectedIndex = imgui.combo("##combatassist_combatcombo", self.combatSelectedIndex, combats.LOADED_COMBATS.keys())
                if selectedChanged:
                    combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]
                    self.combatRotationName = combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]
                    roplus.log("Using combat script : " + self.combatRotationName)
                imgui.sameLine()
                if imgui.button("Reload##grinder_reload_scripts", (imgui.getContentRegionAvail()[0], 24)):
                    combats.reloadCombatModules()
                imgui.separator()
                if self.combatSelectedIndex == -1:
                    imgui.text("Select a combat script first ...")
                else:
                    if imgui.checkbox("Enable combat", self.rotationEnabled):
                        self.rotationEnabled = not self.rotationEnabled
                    if imgui.checkbox("Only attack in combat targets", self.combatCheck):
                        self.combatCheck = not self.combatCheck
                    if imgui.checkbox("Allow combat script to use movements", self.handleMovements):
                        self.handleMovements = not self.handleMovements
                    if imgui.checkbox("Automatically target attackers (Not implemented)", self.autoTargetEnemies):
                        self.autoTargetEnemies = not self.autoTargetEnemies
            imgui.end()
Exemple #3
0
    def onDrawGuiCallback(self, args):
        if self.visible:
            if imgui.begin("Grinder##grinder_mainwindow", (300,350)):
                player = BigWorld.player()
                imgui.columns(2)
                imgui.separator()
                imgui.text("State")
                imgui.nextColumn()
                if self.bot.running and self.bot.engine.currentState:
                    imgui.text(self.bot.engine.currentState.name)
                else:
                    imgui.text("N/A")
                imgui.nextColumn()
                imgui.text("Name")
                imgui.nextColumn()
                if player:
                    imgui.text(player.playerName)
                else:
                    imgui.text("Not ingame")
                imgui.nextColumn()
                imgui.text("Experience")
                imgui.nextColumn()
                if player:
                    exp_label = '{0} / {1}'.format(player.exp, data.avatar_lv_data.data.get(player.realLv, {}).get('upExp', '?'))
                    imgui.text(exp_label)
                else:
                    imgui.text("Not ingame")
                imgui.columns(1)
                imgui.separator()
                if not self.bot.running:
                    if imgui.button("Start##grinder_start_bot", (imgui.getContentRegionAvail()[0] / 2, 25)):
                        try:
                            combat_inst = combats.LOADED_COMBATS[combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]]
                            self.bot.start(combat_inst)
                            self.profileEditor.hide()
                        except IndexError:
                            roplus.log("Please select a combat script first !")
                    imgui.sameLine()
                    if imgui.button("Profile editor##grinder_profile_editor", (imgui.getContentRegionAvail()[0], 25)):
                        self.profileEditor.show()
                else:
                    if imgui.button("Stop##grinder_stop_bot", (imgui.getContentRegionAvail()[0], 25)):
                        self.bot.stop()

                imgui.separator()
                if imgui.button("Save settings##grinder_save_settings", (imgui.getContentRegionAvail()[0], 25)):
                    settings.saveSettings(self.bot.settings, "grinder")
                if imgui.collapsingHeader("Combats##grinder_combats_settings", 0x20):
                    selectedChanged, self.combatSelectedIndex = imgui.combo("##grinder_combatcombo", self.combatSelectedIndex, combats.LOADED_COMBATS.keys())
                    if selectedChanged:
                        self.bot.settings["lastUsedCombat"] = combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]
                        self.bot.saveSettings()
                    imgui.sameLine()
                    if imgui.button("Reload##grinder_reload_scripts", (imgui.getContentRegionAvail()[0], 24)):
                        combats.reloadCombatModules()
                        
        
            imgui.end()
Exemple #4
0
    def getQuestCompletor(self, questId):
        if questId in self.questCompletors:
            return self.questCompletors[questId]

        if questId in quests.QUEST_COMPLETORS:
            completor = quests.QUEST_COMPLETORS[questId](self, questId)
        else:
            completor = GenericQuestCompletor(self, questId)

        self.questCompletors[questId] = completor
        roplus.log("Created quest completor for [" + str(questId) + "] : " +
                   str(completor))
        return completor
 def processQuestGoal(self, goal):
     p = BigWorld.player()
     if goal.order == "compItemCollect":
         itemToBuy = self.questData.get("compItemCollect", ())[0]
         sellerNpcId = goal.trackSeekData.get("npcId", 0)
         sellerNpc = entities.findEntityByNpcId(sellerNpcId, 100)
         if sellerNpc:
             self.skipQuestGoal = True
             self.skipAutoQuest = True
             if self.moveToEntity(sellerNpc, 3):
                 bagPage, bagPos = p.inv.searchBestInPages(
                     itemToBuy, 1)  # Search best slots in bag to put item
                 sellerNpc.cell.sell(0, 0, 1, bagPage,
                                     bagPos)  # Buy item from page 0, slot 0
                 roplus.log("Buy item from " + sellerNpc.roleName)
                 self.bot.engine.wait(3)
     GenericQuestCompletor.processQuestGoal(self, goal)
Exemple #6
0
    def __init__(self):
        roplus.log('AutoLoot Loading')

        # A few defaults in case onPulse hasn't triggered yet.
        self.player = self.p = BigWorld.player()
        self.entities = {}
        self.items = []

        # Some configuration options
        self.entity_range = 100

        # And some internals
        self.last_loot_attempt_time = datetime.now()
        self.key_func = lambda e: e.__module__

        self.mainWindow = main_window.MainWindow(self)
        self.mainWindow.show()
        roplus.registerCallback('ROPlus.OnPulse', self.onPulseCallback)
        roplus.log(' ... Done')
Exemple #7
0
 def onPulseCallback(self, *args, **kw):
     # roplus.log('self: {0}'.format(self), 'args: {0}'.format(args), 'kw: {0}'.format(kw))
     grouper = itertools.groupby(sorted(self.p.entitiesInRange(self.entity_range), key=self.key_func), key=self.key_func)
     self.entities = dict((k, list(v)) for (k, v) in grouper)
     self.items = self.entities.get('DroppedItem', []) + self.entities.get('TreasureBox', [])
     # roplus.log('self.enabled_auto_loot:', self.enabled_auto_loot)
     for item in self.items:
         if not item:
             continue
         # Loot it, if we can
         item_dist = self.p.position.distTo(item.position)
         if item_dist < 4.0 and self.mainWindow.enabled_auto_loot:
             # Try looting it!
             if (datetime.now() - self.last_loot_attempt_time).total_seconds() > 1:
                 if item.__module__ == 'TreasureBox':
                     roplus.log('Opening Treasure Box: {0}'.format(item.roleName))
                     item.use()
                 elif item.__module__ == 'DroppedItem' and item._checkPickItem(self.p):
                     roplus.log('Looting Nearby Item: {0}'.format(item.roleName))
                     self.p.pickNearByItems(True)
                 self.last_loot_attempt_time = datetime.now()
Exemple #8
0
def reloadCustomQuestCompletors():
    global QUEST_COMPLETORS
    QUEST_COMPLETORS = {}
    dir_path = os.path.dirname(os.path.realpath(__file__))
    for file in os.listdir(dir_path):
        if file.endswith(".py") and not file.startswith("__"):
            filePath = os.path.join(dir_path, file)
            mod_name = file[:-3]
            if mod_name in sys.modules:
                del sys.modules[mod_name]
            try:
                mod = __import__(mod_name, globals(), locals(), [], -1)
                if mod and hasattr(mod, "QUEST_COMPLETORS"):
                    for questId, questCompletor in mod.QUEST_COMPLETORS.items():
                        roplus.log("Found custom quest completor for quest : " + str(questId))
                        QUEST_COMPLETORS[questId] = questCompletor
            except Exception as e:
                roplus.log("Unable to load file : " + str(e))
    roplus.log("Loaded " + str(len(QUEST_COMPLETORS)) + " custom quest completors")
Exemple #9
0
def reloadCombatModules():
    global LOADED_COMBATS
    LOADED_COMBATS = {}
    dir_path = roplus.getWorkingDirectory() + "\\Combats"
    for file in os.listdir(dir_path):
        if file.endswith(".py") and not file.startswith("__"):
            filePath = os.path.join(dir_path, file)
            mod_name = "Combats." + file
            try:
                combatmod = imp.load_source(mod_name, filePath)
                if combatmod and hasattr(combatmod, "Combat"):
                    try:
                        combat_inst = combatmod.Combat()
                        LOADED_COMBATS[combat_inst.name] = combat_inst
                        roplus.log("Combat script loaded : {0} ({1})".format(
                            combat_inst.name, combat_inst.author))
                    except:
                        roplus.log(
                            "Unable to create Combat() class from file : " +
                            file)
            except:
                roplus.log("Unable to load file : " + file)
Exemple #10
0
    def start(self, combatInst):
        if self.running:
            roplus.log("Bot is already running !")
            return

        if not combatInst:
            roplus.log("Error : No combat script !")
            return

        quests.reloadCustomQuestCompletors()
        self.currentQuestCompletor = None
        self.questCompletors = {}
        self.currentCombat = combatInst
        self.currentCombat.handleMove = True

        self.engine = fsm.Engine()
        self.engine.states.append(ScenarioPlaying(self))
        self.engine.states.append(CompleteQuest(self))
        self.engine.states.append(PickupNearbyQuest(self))
        self.engine.states.append(Idle(self))

        self.running = True
        roplus.log("Bot started !")
Exemple #11
0
def stderr(path_to_stderr, force=False):
    if force or getattr(sys.stderr, 'name', 'nope') != path_to_stderr:
        roplus.log('Redirecting STDERR to {0}'.format(path_to_stderr))
        sys.stderr = open(path_to_stderr, 'wb')
Exemple #12
0
def stdout(path_to_stdout, force=False):
    if force or getattr(sys.stdout, 'name', 'nope') != path_to_stdout:
        roplus.log('Redirecting STDOUT to {0}'.format(path_to_stdout))
        sys.stdout = open(path_to_stdout, 'wb')
Exemple #13
0
    def onDrawGuiCallback(self, args):
        p = BigWorld.player()
        if self.visible:
            if imgui.begin("Quester##Quester_mainwindow", (300,350)):
                imgui.columns(2)
                imgui.separator()
                imgui.text("Name")
                imgui.nextColumn()
                if p:
                    imgui.text(p.playerName)
                else:
                    imgui.text("Not ingame")
                imgui.nextColumn()
                imgui.text("Map ID")
                imgui.nextColumn()
                if p:
                    imgui.text(str(p.mapID))
                else:
                    imgui.text("Not ingame")
                imgui.nextColumn()
                imgui.text("Experience")
                imgui.nextColumn()
                if p:
                    exp_label = '{0} / {1}'.format(p.exp, data.avatar_lv_data.data.get(p.realLv, {}).get('upExp', '?'))
                    imgui.text(exp_label)
                    imgui.nextColumn()
                else:
                    imgui.text("Not ingame")
                    imgui.nextColumn()
                imgui.text("State")
                imgui.nextColumn()
                if self.bot.running and self.bot.engine.currentState:
                    imgui.text(self.bot.engine.currentState.name)
                else:
                    imgui.text("N/A")
                imgui.nextColumn()
                imgui.text("Active quest")
                imgui.nextColumn()
                if self.bot.running and self.bot.currentQuestCompletor:
                    imgui.text(str(self.bot.currentQuestCompletor.questId))
                else:
                    imgui.text("N/A")
                imgui.nextColumn()
                imgui.text("Quest state")
                imgui.nextColumn()
                if self.bot.running and self.bot.currentQuestCompletor:
                    imgui.text(self.bot.currentQuestCompletor.state)
                else:
                    imgui.text("N/A")
                imgui.nextColumn()
                imgui.columns(1)
                imgui.separator()

                if not self.bot.running:
                    if imgui.button("Start##Quester_start_bot", (imgui.getContentRegionAvail()[0], 25)):
                        try:
                            combat_inst = combats.LOADED_COMBATS[combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]]
                            self.bot.start(combat_inst)
                        except IndexError:
                            roplus.log("Please select a combat script first !")
                else:
                    if imgui.button("Stop##Quester_stop_bot", (imgui.getContentRegionAvail()[0], 25)):
                        self.bot.stop()

                imgui.separator()
                if imgui.button("Save settings##Quester_save_settings", (imgui.getContentRegionAvail()[0], 25)):
                    settings.saveSettings(self.bot.settings, "Quester")

                #
                # Combats
                #
                if imgui.collapsingHeader("Combats##Quester_combats_settings", 0x20):
                    selectedChanged, self.combatSelectedIndex = imgui.combo("##Quester_combatcombo", self.combatSelectedIndex, combats.LOADED_COMBATS.keys())
                    if selectedChanged:
                        self.bot.settings["lastUsedCombat"] = combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]
                        self.bot.saveSettings()
                    imgui.sameLine()
                    if imgui.button("Reload##Quester_reload_scripts", (imgui.getContentRegionAvail()[0], 24)):
                        combats.reloadCombatModules()

                #
                # Quest Logs
                #
                if imgui.collapsingHeader("[Debug] Quests Info##Quester_questslog"):
                    if p and p.questInfoCache:
                        for category, questIds in p.questInfoCache.items():
                            if imgui.treeNode("[{}] {}".format(str(len(questIds)), category)):
                                for questId in questIds:
                                    questDetails = p.genQuestDetail(questId, -1)
                                    questData = QuestData.data.get(questId, {})
                                    if questData and imgui.treeNode("[{}] {}".format(str(questId), questData.get("name", ""))):
                                        if questDetails and questDetails.get("taskGoal", {}) and imgui.treeNode("Quest goals ({})##questid_{}".format(str(len(questDetails["taskGoal"])), str(questId))):
                                            for i, taskGoal in enumerate(questDetails["taskGoal"]):
                                                questGoal = QuestGoal(taskGoal)
                                                if imgui.treeNode("[{0}] {1}##quest_goal_{2}_{0}".format(str(i+1), questGoal.description, str(questId))):
                                                    imgui.text("State : {}".format(str(questGoal.state)))
                                                    imgui.text("Type : {}".format(str(questGoal.type)))
                                                    imgui.text("Track Seek ID : {}".format(str(questGoal.trackSeekId)))
                                                    imgui.text("Track Task Type : {}".format(str(questGoal.trackTaskType)))
                                                    imgui.text("Order : {}".format(str(questGoal.order)))
                                                    if questGoal.trackSeekData and imgui.treeNode("Track Task data##questid_{}_{}".format(str(questId), str(i))):
                                                        for k,v in questGoal.trackSeekData.items():
                                                            imgui.text("{} -> {}".format(str(k), str(v)))
                                                        imgui.treePop()
                                                    imgui.treePop()
                                            imgui.treePop()
                                        if questData and imgui.treeNode("Quest data##questid_{}".format(str(questId))):
                                            for k,v in questData.items():
                                                imgui.text("{} -> {}".format(str(k), str(v)))
                                            imgui.treePop()
                                        if questDetails and imgui.treeNode("Quest details##questid_{}".format(str(questId))):
                                            for k,v in questDetails.items():
                                                imgui.text("{} -> {}".format(str(k), str(v)))
                                            imgui.treePop()
                                        imgui.treePop()
                                imgui.treePop()
                            #for questInfo in roplus.helpers.questing.getQuestInfosFromCache(questCategory):
                            #    if imgui.treeNode("["+questCategory+"] "+questInfo.getName()+"##" + str(questInfo.questId)):
                            #        if imgui.treeNode("-> Quest Data##" + str(questInfo.questId)):
                            #            for k,v in questInfo.questData.items():
                            #                imgui.text(str(k) + " -> " + str(v))
                            #            imgui.treePop()
                            #        if imgui.treeNode("-> Quest Details##" + str(questInfo.questId)):
                            #            for k,v in player.genQuestDetail(questInfo.questId, -1).items():
                            #                imgui.text(str(k) + " -> " + str(v))
                            #            imgui.treePop()
                            #        imgui.treePop()
        
            imgui.end()
Exemple #14
0
def silence_debug():
    if gamelog.debug.__name__ == 'debug':  # The default function name
        gamelog.debug = fake_debugger
        roplus.log('gamelog.debug silenced.')
    else:
        roplus.log('gamelog.debug was already silenced. Skipping...')
Exemple #15
0
    def onDrawGuiCallback(self, *args, **kw):
        if self.window_visable:
            try:
                if imgui.begin('AutoLoot {0} - {1}##Entity_mainwindow'.format(autoloot.__version__, autoloot.__author__), (600,350)):
                    # button bar
                    if imgui.checkbox('Enable Auto-Loot', self.enabled_auto_loot):
                        self.enabled_auto_loot = not self.enabled_auto_loot
                    
                    if imgui.collapsingHeader('Available Loot ({0} items)'.format(len(self.bot.items))):
                        imgui.columns(4)
                        for item in self.bot.items:
                            if not item:
                                continue

                            imgui.text(item.roleName)
                            imgui.nextColumn()

                            if item.__module__ == 'DroppedItem':
                                try:
                                    imgui.text('Lootable' if item._checkPickItem(self.bot.p) else 'Not Lootable')
                                except AttributeError:
                                    imgui.text('Not _checkPickItem')
                            else:
                                imgui.text('Openable?')
                            imgui.nextColumn()

                            imgui.text('{0}'.format(self.bot.p.position.distTo(item.position)))
                            imgui.nextColumn()

                            if imgui.button('Go To {0}##NavToEntity'.format(item.__module__)):
                                nav.moveToEntityPathFind(item)
                            imgui.nextColumn()
                            imgui.separator()
                        imgui.columns(1)

                    if imgui.collapsingHeader('Debug All Entities'):
                        for entity_name, entities in sorted(self.bot.entities.iteritems()):
                            for entity in entities:
                                imgui.columns(5)
                                imgui.separator()
                                imgui.text('{0}'.format(entity_name))
                                imgui.nextColumn()
                                imgui.text('{0}'.format(entity.id))
                                imgui.nextColumn()
                                if entity_name == 'DroppedItem' and hasattr(entity, '_checkPickItem') and entity._checkPickItem(self.bot.p):
                                    imgui.text('{0}'.format('Lootable'))
                                elif not entity_name == 'DroppedItem':
                                    imgui.text('No Data Available')
                                else:
                                    imgui.text('Not your Loot!')
                                imgui.nextColumn()
                                if entity and hasattr(entity, 'position') and self.bot.p and hasattr(self.bot.p, 'position'):
                                    imgui.text('{0}'.format(self.bot.p.position.distTo(entity.position)))
                                else:
                                    imgui.text('No Position Information')
                                imgui.nextColumn()
                                if imgui.button('NavToEntity##NavToEntity'):
                                    nav.moveToEntityPathFind(entity)
                                imgui.nextColumn()
                        imgui.columns(1)
                imgui.end()
            except Exception:
                import traceback
                for line in traceback.format_exc().splitlines():
                    roplus.log(line)
                self.window_visable = False
Exemple #16
0
 def stop(self):
     if not self.running:
         roplus.log("Bot is not running !")
         return
     self.running = False
     roplus.log("Bot stopped !")
Exemple #17
0
def silence_info():
    if gamelog.info.__name__ == 'info':  # The default function name
        gamelog.info = fake_debugger
        roplus.log('gamelog.info silenced.')
    else:
        roplus.log('gamelog.info was already silenced. Skipping...')
Exemple #18
0
 def __init__(self):
     roplus.log('Bot.__init__')
     self.running = False
     self.mainWindow = main_window.MainWindow(self)
     self.mainWindow.show()
     roplus.registerCallback('ROPlus.OnPulse', self.onPulseCallback)
Exemple #19
0
def silence_error():
    if gamelog.error.__name__ == 'error':  # The default function name
        gamelog.error = fake_debugger
        roplus.log('gamelog.error silenced.')
    else:
        roplus.log('gamelog.error was already silenced. Skipping...')