#NEWLINE# def calculate_fire( fire ) : #NEWLINE# #INDENT# _neighbor_intensity = 0 #NEWLINE# _neighbor_lit = False #NEWLINE# for x in range ( ( - 1 ) , 2 ) : #NEWLINE# #INDENT# _x = ( fire [ 'pos' ] [ 0 ] + x ) #NEWLINE# if ( ( _x < 0 ) or ( _x >= MAP_SIZE [ 0 ] ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# for y in range ( ( - 1 ) , 2 ) : #NEWLINE# #INDENT# if ( ( not x ) and ( not y ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# _y = ( fire [ 'pos' ] [ 1 ] + y ) #NEWLINE# if ( ( _y < 0 ) or ( _y >= MAP_SIZE [ 1 ] ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# _effects = [ EFFECTS [ eid ] for eid in EFFECT_MAP [ _x ] [ _y ] if ( EFFECTS [ eid ] [ 'type' ] == 'fire' ) ] #NEWLINE# for effect in _effects : #NEWLINE# #INDENT# _neighbor_intensity += effect [ 'intensity' ] #NEWLINE# if ( 'light' in effect ) : #NEWLINE# #INDENT# _neighbor_lit = True #NEWLINE# #UNINDENT# #UNINDENT# if ( not _effects ) : #NEWLINE# #INDENT# _tile = WORLD_INFO [ 'map' ] [ _x ] [ _y ] [ fire [ 'pos' ] [ 2 ] ] #NEWLINE# _raw_tile = tiles . get_raw_tile ( _tile ) #NEWLINE# _heat = tiles . get_flag ( WORLD_INFO [ 'map' ] [ _x ] [ _y ] [ fire [ 'pos' ] [ 2 ] ] , 'heat' ) #NEWLINE# _current_burn = int ( round ( fire [ 'intensity' ] ) ) #NEWLINE# _max_burn = int ( round ( ( _current_burn * 0.23 ) ) ) #NEWLINE# if ( tiles . flag ( _tile , 'heat' , numbers . clip ( ( _heat + ( fire [ 'intensity' ] * 0.01 ) ) , 0 , 8 ) ) >= _raw_tile [ 'burnable' ] ) : #NEWLINE# #INDENT# if ( _raw_tile [ 'burnable' ] and _max_burn ) : #NEWLINE# #INDENT# create_fire ( ( _x , _y , fire [ 'pos' ] [ 2 ] ) , intensity = random . randint ( 1 , numbers . clip ( ( 1 + _max_burn ) , 2 , 8 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# _intensity = ( ( ( 64 - _neighbor_intensity ) / 64.0 ) * random . uniform ( 0 , SETTINGS [ 'fire burn rate' ] ) ) #NEWLINE# fire [ 'intensity' ] -= _intensity #NEWLINE# if random . randint ( 0 , 1 ) : #NEWLINE# #INDENT# _pos = fire [ 'pos' ] [ : 2 ] #NEWLINE# _pos . append ( 2 ) #NEWLINE# 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 ) #NEWLINE# #UNINDENT# for life in [ LIFE [ life_id ] for life_id in LIFE_MAP [ fire [ 'pos' ] [ 0 ] ] [ fire [ 'pos' ] [ 1 ] ] ] : #NEWLINE# #INDENT# lfe . burn ( life , fire [ 'intensity' ] ) #NEWLINE# #UNINDENT# for item in items . get_items_at ( fire [ 'pos' ] ) : #NEWLINE# #INDENT# items . burn ( item , fire [ 'intensity' ] ) #NEWLINE# #UNINDENT# update_effect ( fire ) #NEWLINE# if ( fire [ 'intensity' ] <= 0.25 ) : #NEWLINE# #INDENT# unregister_effect ( fire ) #NEWLINE# #UNINDENT# if ( 'light' in fire ) : #NEWLINE# #INDENT# fire [ 'light' ] [ 'brightness' ] -= numbers . clip ( ( _intensity * 0.015 ) , 0 , 5 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not _neighbor_lit ) : #NEWLINE# #INDENT# fire [ 'light' ] = create_light ( fire [ 'pos' ] , ( 255 , 69 , 0 ) , ( 17 * ( fire [ 'intensity' ] / 8.0 ) ) , 0.25 )