def declare_group_target(life, target_id, alignment): change_alignment(life, target_id, alignment) groups.announce(life, life['group'], 'add_group_target', target_id=target_id)
def react_to_attack(life, life_id): _knows = brain.knows_alife_by_id(life, life_id) if not _knows['alignment'] == 'hostile': speech.start_dialog(life, _knows['life']['id'], 'establish_hostile') if life['group']: groups.announce(life, life['group'], 'attacked_by_hostile', target_id=_knows['life']['id'])
def react_to_attack(life, life_id): _knows = brain.knows_alife_by_id(life, life_id) if not _knows['alignment'] == 'hostile': speech.start_dialog(life, _knows['life']['id'], 'establish_hostile') if life['group']: groups.announce(life, life['group'], 'attacked_by_hostile', target_id=_knows['life']['id'], filter_if=lambda life_id: brain.knows_alife_by_id(life, life_id)['last_seen_time']<=30, ignore_if_said_in_last=150)
def react_to_attack(life, life_id): _knows = brain.knows_alife_by_id(life, life_id) if not _knows['alignment'] == 'hostile': speech.start_dialog(life, _knows['life']['id'], 'establish_hostile') if life['group']: groups.announce(life, life['group'], 'attacked_by_hostile', target_id=_knows['life']['id'], filter_if=lambda life_id: brain.knows_alife_by_id( life, life_id)['last_seen_time'] <= 30, ignore_if_said_in_last=150)
def react_to_tension(life, life_id): if brain.knows_alife_by_id(life, life_id)['alignment'] in ['hostile']: return False if life['group'] and not groups.is_leader( life, life['group'], life['id']) and groups.get_leader( life, life['group']): if sight.can_see_target(life, groups.get_leader( life, life['group'])) and sight.can_see_target( LIFE[life_id], groups.get_leader(life, life['group'])): return False _disarm = brain.get_alife_flag(life, life_id, 'disarm') if _disarm: #For now... if not sight.can_see_position(life, LIFE[life_id]['pos']): groups.announce(life, life['group'], 'attacked_by_hostile', filter_if=lambda life_id: brain.knows_alife_by_id( life, life_id)['last_seen_time'] <= 30, target_id=life_id) return False for item_uid in lfe.get_all_visible_items(LIFE[life_id]): if ITEMS[item_uid]['type'] == 'gun': break else: brain.unflag_alife(life, life_id, 'disarm') speech.start_dialog(life, life_id, 'clear_drop_weapon') return False _time_elapsed = WORLD_INFO['ticks'] - _disarm if _time_elapsed > 135 and not speech.has_sent(life, life_id, 'threaten'): speech.start_dialog(life, life_id, 'threaten') speech.send(life, life_id, 'threaten') elif _time_elapsed > 185: speech.start_dialog(life, life_id, 'establish_hostile') elif not speech.has_sent(life, life_id, 'confront'): speech.start_dialog(life, life_id, 'confront') speech.send(life, life_id, 'confront')
def react_to_tension(life, life_id): if brain.knows_alife_by_id(life, life_id)['alignment'] in ['hostile']: return False if life['group'] and not groups.is_leader(life, life['group'], life['id']) and groups.get_leader(life, life['group']): if sight.can_see_target(life, groups.get_leader(life, life['group'])) and sight.can_see_target(LIFE[life_id], groups.get_leader(life, life['group'])): return False _disarm = brain.get_alife_flag(life, life_id, 'disarm') if _disarm: #For now... if not sight.can_see_position(life, LIFE[life_id]['pos']): groups.announce(life, life['group'], 'attacked_by_hostile', filter_if=lambda life_id: brain.knows_alife_by_id(life, life_id)['last_seen_time']<=30, target_id=life_id) return False for item_uid in lfe.get_all_visible_items(LIFE[life_id]): if ITEMS[item_uid]['type'] == 'gun': break else: brain.unflag_alife(life, life_id, 'disarm') speech.start_dialog(life, life_id, 'clear_drop_weapon') return False _time_elapsed = WORLD_INFO['ticks']-_disarm if _time_elapsed>135 and not speech.has_sent(life, life_id, 'threaten'): speech.start_dialog(life, life_id, 'threaten') speech.send(life, life_id, 'threaten') elif _time_elapsed>185: speech.start_dialog(life, life_id, 'establish_hostile') elif not speech.has_sent(life, life_id, 'confront'): speech.start_dialog(life, life_id, 'confront') speech.send(life, life_id, 'confront')
def announce_combat_to_group(life, group_id): _number_of_members = len(groups.get_group(life, group_id)['members']) if _number_of_members >= 5: groups.announce(life, group_id, 'group_prepare_for_combat_large') elif _number_of_members > 2: groups.announce(life, group_id, 'group_prepare_for_combat_small') else: groups.announce(life, group_id, 'group_prepare_for_combat_partner')
def announce_combat_to_group(life, group_id): _number_of_members = len(groups.get_group(life, group_id)['members']) if _number_of_members>=5: groups.announce(life, group_id, 'group_prepare_for_combat_large') elif _number_of_members>2: groups.announce(life, group_id, 'group_prepare_for_combat_small') else: groups.announce(life, group_id, 'group_prepare_for_combat_partner')