def delete_fire(fire): tiles.flag(WORLD_INFO['map'][fire['pos'][0]][fire['pos'][1]][fire['pos'][2]], 'heat', False) tiles.flag(WORLD_INFO['map'][fire['pos'][0]][fire['pos'][1]][fire['pos'][2]], 'burnt', True) create_ash(fire['pos']) if 'light' in fire: delete_light(fire['light'])
def delete_fire(fire): tiles.flag( WORLD_INFO['map'][fire['pos'][0]][fire['pos'][1]][fire['pos'][2]], 'heat', False) tiles.flag( WORLD_INFO['map'][fire['pos'][0]][fire['pos'][1]][fire['pos'][2]], 'burnt', True) create_ash(fire['pos']) if 'light' in fire: delete_light(fire['light'])
def calculate_fire(fire): _neighbor_intensity = 0 _neighbor_lit = False for x in range(-1, 2): _x = fire['pos'][0]+x if _x<0 or _x>=MAP_SIZE[0]: continue for y in range(-1, 2): if not x and not y: continue _y = fire['pos'][1]+y if _y<0 or _y>=MAP_SIZE[1]: continue _effects = [EFFECTS[eid] for eid in EFFECT_MAP[_x][_y] if EFFECTS[eid]['type'] == 'fire'] for effect in _effects: _neighbor_intensity += effect['intensity'] if 'light' in effect: _neighbor_lit = True if not _effects: _tile = WORLD_INFO['map'][_x][_y][fire['pos'][2]] _raw_tile = tiles.get_raw_tile(_tile) _heat = tiles.get_flag(WORLD_INFO['map'][_x][_y][fire['pos'][2]], 'heat') _current_burn = int(round(fire['intensity'])) _max_burn = int(round(_current_burn*.23)) if tiles.flag(_tile, 'heat', numbers.clip(_heat+(fire['intensity']*.01), 0, 8))>=_raw_tile['burnable']: if _raw_tile['burnable'] and _max_burn: create_fire((_x, _y, fire['pos'][2]), intensity=random.randint(1, numbers.clip(1+_max_burn, 2, 8))) _intensity = ((64-_neighbor_intensity)/64.0)*random.uniform(0, SETTINGS['fire burn rate']) fire['intensity'] -= _intensity for life in [LIFE[life_id] for life_id in LIFE_MAP[fire['pos'][0]][fire['pos'][1]]]: lfe.burn(life, fire['intensity']) for item in items.get_items_at(fire['pos']): items.burn(item, fire['intensity']) update_effect(fire) if fire['intensity'] <= 0.25: unregister_effect(fire) if 'light' in fire: fire['light']['brightness'] -= numbers.clip(_intensity*.015, 0, 5) elif not _neighbor_lit: fire['light'] = create_light(fire['pos'], (255, 69, 0), 17*(fire['intensity']/8.0), 0.25)
def calculate_fire(fire): _neighbor_intensity = 0 _neighbor_lit = False for x in range(-1, 2): _x = fire['pos'][0] + x if _x < 0 or _x >= MAP_SIZE[0]: continue for y in range(-1, 2): if not x and not y: continue _y = fire['pos'][1] + y if _y < 0 or _y >= MAP_SIZE[1]: continue maps.load_cluster_at_position_if_needed((_x, _y, fire['pos'][2])) _effects = [ EFFECTS[eid] for eid in EFFECT_MAP[_x][_y] if EFFECTS[eid]['type'] == 'fire' ] for effect in _effects: _neighbor_intensity += effect['intensity'] if 'light' in effect: _neighbor_lit = True if not _effects: _tile = WORLD_INFO['map'][_x][_y][fire['pos'][2]] _raw_tile = tiles.get_raw_tile(_tile) _heat = tiles.get_flag( WORLD_INFO['map'][_x][_y][fire['pos'][2]], 'heat') _current_burn = int(round(fire['intensity'])) _max_burn = int(round(_current_burn * .23)) if tiles.flag( _tile, 'heat', bad_numbers.clip(_heat + (fire['intensity'] * .8), 0, 8)) >= _raw_tile['burnable']: if _raw_tile['burnable'] and _max_burn: create_fire((_x, _y, fire['pos'][2]), intensity=random.randint( 1, bad_numbers.clip(1 + _max_burn, 2, 8))) _intensity = ((64 - _neighbor_intensity) / 64.0) * random.uniform( 0, SETTINGS['fire burn rate']) fire['intensity'] -= _intensity if random.randint(0, 1): _pos = fire['pos'][:2] _pos.append(2) create_smoke(_pos, direction=random.randint(0, 369), speed=random.uniform(0.3, 0.85), age=0.2, max_opacity=0.9, decay=0.03) for life in [ LIFE[life_id] for life_id in LIFE_MAP[fire['pos'][0]][fire['pos'][1]] ]: lfe.burn(life, fire['intensity']) for item in items.get_items_at(fire['pos']): items.burn(item, fire['intensity']) update_effect(fire) if fire['intensity'] <= 0.25: unregister_effect(fire) if 'light' in fire: fire['light']['brightness'] -= bad_numbers.clip( _intensity * .015, 0, 5) elif not _neighbor_lit: fire['light'] = create_light(fire['pos'], (255, 69, 0), 17 * (fire['intensity'] / 8.0), 0.25)