示例#1
0
def judge_self(life):
    _confidence = 0
    _limb_confidence = 0

    for limb in [life["body"][limb] for limb in life["body"]]:
        # TODO: Mark as target?
        if not limb["bleeding"]:
            _limb_confidence += 1

        if not limb["bruised"]:
            _limb_confidence += 2

        if not limb["broken"]:
            _limb_confidence += 3

            # TODO: There's a chance to fake confidence here
            # If we're holding a gun, that's all the other ALifes see
            # and they judge based on that (unless they've heard you run
            # out of ammo.)
            # For now we'll consider ammo just because we can...
    _self_armed = lfe.get_held_items(life, matches=[{"type": "gun"}])

    if _self_armed:
        _weapon = lfe.get_inventory_item(life, _self_armed[0])
        _feed = weapons.get_feed(_weapon)

        if _feed and _feed["rounds"]:
            _confidence += 30
        else:
            _confidence -= 30

    return _confidence + _limb_confidence
示例#2
0
文件: combat.py 项目: flags/Reactor-3
def get_best_weapon(life):
	_weapons = lfe.get_all_inventory_items(life, matches=[{'type': 'gun'}], ignore_actions=True)
	
	_best_wep = {'weapon': None, 'feed': None, 'rounds': 0}
	for _wep in _weapons:
		_feed_rounds = 0
		_free_rounds = 0
		_feeds = lfe.get_all_inventory_items(life,
			matches=[{'type': _wep['feed'],'ammotype': _wep['ammotype']}])
		
		_loaded_feed_uid = weapons.get_feed(_wep)
		if _loaded_feed_uid:
			_loaded_feed = items.get_item_from_uid(_loaded_feed_uid)
			
			if len(_loaded_feed['rounds'])>_best_wep['rounds']:
				_best_wep['weapon'] = _wep
				_best_wep['feed'] = _loaded_feed
				_best_wep['rounds'] = len(_loaded_feed['rounds'])
				continue

		for _feed in _feeds:
			_feed_rounds = len(_feed['rounds'])
			_free_rounds = len(lfe.get_all_inventory_items(life,
				matches=[{'type': 'bullet', 'ammotype': _wep['ammotype']}]))
			
			if _feed_rounds+_free_rounds > _best_wep['rounds']:
				_best_wep['weapon'] = _wep
				_best_wep['feed'] = _feed
				_best_wep['rounds'] = _feed_rounds+_free_rounds
	
	if not _best_wep['weapon'] or not _best_wep['feed']:
		return False
	
	return _best_wep
示例#3
0
def get_best_weapon(life):
	_weapons = lfe.get_all_inventory_items(life, matches=[{'type': 'gun'}], ignore_actions=True)
	
	_best_wep = {'weapon': None, 'feed': None, 'rounds': 0}
	for _wep in _weapons:
		_feed_rounds = 0
		_free_rounds = 0
		_feeds = lfe.get_all_inventory_items(life,
			matches=[{'type': _wep['feed'],'ammotype': _wep['ammotype']}])
		
		_loaded_feed_uid = weapons.get_feed(_wep)
		if _loaded_feed_uid:
			_loaded_feed = items.get_item_from_uid(_loaded_feed_uid)
			
			if len(_loaded_feed['rounds'])>_best_wep['rounds']:
				_best_wep['weapon'] = _wep
				_best_wep['feed'] = _loaded_feed
				_best_wep['rounds'] = len(_loaded_feed['rounds'])
				continue

		for _feed in _feeds:
			_feed_rounds = len(_feed['rounds'])
			_free_rounds = len(lfe.get_all_inventory_items(life,
				matches=[{'type': 'bullet', 'ammotype': _wep['ammotype']}]))
			
			if _feed_rounds+_free_rounds > _best_wep['rounds']:
				_best_wep['weapon'] = _wep
				_best_wep['feed'] = _feed
				_best_wep['rounds'] = _feed_rounds+_free_rounds
	
	if not _best_wep['weapon'] or not _best_wep['feed']:
		return False
	
	return _best_wep
示例#4
0
def judge_self(life):
	_confidence = 0
	_limb_confidence = 0
	
	for limb in [life['body'][limb] for limb in life['body']]:
		#TODO: Mark as target?
		if not limb['bleeding']:
			_limb_confidence += 1
		
		if not limb['bruised']:
			_limb_confidence += 2
		
		if not limb['broken']:
			_limb_confidence += 3
	
	#TODO: There's a chance to fake confidence here
	#If we're holding a gun, that's all the other ALifes see
	#and they judge based on that (unless they've heard you run
	#out of ammo.)
	#For now we'll consider ammo just because we can...
	_self_armed = lfe.get_held_items(life,matches=[{'type': 'gun'}])
	
	if _self_armed:
		_weapon = lfe.get_inventory_item(life,_self_armed[0])
		_feed = weapons.get_feed(_weapon)
		
		if _feed and _feed['rounds']:
			_confidence += 30
		else:
			_confidence -= 30
	
	return _confidence+_limb_confidence
示例#5
0
文件: combat.py 项目: flags/Reactor-3
def weapon_is_working(life, item_uid):
	_weapon = ITEMS[item_uid]
	_feed_uid = weapons.get_feed(_weapon)
	
	if _feed_uid and ITEMS[_feed_uid]['rounds']:
		return True
	
	return False
示例#6
0
def weapon_is_working(life, item_uid):
    _weapon = ITEMS[item_uid]
    _feed_uid = weapons.get_feed(_weapon)

    if _feed_uid and ITEMS[_feed_uid]['rounds']:
        return True

    return False
示例#7
0
def reload_weapon(life, weapon_uid):
	_weapon = ITEMS[weapon_uid]
	_feed = _get_feed(life, _weapon)
	
	if not _feed:
		logging.error('No feed for weapon, but trying to reload anyway.')
		return False
	
	_refill = _refill_feed(life, _feed)
	if _refill:
		load_feed(life, weapon_uid, _feed['uid'])
	
	return weapons.get_feed(_weapon)
示例#8
0
def reload_weapon(life, weapon_uid):
    _weapon = ITEMS[weapon_uid]
    _feed = _get_feed(life, _weapon)

    if not _feed:
        logging.error('No feed for weapon, but trying to reload anyway.')

        return False

    _refill = _refill_feed(life, _feed)

    if _refill:
        load_feed(life, weapon_uid, _feed['uid'])

    return weapons.get_feed(_weapon)
示例#9
0
def _equip_weapon(life, weapon_uid, feed_uid):
	_weapon = ITEMS[weapon_uid]
	_feed = ITEMS[feed_uid]
	
	#TODO: Need to refill ammo?
	if not weapons.get_feed(_weapon):
		#TODO: How much time should we spend loading rounds if we're in danger?
		if _refill_feed(life, _feed):
			load_feed(life, _weapon['uid'], _feed['uid'])
	else:
		print 'should be equippan?'
		lfe.add_action(life,{'action': 'equipitem',
			'item': weapon_uid},
			300,
			delay=0)
		
		print 'Loaded!'
		return True
	
	return True
示例#10
0
def _equip_weapon(life, weapon_uid, feed_uid):
	_weapon = ITEMS[weapon_uid]
	_feed = ITEMS[feed_uid]
	
	#TODO: Need to refill ammo?
	if not weapons.get_feed(_weapon):
		#TODO: How much time should we spend loading rounds if we're in danger?
		
		if _refill_feed(life, _feed):
			load_feed(life, _weapon['uid'], _feed['uid'])
	else:
		print 'should be equippan?'
		lfe.add_action(life,{'action': 'equipitem',
			'item': weapon_uid},
			300,
			delay=0)
		
		print 'Loaded!'
		return True
	
	return True