def create_effects(item, pos, real_z_pos, z_min): for _z in range(0, 2): _z_level = bad_numbers.clip( z_min - _z, 0, maputils.get_map_size(WORLD_INFO['map'])[2] - 1) if WORLD_INFO['map'][pos[0]][pos[1]][_z_level]: if int(round(real_z_pos)) - _z_level <= 2: if 'BLOODY' in item['flags']: if random.randint(0, 50) <= 35: effects.create_splatter('blood', [ pos[0] + random.randint(-2, 2), pos[1] + random.randint(-2, 2), _z_level ]) if 'SMOKING' in item['flags']: if random.randint(0, 50) <= 25: effects.create_smoke_streamer( [ pos[0] + random.randint(-item['size'], item['size']), pos[1] + random.randint(-item['size'], item['size']), _z_level ], item['size'] / 2, random.randint(item['size'] * 2, (item['size'] * 2) + 5)) if 'BURNING' in item['flags']: if random.randint(0, 50) <= 25: effects.create_smoke_cloud([ pos[0] + random.randint(-item['size'], item['size']), pos[1] + random.randint(-item['size'], item['size']), _z_level ], random.randint( item['size'], (item['size']) + 3), color=tcod.light_crimson) if 'max_speed' in item and is_moving(item): effects.create_vapor( item['pos'], 5, bad_numbers.clip(item['speed'] / 20, 0, 1))
def create_effects(item, pos, real_z_pos, z_min): for _z in range(0, 2): _z_level = bad_numbers.clip(z_min-_z, 0, maputils.get_map_size(WORLD_INFO['map'])[2]-1) if WORLD_INFO['map'][pos[0]][pos[1]][_z_level]: if int(round(real_z_pos))-_z_level<=2: if 'BLOODY' in item['flags']: if random.randint(0,50)<=35: effects.create_splatter('blood', [pos[0]+random.randint(-2, 2), pos[1]+random.randint(-2, 2), _z_level]) if 'SMOKING' in item['flags']: if random.randint(0, 50)<=25: effects.create_smoke_streamer([pos[0]+random.randint(-item['size'], item['size']), pos[1]+random.randint(-item['size'], item['size']), _z_level], item['size']/2, random.randint(item['size']*2, (item['size']*2)+5)) if 'BURNING' in item['flags']: if random.randint(0, 50)<=25: effects.create_smoke_cloud([pos[0]+random.randint(-item['size'], item['size']), pos[1]+random.randint(-item['size'], item['size']), _z_level], random.randint(item['size'], (item['size'])+3), color=tcod.light_crimson) if 'max_speed' in item and is_moving(item): effects.create_vapor(item['pos'], 5, bad_numbers.clip(item['speed']/20, 0, 1))
def explode(item): if not item['type'] == 'explosive': return False logging.debug('The %s (item %s) explodes!' % (item['name'], item['uid'])) #TODO: Don't breathe this! item['pos'] = get_pos(item['uid']) alife.noise.create(item['pos'], item['damage']['force']*100, 'an explosion', 'a low rumble') if item['damage']['force']: effects.create_light(item['pos'], (255, 69, 0), item['damage']['force']*6, 1, fade=3) effects.create_smoke_cloud(item['pos'], item['damage']['force']*6, age=.8, factor_distance=True) for i in range(random.randint(1, 3)): effects.create_smoke_streamer(item['pos'], 3+random.randint(0, 2), (item['damage']['force']*2)+random.randint(3, 6), color=tcod.color_lerp(tcod.gray, tcod.crimson, random.uniform(0.1, 0.3))) if SETTINGS['controlling'] and alife.sight.can_see_position(LIFE[SETTINGS['controlling']], item['pos']): gfx.message('%s explodes!' % get_name(item)) logic.show_event('%s explodes!' % get_name(item), item=item, delay=0) #elif numbers.distance( #TODO: Dirty hack for life_id in LIFE: _limbs = LIFE[life_id]['body'].keys() if not _limbs: continue _force = numbers.clip((item['damage']['force']*2)-numbers.distance(LIFE[life_id]['pos'], item['pos']), 0, 100) if not _force: continue _known_item = alife.brain.remembers_item(LIFE[life_id], item) _direction = numbers.direction_to(item['pos'], LIFE[life_id]['pos']) #TODO: Intelligent(?) limb groups? _distance = numbers.distance(LIFE[life_id]['pos'], item['pos'])/2 for i in range(_force-_distance): _limb = random.choice(_limbs) for _attached_limb in life.get_all_attached_limbs(LIFE[life_id], _limb): if _attached_limb in _limbs: _limbs.remove(_attached_limb) #_limb = random.choice(LIFE[life_id]['body'].keys()) #ex: memory(life, 'shot at by (missed)', target=item['owner'], danger=3, trust=-10) if _known_item and _known_item['last_seen_time'] < 100 and _known_item['last_owned_by']: life.memory(LIFE[life_id], 'blown_up_by', target=_known_item['last_owned_by'], trust=-10, danger=3) #for _limb in _limbs: life.add_wound(LIFE[life_id], _limb, force_velocity=numbers.velocity(_direction, _force*2)) if not _limbs: break life.push(LIFE[life_id], _direction, _force) if 'player' in LIFE[life_id]: life.say(LIFE[life_id], '@n are thrown by the explosion!', action=True) else: life.say(LIFE[life_id], '@n is thrown by the explosion!', action=True) if 'fire' in item['damage']: _circle = drawing.draw_circle(item['pos'], item['radius']) _zone = zones.get_zone_at_coords(item['pos']) if _zone: for pos in zones.dijkstra_map(item['pos'], [item['pos']], [_zone], return_score_in_range=[0, item['damage']['fire']]): if not pos in _circle: continue if not maps.position_is_in_map(pos): continue for life_id in LIFE_MAP[pos[0]][pos[1]]: for _visible_item in [get_item_from_uid(i) for i in life.get_all_visible_items(LIFE[life_id])]: if not 'CAN_BURN' in _visible_item['flags']: continue burn(_visible_item, item['damage']['fire']) if not random.randint(0, 4): effects.create_fire((pos[0], pos[1], item['pos'][2]), intensity=item['damage']['fire']/2) _dist = numbers.distance(item['pos'], pos)/2 if not random.randint(0, _dist) or not _dist: effects.create_ash(pos) if gfx.position_is_in_frame(pos): _render_pos = gfx.get_render_position(pos) gfx.refresh_view_position(_render_pos[0], _render_pos[1], 'map') #if item['uid'] in ITEMS and ITEMS[item['uid']]['owner'] and item['uid'] in LIFE[ITEMS[item['uid']]['owner']]['inventory']: delete_item(item)