Exemplo n.º 1
0
def spawn_truck(pmap, odds):
    for x in range(pmap.width):
        for y in range(pmap.height):
            if random.random() < odds and check_for_ground(
                    pmap, x, y, 1, 3) and is_actual_path(
                        pmap, x, y + 2) and is_actual_path(pmap, x + 2, y + 2):
                if check_for_building(pmap, x, y, 3, 3) and flat_surface(
                        pmap, x, y + 1, 3, 2) and check_for_decoration(
                            pmap, x, y, 3, 3):
                    for truck_tile in range(9):
                        pmap.secondary_ground[(x + truck_tile % 3, y +
                                               math.floor(truck_tile / 3))] = (
                                                   "de", 7 + truck_tile % 3,
                                                   truck_tile // 3)
                    return
Exemplo n.º 2
0
def spawn_truck(pmap, odds):
    for x in range(pmap.width):
        for y in range(pmap.height):
            if random.random() < odds and pmap.ground.empty_area(
                (x, y), (x + 2, y + 1)) and is_actual_path(
                    pmap.ground, x, y + 2) and is_actual_path(
                        pmap.ground, x + 2, y + 2):
                if check_for_building(
                        pmap.buildings, x, y, 3, 3) and flat_surface(
                            pmap, x, y + 1, 3, 2) and check_for_decoration(
                                pmap.decoration, x, y, 3, 3):
                    for truck_tile in range(6):
                        pmap.decoration.set_tile(
                            (x + truck_tile % 3,
                             y + math.floor(truck_tile / 3)),
                            ("de", 7 + truck_tile % 3, truck_tile // 3))
                    return
Exemplo n.º 3
0
def set_npc(pmap, layer, npc, x, y):
    direction = 0 if npc == 54 else random.randint(
        0, 3)  # Npcs nr 50 only has 1 direction
    layer.set_tile((x, y), ("np", npc % 5 * 4 + direction, npc // 5))
    if direction == 1 and is_actual_path(pmap.ground, x, y):
        if (x + 1, y) not in layer.get_ex_pos() and (
                x + 1, y
        ) not in pmap.buildings.get_ex_pos() and "hi" != pmap.ground.get_tile(
            (x + 1, y)) and "fe" != pmap.ground.get_tile(
                x + 1, y) and (x + 1, y) not in pmap.ground2.get_ex_pos():
            snpc = get_path_npc()
            while snpc == 54:
                snpc = get_path_npc()
            layer.set_tile((x + 1, y), ("np", snpc % 5 * 4 + 3, snpc // 5))
Exemplo n.º 4
0
def set_npc(pmap, npc, x, y):
    direction = 0 if npc == 54 else random.randint(
        0, 3)  # Npcs nr 50 only has 1 direction
    pmap.npc_layer[(x, y)] = ("np", npc % 5 * 4 + direction, npc // 5)
    if direction == 1 and is_actual_path(pmap, x, y):
        if (x + 1, y) not in pmap.npc_layer.keys() and (
                x + 1, y
        ) not in pmap.buildings.keys() and "hi" != pmap.ground_layer.get(
            (x + 1, y), "") and "fe" != pmap.get_tile_type(
                "ground_layer", x + 1,
                y) and (x + 1, y) not in pmap.secondary_ground.keys():
            snpc = get_path_npc()
            while snpc == 54:
                snpc = get_path_npc()
            pmap.npc_layer[(x + 1, y)] = ("np", snpc % 5 * 4 + 3, snpc // 5)
Exemplo n.º 5
0
def spawn_npc(pmap, layer, population, path_only=False):
    coord = random_npc_coordinates(pmap, population)
    for co in coord:
        x, y = co
        if pmap.tile_heights.get((x, y), -1) <= pmap.highest_path and (
                x, y) not in pmap.buildings.get_ex_pos(
                ) and "hi" != pmap.ground.get_tile_type(
                    (x, y)) and (x, y) not in pmap.ground2.get_ex_pos():
            if path_only:
                if is_actual_path(pmap.ground, x, y):
                    npc = get_path_npc()
                    set_npc(layer, npc, x, y)
            else:
                npc = get_npc(pmap, x, y)
                if npc is not None:
                    set_npc(pmap, pmap.npc, npc, x, y)
Exemplo n.º 6
0
def get_npc(pmap, x, y):
    WATER_LVL = 0.2
    npc_number = None
    if not pmap.raining:
        if random.random() < WATER_LVL and "wa" == pmap.get_tile_type(
                "ground_layer", x, y) and is_inside_cluster(pmap, x, y, 20, 1):
            npc_number = get_water_npc()
        elif "ro" in pmap.ground_layer.get((x, y), ""):
            npc_number = get_bridge_npc()
        elif random.random() < WATER_LVL and 3 == get_path_type(
                pmap, x, y) in pmap.ground_layer.get(
                    (x, y), "") and is_inside_cluster(pmap, x, y, 20, 1):
            npc_number = get_shore_npc()
    if (x, y) not in pmap.ground_layer.keys():
        npc_number = get_outside_npc()
    elif is_actual_path(pmap, x, y):
        npc_number = get_path_npc()
    return npc_number
Exemplo n.º 7
0
def get_npc(pmap, x, y):
    WATER_LVL = 0.2
    npc_number = None
    if not pmap.raining:
        if random.random() < WATER_LVL and "wa" == pmap.ground.get_tile_type(
            (x, y)) and is_inside_cluster(pmap, x, y, 8, 1):
            npc_number = get_water_npc()
        elif "ro" == pmap.ground.get_tile((x, y)):
            npc_number = get_bridge_npc()
        elif random.random() < WATER_LVL and 3 == get_path_type(
                pmap.ground, x, y) in pmap.ground.get_tile(
                    (x, y)) and is_inside_cluster(pmap, x, y, 8, 1):
            npc_number = get_shore_npc()
    if (x, y) not in pmap.ground.get_ex_pos():
        npc_number = get_outside_npc()
    elif is_actual_path(pmap.ground, x, y):
        npc_number = get_path_npc()
    return npc_number