Example #1
0
def add_secret_exit(map_name, line_id):
    # sets given line # in given map as a secret exit switch
    wad = omg.WAD()
    wad_filename = DEST_DIR + 'maps/%s.wad' % map_name
    wad.from_file(wad_filename)
    ed = omg.MapEditor(wad.maps[map_name])
    ed.linedefs[line_id].__dict__['action'] = 51
    wad.maps[map_name] = ed.to_lumps()
    wad.to_file(wad_filename)
Example #2
0
def rate_map(wmap):
    med = omg.MapEditor(wmap)
    rating = 0
    for t in med.things:
        if t.type == 3004: rating += 10  #zombieman
        if t.type == 9: rating += 15  #sergeant
        if t.type == 3001: rating += 15  #imp
        if t.type == 3002: rating += 15  #pinky
        if t.type == 58: rating += 18  #spectre
        if t.type == 65: rating += 25  #chaingunner
        if t.type == 69: rating += 40  #hell knight
        if t.type == 3003: rating += 60  #baron of hell
        if t.type == 66: rating += 40  #revenent
        if t.type == 68: rating += 70  #arachnotron
        if t.type == 67: rating += 70  #mancubus
        if t.type == 3006: rating += 15  #lost soul
        if t.type == 3005: rating += 25  #cacodemon
        if t.type == 71: rating += 50  #pain elemental
        if t.type == 64: rating += 150  #archvile
        if t.type == 7: rating += 200  #spider mastermind
        if t.type == 16: rating += 250  #cyberdemon
        if t.type == 84: rating += 15  #wolf ss
    return rating
Example #3
0
def change_textures(in_map, textures_file):
    with open(os.path.join('/home/adosovit/work/future_pred/my_scenarios/paper', textures_file)) as f:
        textures = f.read().split()
        
    #print textures
    
    # three options are: 
    #   all random; 
    #   all walls the same, ceil the same, floor the same; 
    #   all the same
    probs = [1.,1.,1.]
    r = random.uniform(0,probs[0] + probs[1] + probs[2])
    if r < probs[0]:
        mode = 'all_rand'
    elif r < probs[0] + probs[1]:
        mode = 'walls_ceil_floor'
    else:
        mode = 'all_the_same'   
        
    print mode, textures_file
        
    map_editor = omg.MapEditor(in_map)
    
    apply_to_mid = False  # this has to be False for lab22
    if mode == 'all_rand':
        for s in map_editor.sidedefs:
            s.tx_up = random.choice(textures)
            s.tx_low = random.choice(textures)
            if apply_to_mid:
                s.tx_mid = random.choice(textures)
        for s in map_editor.sectors:
            s.tx_floor = random.choice(textures)
            s.tx_ceil = random.choice(textures)
    elif mode == 'walls_ceil_floor':
        wall_tx = random.choice(textures)
        floor_tx = random.choice(textures)
        ceil_tx = random.choice(textures)
        for s in map_editor.sidedefs:
            s.tx_up = wall_tx
            s.tx_low = wall_tx
            if apply_to_mid:
                s.tx_mid = wall_tx
        for s in map_editor.sectors:
            s.tx_floor = floor_tx
            s.tx_ceil = ceil_tx
    elif mode == 'all_the_same':
        all_tx = random.choice(textures)
        for s in map_editor.sidedefs:
            s.tx_up = all_tx
            s.tx_low = all_tx
            if apply_to_mid:
                s.tx_mid = all_tx
        for s in map_editor.sectors:
            s.tx_floor = all_tx
            s.tx_ceil = all_tx  
    else:
        raise Exception('Unknown mode', mode)
        
    out_map = map_editor.to_lumps()
    
    to_copy = ['BEHAVIOR']
    for t in to_copy:
        if t in in_map:
            out_map[t] = in_map[t]
    
    return out_map
Example #4
0
def change_textures(in_map, texture_generator):
  map_editor = omg.MapEditor(in_map)
  inner_change_textures(map_editor, texture_generator)
  out_map = map_editor.to_lumps()
  copy_attributes(in_map, out_map)
  return out_map
Example #5
0
def main(argv):
    w = omg.WAD(from_file=omg.WadIO(argv[1], mode='rb'))
    map_editor = omg.MapEditor(w.maps[argv[2]])
    return globals()[argv[3]](map_editor, *argv[4:])
Example #6
0
            letter = letters[c]
        result.extend(letter)
        if idx + 1 < len(s) and s[idx + 1] != ' ':
            result.extend(letters['short_space'])
    return result


words = ENGLISH_WORDS
#words = SPANISH_WORDS

# Fudge factor:
wall_len = 32 * len(words)

letters = read_letters()

ed = omg.MapEditor()

add_sector = make_adder(ed.sectors, omg.Sector)
add_sidedef = make_adder(ed.sidedefs, omg.Sidedef)
add_linedef = make_adder(ed.linedefs, omg.Linedef)
add_vertex = make_adder(ed.vertexes, omg.Vertex)
add_thing = make_adder(ed.things, omg.Thing)

sec1 = add_sector(z_ceil=96)
sec2 = add_sector(z_ceil=96, z_floor=55)
sd1 = add_sidedef(sector=sec1, tx_mid="STARTAN2")
sd2 = add_sidedef(sector=sec2, tx_mid="SHAWN2")
v1 = add_vertex(x=256, y=wall_len)
v2 = add_vertex(x=256, y=0)
v3 = add_vertex(x=0, y=0)
v4 = add_vertex(x=0, y=wall_len)