Esempio n. 1
0
 def use_br(self, shield=False, target='', ally=''):
     if time.time() - self.last_action < 2:
         return False
     for ab in self.br_avail:
         ab = ab.strip()
         if ab in self.all_skills['battlerage']:
             entry = self.all_skills['battlerage'][ab]
             syntax = entry['syntax']
             can_use = entry['other'] and 'dmg' in entry['other']
             if shield:
                 can_use = entry['other'] and 'shld' in entry['other']
             if syntax and can_use:
                 syntax.replace("<target>", str(target))
                 syntax.replace("<ally>", str(ally))
                 sage.send(syntax)
                 self.last_action = time.time()
                 self.br_avail.remove(ab)
                 if shield:
                     return True
                 return False
         else:
             print ab
             print self.all_skills['battlerage'].keys()
             print ab in self.all_skills['battlerage'].keys()
             return False
Esempio n. 2
0
 def use_br(self, shield=False, target='', ally=''):
     if time.time() - self.last_action < 2:
         return False
     for ab in self.br_avail:
         ab = ab.strip()
         if ab in self.all_skills['battlerage']:
             entry = self.all_skills['battlerage'][ab]
             syntax = entry['syntax']
             can_use = entry['other'] and 'dmg' in entry['other']
             if shield:
                 can_use = entry['other'] and 'shld' in entry['other']
             if syntax and can_use:
                 syntax.replace("<target>", str(target))
                 syntax.replace("<ally>", str(ally))
                 sage.send(syntax)
                 self.last_action=time.time()
                 self.br_avail.remove(ab)
                 if shield:
                     return True
                 return False
         else:
             print ab
             print self.all_skills['battlerage'].keys()
             print ab in self.all_skills['battlerage'].keys()
             return False
Esempio n. 3
0
def pull_comms():
    global login_info
    global last_pull_time
    update_time = False
    db = mysql.connect(host=login_info[0], user=login_info[1],passwd=login_info[2],
            db='achaea',cursorclass=MySQLdb.cursors.DictCursor)
    cur=db.cursor()
    cur.execute('select `char`, `talker`, `channel`, `message` from achaea.messages_heard '
                ' where `time` > %s and `char` != %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        output = '%s heard %s say on %s : %s' % (res['char'],  res['talker'],
                res['channel'], res['message'])
        sage.echo(output)

    cur.execute('select `from_char`, `message` from achaea.messages_sent'
                ' where `time` > %s and `to_char` = %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        sage.echo(res['from_char'] + " said do " + res['message'])
        sage.send(res['message'])

    if(update_time):
        last_pull_time = time.time()

    cur.close()
    db.commit()
    db.close()

    if do_pull:
        sage.delay(5, pull_comms)
Esempio n. 4
0
def xplr_lode2(trigger):
    entry=[trigger.groups[1].lower(), trigger.groups[0], trigger.groups[2],
            player.room.id, player.room.area, time.time(), "Unknown"]
    explr.all_mines.append(entry)
    print player.room.id 
    print trigger.line
    sage.send('read sign')
Esempio n. 5
0
    def quest_actions(self):
        is_hindered = ('webbed' in player.afflictions
                       or 'paralyzed' in player.afflictions
                       or 'prone' in player.afflictions
                       or 'sleeping' in player.afflictions
                       or 'transfixation' in player.afflictions
                       or 'aeon' in player.afflictions
                       or 'entangled' in player.afflictions)
        has_balance = player.balance.is_on() and player.equilibrium.is_on()

        self.can_move = not is_hindered and has_balance

        items = [
            self.imap.items[iid] for iid in player.inv.keys()
            if iid in self.imap.items
        ]
        items = [
            item for item in items
            if item['quest_actions'] != '' and item['quest_actions']
            is not None and item['itemid'] not in self.unquest_items
        ]
        room_items = player.room.items.keys()
        for item in items:
            commands = item['quest_actions'].split(';')
            for command in commands:
                action = command.split(' ')[0]
                if (action == 'give' and self.can_move):
                    target = long(command.split(' ')[2])
                    if target in room_items:
                        sage.send('give %s to %s' % (item['itemid'], target))
Esempio n. 6
0
def get_miner_stats(alias):
    global minermap
    minermap = {}
    xplr_triggers('legion_list').enable()
    xplr_triggers('legion_list_over').enable()
    xplr_triggers('legion_ignore_dash').enable()
    xplr_triggers('legion_ignore_id').enable()
    sage.send('legion list')
Esempio n. 7
0
def xplr_act(alias):
    explr.roomact = ' '.join(alias.line.split()[1:])

    if explr.roomact.startswith('wait '):
        waittime = float(re.sub('wait ', '', explr.roomact.split('/')[0]))
        sage.delay(waittime, sage.send, explr.roomact.split('/')[1])
    else:
        sage.send(explr.roomact)
Esempio n. 8
0
def xplr_act(alias):
    explr.roomact = ' '.join(alias.line.split()[1:])

    if explr.roomact.startswith('wait '):
        waittime = float(re.sub('wait ','',explr.roomact.split('/')[0]))
        sage.delay(waittime,sage.send, explr.roomact.split('/')[1])
    else:
        sage.send(explr.roomact)
Esempio n. 9
0
def get_miner_stats(alias):
    global minermap
    minermap={}
    xplr_triggers('legion_list').enable()
    xplr_triggers('legion_list_over').enable()
    xplr_triggers('legion_ignore_dash').enable()
    xplr_triggers('legion_ignore_id').enable()
    sage.send('legion list')
Esempio n. 10
0
def xplr_lode2(trigger):
    entry = [
        trigger.groups[1].lower(), trigger.groups[0], trigger.groups[2],
        player.room.id, player.room.area,
        time.time(), "Unknown"
    ]
    explr.all_mines.append(entry)
    print player.room.id
    print trigger.line
    sage.send('read sign')
Esempio n. 11
0
    def advance(self):
        if not self.walk:
            self._loop.stop()
            return

        try:
            self.direction = self.path_iter.next()
            send(self.direction)
        except StopIteration:
            self._path_iter = None
            self._loop.stop()
def doSip(type):
	""" Perform sipping action """
	if player.sip.balance is False:
		return

	overwatch.last_siptype = type
	sip_group.enable()
	osys.system_echo('DEBUG: sipping ' + type + ' at ' + str(player.mana.percentage) + ' [threshold: ' + str(overwatch.mana_sipat) + ']')
	sage.send('sip ' + type)
	overwatch.currently_sipping = True
	sage.delay(12, lambda: sip_timeout())
Esempio n. 13
0
def action_loop():
    global do_loop
    if player.health.value == 0:
        sage.send('qq')
        return
    if do_loop:
        explr.on_begin()
        explr.scope_it_out()
        explr.room_actions()
        explr.quest_actions()
        explr.attacks()
        explr.other()
        #explr.on_end()
        sage.delay(0.1, action_loop)
Esempio n. 14
0
def action_loop():
    global do_loop
    if player.health.value == 0:
        sage.send('qq')
        return
    if do_loop:
        explr.on_begin()
        explr.scope_it_out()
        explr.room_actions()
        explr.quest_actions()
        explr.attacks()
        explr.other()
        #explr.on_end()
        sage.delay(0.1, action_loop)
Esempio n. 15
0
def sip(vial):
    """ Takes a sip of health or mana """

    # Don't try to sip if we are off sip balance
    if player.sip == False:
        return

    # turn on the sip group
    sip_group.enable()

    # set the balance to the wait-state
    player.sip.wait()

    # send the sip to the server
    sage.send('sip ' + vial)
Esempio n. 16
0
def deploy_miners(count, mtype):
    global minermap
    squadstr = ""
    total = 0
    for x in sorted(minermap.iteritems(), key=lambda(x, y): y['size'], reverse=True):
        valid = x[1]['type'] == 'miners' if mtype == 'miner' else x[1]['type'] != 'miners' 
        if x[1]['status'] != 'deployed' and valid:
            if x[1]['size'] < count:
                squadstr = "%s %s"%(squadstr,x[0])
                sage.echo(x[1])
                total += x[1]['size']
                count -= x[1]['size']
                sage.echo("count left: %s"%count)
    sage.echo("legion deploy squads %s"%squadstr)
    sage.send("legion deploy squads %s"%squadstr)
Esempio n. 17
0
def sip(vial):
    """ Takes a sip of health or mana """

    # Don't try to sip if we are off sip balance
    if player.sip == False:
        return

    # turn on the sip group
    sip_group.enable()

    # set the balance to the wait-state
    player.sip.wait()

    # send the sip to the server
    sage.send('sip ' + vial)
Esempio n. 18
0
def deploy_miners(count, mtype):
    global minermap
    squadstr = ""
    total = 0
    for x in sorted(minermap.iteritems(),
                    key=lambda (x, y): y['size'],
                    reverse=True):
        valid = x[1]['type'] == 'miners' if mtype == 'miner' else x[1][
            'type'] != 'miners'
        if x[1]['status'] != 'deployed' and valid:
            if x[1]['size'] < count:
                squadstr = "%s %s" % (squadstr, x[0])
                sage.echo(x[1])
                total += x[1]['size']
                count -= x[1]['size']
                sage.echo("count left: %s" % count)
    sage.echo("legion deploy squads %s" % squadstr)
    sage.send("legion deploy squads %s" % squadstr)
Esempio n. 19
0
    def room_actions(self):
        items = [self.imap.items[iid] for iid in player.room.items.keys() if iid in self.imap.items]
        is_hindered = ('webbed' in player.afflictions or 'paralyzed' in player.afflictions 
                or 'prone' in player.afflictions or 'sleeping' in player.afflictions
                or 'transfixation' in player.afflictions or 'aeon' in player.afflictions
                or 'entangled' in player.afflictions)
        has_balance = player.balance.is_on() and player.equilibrium.is_on()
        lagging = self.times['last_action'] > self.times['last_ping']
        time_since_action = time.time() - self.times['last_action']

        self.can_move = not is_hindered and has_balance 

        can_prosp = player.room.environment.lower() in ['desert','hills','mountains','polar','tundra','valley']

        if not lagging and time_since_action > 0.0:
            if self.state == State.PROSP and self.path is None:
                if player.room.id in self.mine_rooms and can_prosp:
                    sage.send('prospect')
                self.visited.add(player.room.id)
                self.path = self.map.path_to_room_in_set( player.room.id,
                    self.visited, self.mine_rooms, self.blocked)
                if self.path is None:
                    print "Done!"
                    self.all_mines = [entry for entry in 
                            self.all_mines if time.time() - entry[5] < 1800]
                    '''
                    self.visited = set([player.room.id])
                    self.path = self.map.path_to_room_in_set( player.room.id,
                        self.visited, self.mine_rooms, self.blocked)
                    '''
                self.times['last_action'] = time.time()


        if not lagging and self.can_take_stuff and time_since_action > 0.5:
            for item in items:
                if (not ('takeable' in item.keys() and 'itemid' in item.keys()
                        and 'quest_actions' in item.keys() and 'classified' in item.keys()) or
                        (item['takeable'] is None or item['itemid'] is None or item['quest_actions'] is None
                            or item['classified'] is None)):
                    print item
                    continue
                if (item['takeable'] and ((item['itemid'] not in self.took_items) or 'some gold sovereigns' in item['name'])
                        and self.can_move and ('some gold sovereigns' in item['name'] or len(item['quest_actions']) > 1 or len(item['classified']) > 1)):
                    sage.send('take %s' % item['itemid'])
                    if 'gold' in item['name']:
                        sage.send('pg')
                    self.took_items.append(item['itemid'])
                if player.room.items[item['itemid']].dead:
                    sage.send('take %s' % item['itemid'])
                    self.took_items.append(item['itemid'])
Esempio n. 20
0
def pull_comms():
    global login_info
    global last_pull_time
    update_time = False
    db = mysql.connect(host=login_info[0],
                       user=login_info[1],
                       passwd=login_info[2],
                       db='achaea',
                       cursorclass=MySQLdb.cursors.DictCursor)
    cur = db.cursor()
    cur.execute(
        'select `char`, `talker`, `channel`, `message` from achaea.messages_heard '
        ' where `time` > %s and `char` != %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        output = '%s heard %s say on %s : %s' % (
            res['char'], res['talker'], res['channel'], res['message'])
        sage.echo(output)

    cur.execute(
        'select `from_char`, `message` from achaea.messages_sent'
        ' where `time` > %s and `to_char` = %s', (last_pull_time, player.name))
    allres = cur.fetchall()
    if len(allres) > 0:
        update_time = True
    for res in allres:
        sage.echo(res['from_char'] + " said do " + res['message'])
        sage.send(res['message'])

    if (update_time):
        last_pull_time = time.time()

    cur.close()
    db.commit()
    db.close()

    if do_pull:
        sage.delay(5, pull_comms)
Esempio n. 21
0
    def quest_actions(self):
        is_hindered = ('webbed' in player.afflictions or 'paralyzed' in player.afflictions 
                or 'prone' in player.afflictions or 'sleeping' in player.afflictions
                or 'transfixation' in player.afflictions or 'aeon' in player.afflictions
                or 'entangled' in player.afflictions)
        has_balance = player.balance.is_on() and player.equilibrium.is_on()

        self.can_move = not is_hindered and has_balance 

        items = [self.imap.items[iid] for iid in player.inv.keys() if iid in self.imap.items]
        items = [item for item in items if item['quest_actions'] != ''
                    and item['quest_actions'] is not None
                    and item['itemid'] not in self.unquest_items]
        room_items = player.room.items.keys()
        for item in items:
            commands = item['quest_actions'].split(';')
            for command in commands:
                action = command.split(' ')[0]
                if(action == 'give' and self.can_move):
                    target = long(command.split(' ')[2])
                    if target in room_items:
                        sage.send('give %s to %s' % (item['itemid'], target))
Esempio n. 22
0
def update_room_contents(**kwargs):
    global track_shortnames
    if track_shortnames:
        room_triggers('ih').enable()
        room_triggers('ih_over').enable()
        sage.send('ih')
Esempio n. 23
0
 def buyElixirs(self):
     mana_count = 0
     health_count = 0
     manaClass = ['alchemist', 'apostate','magi','occultist','shaman','sylvan']
     sage.echo("Current sips: (%s, %s)"%(self.sips_health, self.sips_mana))
     if self.sips_health < 200:
         health_count = health_count + 1
     if self.sips_mana < 200:
         mana_count = mana_count + 1
     if self.vials_empty > mana_count + health_count:
         if player.combatclass in manaClass:
             cur_mana = int(self.sips_mana/200)+mana_count
             cur_health = int(self.sips_health/200)+health_count
             mana_count = max(int((self.vials_empty + cur_mana + cur_health) * .3) - cur_mana, 0)
         health_count = max(health_count,self.vials_empty - mana_count)
     sage.send('tg')
     sage.echo("Buying %s health"%health_count)
     sage.echo("Buying %s mana"%mana_count)
     for i in range(0,health_count):
         sage.send('refill empty from health')
     for i in range(0,mana_count):
         sage.send('refill empty from mana')
     self.vials_empty = 0
     vial_triggers('vial_empty').disable()
     vial_triggers('vial_stat').disable()
     sage.send('pg')
     if player.willpower.value < player.endurance.value:
         sage.send('meditate')
     else:
         sage.send('sleep')
Esempio n. 24
0
    def other(self):
        #print self.times
        idle_time = self.times['time'] - self.times['last_action']
        action_idle = self.times['time'] - self.times['last_action']
        idle_time = min(idle_time, self.times['time'] - self.times['last_room'])
        lagging = self.times['last_ping'] < self.times['last_action']
        healthy = (player.health.value > player.health.max*.99
                    and player.mana.value > player.mana.max*.9)

        if self.path is not None and len(self.path.route) < self.path.step:
            self.path = None

        #sage.echo("health status: (%s,%s,%s)"%(self.htracker.health, self.htracker.ema_health_loss, self.htracker.cur_health_loss))
        if ((self.htracker.health < 1.5* 
            max(self.htracker.ema_health_loss, self.htracker.cur_health_loss)
            and (player.health.value < player.health.max*.7)
             or self.htracker.mana < 200) and
                self.state != State.RETREAT and not healthy):
            sage.echo("Retreat!")
            self.pre_state = self.state
            self.state = State.RETREAT
            self.path = None

        if(idle_time > 10 and self.path is not None and self.state != State.REST):
            if(len(self.path.route) > self.path.step and
                    player.room.id != self.path.route[self.path.step]):
                sage.echo("Blocking room %s"
                        ", current room %s"
                        ", path: %s"%( self.path.route[self.path.step], player.room.id,self.path.route))
                self.blocked.append(self.path.route[self.path.step])
                self.visited.add(self.path.route[self.path.step])
                self.times['last_action'] = time.time()
            self.path = None

        min_will = 500
        max_will = player.willpower.max
        do_rest = ((self.state != State.REST) and
                ((player.willpower.value < (min_will+max_will/10)) 
                    or (player.endurance.value < min_will+max_will/10))
                and (player.room.id == 6838))

        if do_rest:
            sage.echo("Setting the state to be rest")
            self.path = None
            self.state = State.REST
            self.times['last_action'] = time.time()
            self.vials_empty = 0
            self.sips_health = 0
            self.sips_mana = 0
            vial_triggers('vial_empty').enable()
            vial_triggers('vial_stat').enable()
            sage.send('consolidate health')
            sage.send('consolidate mana')
            sage.send('elixsum health')
            sage.send('elixsum mana')
            sage.send('elixlist empty')
            sage.delay(1, self.buyElixirs)
            #if player.willpower.value < player.endurance.value:
            #    sage.send('meditate')
            #else:
            #    sage.send('sleep')

        end_rest = ((self.state == State.REST) and
                ((player.willpower.value >= min(max_will, player.willpower.max)) 
                    and (player.endurance.value >= min(max_will, player.endurance.max)))
                and (player.room.id == 6838))

        if end_rest:
            sage.echo("Done resting!")
            self.state = State.EXPLORE
            self.times['last_action'] = time.time()
            if(len(self.explore_area) > 0):
                self.path = self.map.path_to_area( player.room.id,
                    self.explore_area[0], self.blocked)


        go_to_rest = ((self.state != State.REST) and (self.state != State.QUEST) and
                ((player.willpower.value < min_will) or (player.endurance.value < min_will)))

        find_new_quest = ((self.state == State.QUEST) and
                ((self.path is None) or (self.path.route[-1] == player.room.id)))

        find_new_room = ((self.state == State.EXPLORE) and
                ((self.path is None) or (self.path.route[-1] == player.room.id)
                    or (idle_time > 20)) and
                len(self.explore_area) > 0)
        #print find_new_room, self.state, self.path, self.explore_area

        if (not self.leader_here and self.state == State.EXPLORE 
                and player.room.id != self.leader_room and 
                (self.path is None or self.leader_room != self.path.route[-1])):
            sage.echo("Setting path to walk to leader")
            self.path = self.map.path_to_room( player.room.id, self.leader_room, self.blocked)

        if go_to_rest:
            sage.echo("Setting the state to be quest to walk to sleepzone")
            self.state = State.QUEST
            self.path = self.map.path_to_room( player.room.id, 6838, self.blocked)
            find_new_quest = find_new_room = False

        if (self.state == State.RETREAT) and (len(self.visited_order) > 1):
            if (player.health.value > player.health.max*.9
                    and player.mana.value > player.mana.max*self.manamin):
                self.times['last_action'] = time.time()
                sage.echo("Done with retreat!")
                self.state = self.pre_state
            if ((player.room.id == self.visited_order[-1]) and (idle_time > 0.5) and
                    (len(self.to_attack) > 0) and self.path == None):
                self.visited.remove(self.visited_order[-1])
                self.visited_order.pop()
                self.path = self.map.path_to_room( player.room.id, self.visited_order[-1],
                        self.blocked)
                sage.echo("Moving to retreat room")
                sage.echo(self.path.route)


        if find_new_room:
            self.visited.add(player.room.id)
            if player.room.area == self.explore_area[0]:
                self.path = self.map.path_to_new_room( player.room.id, self.visited,
                    self.explore_area[0], self.blocked)
            else:
                self.path = self.map.path_to_area( player.room.id,
                    self.explore_area[0], self.blocked)

            if self.path is None:
                echo ("Done exploring area: %s" % self.explore_area[0])
                self.took_items = []
                self.state = State.QUEST
                self.visited = set()
                old_area = self.explore_area.pop(0)
                if self.explore_loop:
                    self.explore_area.append(old_area)

        if find_new_quest:
            items = [self.imap.items[iid] for iid in player.inv.keys() if iid in self.imap.items]
            items = [item for item in items if item['quest_actions'] != ''
                    and item['quest_actions'] is not None
                    and item['itemid'] not in self.unquest_items]
            found_quest = False
            for item in items:
                print "command: ", item['quest_actions']
                commands = item['quest_actions'].split(';')
                for command in commands:
                    action = command.split(' ')[0]
                    if(action == 'give'):
                        target = command.split(' ')[2]
                        targ_item = self.imap.items[long(target)]
                        if targ_item['lastroom'] != player.room.id:
                            self.path = self.map.path_to_room(
                                player.room.id, targ_item['lastroom'], self.blocked)
                            found_quest = True
                            if self.path is None:
                                self.unquest_items.append(item['itemid'])
                                found_quest = False
                            elif self.state == State.QUEST:
                                break
            if not found_quest and len(self.explore_area) > 0:
                self.state = State.EXPLORE
            

        #if('shop' in player.room.details):
        #    check_shop()

        if self.path is None:
            return

        if ((self.path is not None) and (player.room.id == self.path.route[-1])):
            self.visited.add(player.room.id)
            if(self.state != State.PROSP):
                if self.leader_following:
                    sage.send("follow %s"%self.leader)
                echo("We appear to be at the end of our route:"
                    "{end},{cur}".format(end=self.path.route[-1], cur=player.room.id))
                self.path = None
                return
            self.path.step = self.path.step+1
            return

        do_move = ((self.state == State.EXPLORE or self.state == State.QUEST
            or self.state == State.RETREAT or self.state == State.PROSP)
                    and idle_time > self.move_idle_wait and not lagging and self.can_move
                    and action_idle > self.action_idle_wait)
        if self.path.step >= len(self.path.route):
            self.path = None
            return

        if(player.room.id == self.path.route[self.path.step] and do_move):
            sage.send(self.path.directions[self.path.step])
            self.last_move = self.path.directions[self.path.step]
            self.path.step = self.path.step+1
            #self.times['last_action'] = self.times['time']
            self.times['last_move'] = self.times['time']
Esempio n. 25
0
    def attacks(self):
        is_hindered = ('webbed' in player.afflictions
                       or 'paralyzed' in player.afflictions
                       or 'prone' in player.afflictions
                       or 'sleeping' in player.afflictions
                       or 'transfixation' in player.afflictions
                       or 'aeon' in player.afflictions
                       or 'entangled' in player.afflictions)
        has_balance = player.balance.is_on() and player.equilibrium.is_on()

        self.can_move = not is_hindered and has_balance

        items = [
            self.imap.items[iid] for iid in player.room.items.keys()
            if iid in self.imap.items
        ]
        to_attack = []
        for item in items:
            if 'classified' in item:
                if item['classified'] and 'kill' in item['classified']:
                    to_attack.append(item)
            else:
                print 'item not classified'

        to_attack = [
            item for item in items
            if item['classified'] and 'kill' in item['classified']
        ]
        lagging = self.times['last_action'] > self.times['last_ping']
        self.to_attack = to_attack

        if self.leader_following:
            #### Get the leader's location
            db = mysql.connect(host=self.login[0],
                               user=self.login[1],
                               passwd=self.login[2],
                               db='achaea',
                               cursorclass=MySQLdb.cursors.DictCursor)
            cur = db.cursor()
            cur.execute(
                "select ally,roomid from achaea.allies where `leader`=1")
            allres = cur.fetchall()
            if allres is not None and len(allres) == 1:
                leader = allres[0]['ally'].lower()
                self.leader_room = long(allres[0]['roomid'])
                if (leader != self.leader):
                    sage.echo("Changing leader from %s to %s" %
                              (self.leader, leader))
                    self.leader = leader
            cur.close()
            db.commit()
            db.close()

            others_here = [p.lower() for p in player.room.players]

            if self.leader_here and self.path is not None and self.can_move and self.state == State.EXPLORE:
                sage.send('follow %s' % self.leader)
                self.path = None
                self.leader_here = self.leader in others_here

        if (len(to_attack) == 0 or self.canAttack == False or lagging
                or self.state == State.QUEST or self.state == State.RETREAT
                or self.state == State.PROSP or not self.leader_here):
            return

        if not self.cur_target or self.cur_target not in player.room.items.keys(
        ):
            self.cur_target = to_attack[0]['itemid']
            sage.send('st %s' % self.cur_target)

        from skills.skills import smap
        if smap.use_br(target=self.cur_target, shield=self.break_shield):
            self.break_shield = False

        if has_balance and not is_hindered and self.killon:
            #if(player.combatclass.lower() == 'shaman') and (smap.swiftcurses < 2):
            #    sage.send('swiftcurse')
            #elif (player.combatclass.lower() == 'shaman'):
            #    sage.send('swiftcurse %s bleed' % self.cur_target)
            #el
            if (player.combatclass.lower() == 'shaman'):
                sage.send('invoke roar %s' % self.cur_target)
            elif (player.combatclass.lower() == 'magi'
                  and player.mana.value < player.mana.max * self.manamin):
                sage.send('punch %s' % self.cur_target)
            else:
                sage.send('kill %s' % self.cur_target)
            self.times['last_action'] = time.time()
Esempio n. 26
0
    def scope_it_out(self):
        if not self.do_scope:
            return

        if player.room is not None and player.room.id is not None and player.name is not None:
            db = mysql.connect(host=self.login[0], user=self.login[1],passwd=self.login[2],
                    db='achaea',cursorclass=MySQLdb.cursors.DictCursor)
            cur=db.cursor()
            cur.execute("INSERT into achaea.allies (`ally`,`roomid`) VALUES (%s,%s)"
                    " ON DUPLICATE KEY UPDATE ally=ally, roomid=values(roomid) ",
                    (player.name, player.room.id))
            cur.execute("select ally,roomid from achaea.allies where `leader`=1")
            allres = cur.fetchall()
            if allres is not None and len(allres) == 1:
                leader=allres[0]['ally'].lower()
                self.leader_room=long(allres[0]['roomid'])
                if(leader != self.leader):
                    sage.echo("Changing leader from %s to %s"%(self.leader, leader))
                    self.leader = leader
            cur.close()
            db.commit()
            db.close()

        self.do_scope=False
        just_entered = False

        if (player.room.id != self.cur_room) or (time.time() - self.times['entered'] < 0.5):
            self.cur_room = player.room.id
            just_entered = True
            self.times['entered'] = time.time()
            if(self.roomact is not None):
                if self.roomact.startswith('wait '):
                    waittime = float(re.sub('wait ','',self.roomact.split('/')[0]))
                    sage.delay(waittime,sage.send, self.roomact.split('/')[1])
                else:
                    sage.send(self.roomact)
        just_entered = just_entered and (self.times['last_room'] > self.times['last_scope'])

        others_here = [p.lower() for p in player.room.players]
        allies_here = list(set(others_here) & set(self.allies))
        others_here = list(set(others_here) - set(self.allies))

        if self.leader_following:
            self.leader_here = self.leader in others_here or self.leader in allies_here
        else:
            self.leader_here = True

        room_dps = len([iid for iid,item in player.room.items.iteritems() if item.denizen])

        if just_entered:
            #print 'just entered'
            self.canAttack = True

        if just_entered and len(others_here) != 0:
            print 'people here'
            self.canAttack = False
            self.can_take_stuff = False
        elif just_entered:
            self.can_take_stuff = not self.block_can_take_stuff

        if room_dps > self.my_hps * (1 + len(self.allies)):
            print 'dps too high'
            self.canAttack = False
        self.times['last_scope'] = self.times['time']
Esempio n. 27
0
    def room_actions(self):
        items = [
            self.imap.items[iid] for iid in player.room.items.keys()
            if iid in self.imap.items
        ]
        is_hindered = ('webbed' in player.afflictions
                       or 'paralyzed' in player.afflictions
                       or 'prone' in player.afflictions
                       or 'sleeping' in player.afflictions
                       or 'transfixation' in player.afflictions
                       or 'aeon' in player.afflictions
                       or 'entangled' in player.afflictions)
        has_balance = player.balance.is_on() and player.equilibrium.is_on()
        lagging = self.times['last_action'] > self.times['last_ping']
        time_since_action = time.time() - self.times['last_action']

        self.can_move = not is_hindered and has_balance

        can_prosp = player.room.environment.lower() in [
            'desert', 'hills', 'mountains', 'polar', 'tundra', 'valley'
        ]

        if not lagging and time_since_action > 0.0:
            if self.state == State.PROSP and self.path is None:
                if player.room.id in self.mine_rooms and can_prosp:
                    sage.send('prospect')
                self.visited.add(player.room.id)
                self.path = self.map.path_to_room_in_set(
                    player.room.id, self.visited, self.mine_rooms,
                    self.blocked)
                if self.path is None:
                    print "Done!"
                    self.all_mines = [
                        entry for entry in self.all_mines
                        if time.time() - entry[5] < 1800
                    ]
                    '''
                    self.visited = set([player.room.id])
                    self.path = self.map.path_to_room_in_set( player.room.id,
                        self.visited, self.mine_rooms, self.blocked)
                    '''
                self.times['last_action'] = time.time()

        if not lagging and self.can_take_stuff and time_since_action > 0.5:
            for item in items:
                if (not ('takeable' in item.keys() and 'itemid' in item.keys()
                         and 'quest_actions' in item.keys()
                         and 'classified' in item.keys())
                        or (item['takeable'] is None or item['itemid'] is None
                            or item['quest_actions'] is None
                            or item['classified'] is None)):
                    print item
                    continue
                if (item['takeable']
                        and ((item['itemid'] not in self.took_items)
                             or 'some gold sovereigns' in item['name'])
                        and self.can_move
                        and ('some gold sovereigns' in item['name']
                             or len(item['quest_actions']) > 1
                             or len(item['classified']) > 1)):
                    sage.send('take %s' % item['itemid'])
                    if 'gold' in item['name']:
                        sage.send('pg')
                    self.took_items.append(item['itemid'])
                if player.room.items[item['itemid']].dead:
                    sage.send('take %s' % item['itemid'])
                    self.took_items.append(item['itemid'])
Esempio n. 28
0
    def scope_it_out(self):
        if not self.do_scope:
            return

        if player.room is not None and player.room.id is not None and player.name is not None:
            db = mysql.connect(host=self.login[0],
                               user=self.login[1],
                               passwd=self.login[2],
                               db='achaea',
                               cursorclass=MySQLdb.cursors.DictCursor)
            cur = db.cursor()
            cur.execute(
                "INSERT into achaea.allies (`ally`,`roomid`) VALUES (%s,%s)"
                " ON DUPLICATE KEY UPDATE ally=ally, roomid=values(roomid) ",
                (player.name, player.room.id))
            cur.execute(
                "select ally,roomid from achaea.allies where `leader`=1")
            allres = cur.fetchall()
            if allres is not None and len(allres) == 1:
                leader = allres[0]['ally'].lower()
                self.leader_room = long(allres[0]['roomid'])
                if (leader != self.leader):
                    sage.echo("Changing leader from %s to %s" %
                              (self.leader, leader))
                    self.leader = leader
            cur.close()
            db.commit()
            db.close()

        self.do_scope = False
        just_entered = False

        if (player.room.id !=
                self.cur_room) or (time.time() - self.times['entered'] < 0.5):
            self.cur_room = player.room.id
            just_entered = True
            self.times['entered'] = time.time()
            if (self.roomact is not None):
                if self.roomact.startswith('wait '):
                    waittime = float(
                        re.sub('wait ', '',
                               self.roomact.split('/')[0]))
                    sage.delay(waittime, sage.send, self.roomact.split('/')[1])
                else:
                    sage.send(self.roomact)
        just_entered = just_entered and (self.times['last_room'] >
                                         self.times['last_scope'])

        others_here = [p.lower() for p in player.room.players]
        allies_here = list(set(others_here) & set(self.allies))
        others_here = list(set(others_here) - set(self.allies))

        if self.leader_following:
            self.leader_here = self.leader in others_here or self.leader in allies_here
        else:
            self.leader_here = True

        room_dps = len([
            iid for iid, item in player.room.items.iteritems() if item.denizen
        ])

        if just_entered:
            #print 'just entered'
            self.canAttack = True

        if just_entered and len(others_here) != 0:
            print 'people here'
            self.canAttack = False
            self.can_take_stuff = False
        elif just_entered:
            self.can_take_stuff = not self.block_can_take_stuff

        if room_dps > self.my_hps * (1 + len(self.allies)):
            print 'dps too high'
            self.canAttack = False
        self.times['last_scope'] = self.times['time']
Esempio n. 29
0
    def other(self):
        #print self.times
        idle_time = self.times['time'] - self.times['last_action']
        action_idle = self.times['time'] - self.times['last_action']
        idle_time = min(idle_time,
                        self.times['time'] - self.times['last_room'])
        lagging = self.times['last_ping'] < self.times['last_action']
        healthy = (player.health.value > player.health.max * .99
                   and player.mana.value > player.mana.max * .9)

        if self.path is not None and len(self.path.route) < self.path.step:
            self.path = None

        #sage.echo("health status: (%s,%s,%s)"%(self.htracker.health, self.htracker.ema_health_loss, self.htracker.cur_health_loss))
        if ((self.htracker.health < 1.5 *
             max(self.htracker.ema_health_loss, self.htracker.cur_health_loss)
             and (player.health.value < player.health.max * .7)
             or self.htracker.mana < 200) and self.state != State.RETREAT
                and not healthy):
            sage.echo("Retreat!")
            self.pre_state = self.state
            self.state = State.RETREAT
            self.path = None

        if (idle_time > 10 and self.path is not None
                and self.state != State.REST):
            if (len(self.path.route) > self.path.step
                    and player.room.id != self.path.route[self.path.step]):
                sage.echo("Blocking room %s"
                          ", current room %s"
                          ", path: %s" % (self.path.route[self.path.step],
                                          player.room.id, self.path.route))
                self.blocked.append(self.path.route[self.path.step])
                self.visited.add(self.path.route[self.path.step])
                self.times['last_action'] = time.time()
            self.path = None

        min_will = 500
        max_will = player.willpower.max
        do_rest = ((self.state != State.REST)
                   and ((player.willpower.value <
                         (min_will + max_will / 10)) or
                        (player.endurance.value < min_will + max_will / 10))
                   and (player.room.id == 6838))

        if do_rest:
            sage.echo("Setting the state to be rest")
            self.path = None
            self.state = State.REST
            self.times['last_action'] = time.time()
            self.vials_empty = 0
            self.sips_health = 0
            self.sips_mana = 0
            vial_triggers('vial_empty').enable()
            vial_triggers('vial_stat').enable()
            sage.send('consolidate health')
            sage.send('consolidate mana')
            sage.send('elixsum health')
            sage.send('elixsum mana')
            sage.send('elixlist empty')
            sage.delay(1, self.buyElixirs)
            #if player.willpower.value < player.endurance.value:
            #    sage.send('meditate')
            #else:
            #    sage.send('sleep')

        end_rest = ((self.state == State.REST) and (
            (player.willpower.value >= min(max_will, player.willpower.max)) and
            (player.endurance.value >= min(max_will, player.endurance.max)))
                    and (player.room.id == 6838))

        if end_rest:
            sage.echo("Done resting!")
            self.state = State.EXPLORE
            self.times['last_action'] = time.time()
            if (len(self.explore_area) > 0):
                self.path = self.map.path_to_area(player.room.id,
                                                  self.explore_area[0],
                                                  self.blocked)

        go_to_rest = ((self.state != State.REST)
                      and (self.state != State.QUEST)
                      and ((player.willpower.value < min_will) or
                           (player.endurance.value < min_will)))

        find_new_quest = ((self.state == State.QUEST)
                          and ((self.path is None) or
                               (self.path.route[-1] == player.room.id)))

        find_new_room = ((self.state == State.EXPLORE)
                         and ((self.path is None) or
                              (self.path.route[-1] == player.room.id) or
                              (idle_time > 20)) and len(self.explore_area) > 0)
        #print find_new_room, self.state, self.path, self.explore_area

        if (not self.leader_here and self.state == State.EXPLORE
                and player.room.id != self.leader_room and
            (self.path is None or self.leader_room != self.path.route[-1])):
            sage.echo("Setting path to walk to leader")
            self.path = self.map.path_to_room(player.room.id, self.leader_room,
                                              self.blocked)

        if go_to_rest:
            sage.echo("Setting the state to be quest to walk to sleepzone")
            self.state = State.QUEST
            self.path = self.map.path_to_room(player.room.id, 6838,
                                              self.blocked)
            find_new_quest = find_new_room = False

        if (self.state == State.RETREAT) and (len(self.visited_order) > 1):
            if (player.health.value > player.health.max * .9
                    and player.mana.value > player.mana.max * self.manamin):
                self.times['last_action'] = time.time()
                sage.echo("Done with retreat!")
                self.state = self.pre_state
            if ((player.room.id == self.visited_order[-1])
                    and (idle_time > 0.5) and (len(self.to_attack) > 0)
                    and self.path == None):
                self.visited.remove(self.visited_order[-1])
                self.visited_order.pop()
                self.path = self.map.path_to_room(player.room.id,
                                                  self.visited_order[-1],
                                                  self.blocked)
                sage.echo("Moving to retreat room")
                sage.echo(self.path.route)

        if find_new_room:
            self.visited.add(player.room.id)
            if player.room.area == self.explore_area[0]:
                self.path = self.map.path_to_new_room(player.room.id,
                                                      self.visited,
                                                      self.explore_area[0],
                                                      self.blocked)
            else:
                self.path = self.map.path_to_area(player.room.id,
                                                  self.explore_area[0],
                                                  self.blocked)

            if self.path is None:
                echo("Done exploring area: %s" % self.explore_area[0])
                self.took_items = []
                self.state = State.QUEST
                self.visited = set()
                old_area = self.explore_area.pop(0)
                if self.explore_loop:
                    self.explore_area.append(old_area)

        if find_new_quest:
            items = [
                self.imap.items[iid] for iid in player.inv.keys()
                if iid in self.imap.items
            ]
            items = [
                item for item in items
                if item['quest_actions'] != '' and item['quest_actions']
                is not None and item['itemid'] not in self.unquest_items
            ]
            found_quest = False
            for item in items:
                print "command: ", item['quest_actions']
                commands = item['quest_actions'].split(';')
                for command in commands:
                    action = command.split(' ')[0]
                    if (action == 'give'):
                        target = command.split(' ')[2]
                        targ_item = self.imap.items[long(target)]
                        if targ_item['lastroom'] != player.room.id:
                            self.path = self.map.path_to_room(
                                player.room.id, targ_item['lastroom'],
                                self.blocked)
                            found_quest = True
                            if self.path is None:
                                self.unquest_items.append(item['itemid'])
                                found_quest = False
                            elif self.state == State.QUEST:
                                break
            if not found_quest and len(self.explore_area) > 0:
                self.state = State.EXPLORE

        #if('shop' in player.room.details):
        #    check_shop()

        if self.path is None:
            return

        if ((self.path is not None)
                and (player.room.id == self.path.route[-1])):
            self.visited.add(player.room.id)
            if (self.state != State.PROSP):
                if self.leader_following:
                    sage.send("follow %s" % self.leader)
                echo("We appear to be at the end of our route:"
                     "{end},{cur}".format(end=self.path.route[-1],
                                          cur=player.room.id))
                self.path = None
                return
            self.path.step = self.path.step + 1
            return

        do_move = ((self.state == State.EXPLORE or self.state == State.QUEST or
                    self.state == State.RETREAT or self.state == State.PROSP)
                   and idle_time > self.move_idle_wait and not lagging
                   and self.can_move and action_idle > self.action_idle_wait)
        if self.path.step >= len(self.path.route):
            self.path = None
            return

        if (player.room.id == self.path.route[self.path.step] and do_move):
            sage.send(self.path.directions[self.path.step])
            self.last_move = self.path.directions[self.path.step]
            self.path.step = self.path.step + 1
            #self.times['last_action'] = self.times['time']
            self.times['last_move'] = self.times['time']
Esempio n. 30
0
 def buyElixirs(self):
     mana_count = 0
     health_count = 0
     manaClass = [
         'alchemist', 'apostate', 'magi', 'occultist', 'shaman', 'sylvan'
     ]
     sage.echo("Current sips: (%s, %s)" %
               (self.sips_health, self.sips_mana))
     if self.sips_health < 200:
         health_count = health_count + 1
     if self.sips_mana < 200:
         mana_count = mana_count + 1
     if self.vials_empty > mana_count + health_count:
         if player.combatclass in manaClass:
             cur_mana = int(self.sips_mana / 200) + mana_count
             cur_health = int(self.sips_health / 200) + health_count
             mana_count = max(
                 int((self.vials_empty + cur_mana + cur_health) * .3) -
                 cur_mana, 0)
         health_count = max(health_count, self.vials_empty - mana_count)
     sage.send('tg')
     sage.echo("Buying %s health" % health_count)
     sage.echo("Buying %s mana" % mana_count)
     for i in range(0, health_count):
         sage.send('refill empty from health')
     for i in range(0, mana_count):
         sage.send('refill empty from mana')
     self.vials_empty = 0
     vial_triggers('vial_empty').disable()
     vial_triggers('vial_stat').disable()
     sage.send('pg')
     if player.willpower.value < player.endurance.value:
         sage.send('meditate')
     else:
         sage.send('sleep')
Esempio n. 31
0
def xplr_ally(alias):
    explr.times['last_action'] = time.time()
    query = alias.line.split()[2].lower()
    explr.allies.append(query)
    sage.send('ally %s' % query)
Esempio n. 32
0
    def attacks(self):
        is_hindered = ('webbed' in player.afflictions or 'paralyzed' in player.afflictions 
                or 'prone' in player.afflictions or 'sleeping' in player.afflictions
                or 'transfixation' in player.afflictions or 'aeon' in player.afflictions
                or 'entangled' in player.afflictions)
        has_balance = player.balance.is_on() and player.equilibrium.is_on()

        self.can_move = not is_hindered and has_balance 

        items = [self.imap.items[iid] for iid in player.room.items.keys() if iid in self.imap.items]
        to_attack = []
        for item in items:
            if 'classified' in item:
                if item['classified'] and 'kill' in item['classified']:
                    to_attack.append(item)
            else:
                print 'item not classified'

        to_attack = [item for item in items if item['classified'] and 'kill' in item['classified']]
        lagging = self.times['last_action'] > self.times['last_ping']
        self.to_attack = to_attack

        if self.leader_following:
            #### Get the leader's location
            db = mysql.connect(host=self.login[0], user=self.login[1],passwd=self.login[2],
                    db='achaea',cursorclass=MySQLdb.cursors.DictCursor)
            cur=db.cursor()
            cur.execute("select ally,roomid from achaea.allies where `leader`=1")
            allres = cur.fetchall()
            if allres is not None and len(allres) == 1:
                leader=allres[0]['ally'].lower()
                self.leader_room=long(allres[0]['roomid'])
                if(leader != self.leader):
                    sage.echo("Changing leader from %s to %s"%(self.leader, leader))
                    self.leader = leader
            cur.close()
            db.commit()
            db.close()

            others_here = [p.lower() for p in player.room.players]

            if self.leader_here and self.path is not None and self.can_move and self.state == State.EXPLORE:
                sage.send('follow %s'%self.leader)
                self.path = None
                self.leader_here = self.leader in others_here

        if (len(to_attack) == 0 or self.canAttack == False or lagging or self.state == State.QUEST
                or self.state == State.RETREAT or self.state == State.PROSP or not self.leader_here):
            return

        if not self.cur_target or self.cur_target not in player.room.items.keys():
            self.cur_target = to_attack[0]['itemid']
            sage.send('st %s' % self.cur_target)

        from skills.skills import smap
        if smap.use_br(target=self.cur_target, shield=self.break_shield):
            self.break_shield = False

        if has_balance and not is_hindered and self.killon:
            #if(player.combatclass.lower() == 'shaman') and (smap.swiftcurses < 2):
            #    sage.send('swiftcurse')
            #elif (player.combatclass.lower() == 'shaman'):
            #    sage.send('swiftcurse %s bleed' % self.cur_target)
            #el
            if (player.combatclass.lower() == 'shaman'):
                sage.send('invoke roar %s' % self.cur_target)
            elif (player.combatclass.lower() == 'magi' and 
                     player.mana.value < player.mana.max*self.manamin):
                sage.send('punch %s' % self.cur_target)
            else:
                sage.send('kill %s' % self.cur_target)
            self.times['last_action'] = time.time()
Esempio n. 33
0
def xplr_ally(alias):
    explr.times['last_action'] = time.time()
    query = alias.line.split()[2].lower()
    explr.allies.append(query)
    sage.send('ally %s' %query)
Esempio n. 34
0
def update_room_contents(**kwargs):
    global track_shortnames
    if track_shortnames:
        room_triggers('ih').enable()
        room_triggers('ih_over').enable()
        sage.send('ih')