Ejemplo n.º 1
0
void game::wishmonster(int x, int y)
{
    const std::map<std::string, mtype *> montypes = MonsterGenerator::generator().get_all_mtypes();

    uimenu wmenu;
    wmenu.w_x = 0;
    wmenu.w_width = TERMX;
    // disabled due to foldstring crash //( TERMX - getmaxx(w_terrain) - 30 > 24 ? getmaxx(w_terrain) : TERMX );
    wmenu.pad_right = ( wmenu.w_width - 30 );
    wmenu.return_invalid = true;
    wmenu.selected = uistate.wishmonster_selected;
    wish_monster_callback *cb = new wish_monster_callback();
    wmenu.callback = cb;

    int i = 0;
    for( const auto &montype : montypes ) {
        wmenu.addentry( i, true, 0, "%s", montype.second->nname().c_str() );
        wmenu.entries[i].extratxt.txt = montype.second->sym;
        wmenu.entries[i].extratxt.color = montype.second->color;
        wmenu.entries[i].extratxt.left = 1;
        ++i;
    }

    do {
        wmenu.query();
        if ( wmenu.ret >= 0 ) {
            monster mon = monster(GetMType(wmenu.ret));
            if (cb->friendly) {
                mon.friendly = -1;
            }
            if (cb->hallucination) {
                mon.hallucination = true;
            }
            point spawn = ( x == -1 && y == -1 ? look_around() : point ( x, y ) );
            if (spawn.x != -1) {
                std::vector<point> spawn_points = closest_points_first( cb->group, spawn );
                for( auto spawn_point : spawn_points ) {
                    mon.spawn(spawn_point.x, spawn_point.y);
                    add_zombie(mon);
                }
                cb->msg = _("Monster spawned, choose another or 'q' to quit.");
                uistate.wishmonster_selected = wmenu.ret;
                wmenu.redraw();
            }
        }
    } while ( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' );
    delete cb;
    cb = NULL;
    return;
}
Ejemplo n.º 2
0
tripoint start_location::find_player_initial_location() const
{
    popup_nowait( _( "Please wait as we build your world" ) );
    // Spiral out from the world origin scanning for a compatible starting location,
    // creating overmaps as necessary.
    const int radius = 32;
    for( const point omp : closest_points_first( radius, point( 0, 0 ) ) ) {
        overmap &omap = overmap_buffer.get( omp.x, omp.y );
        const tripoint omtstart = omap.find_random_omt( target() );
        if( omtstart != overmap::invalid_tripoint ) {
            return omtstart + point( omp.x * OMAPX, omp.y * OMAPY );
        }
    }
    // Should never happen, if it does we messed up.
    popup( _( "Unable to generate a valid starting location, please report this failure." ) );
    return overmap::invalid_tripoint;
}
Ejemplo n.º 3
0
tripoint start_location::find_player_initial_location() const
{
    const bool using_existing_initial_overmap = overmap_buffer.has( 0, 0 );
    // The coordinates of an overmap that is known to *not* exist. We can regenerate this
    // as often we like.
    point non_existing_omt = point( 0, 0 );

    if( using_existing_initial_overmap ) {
        // arbitrary, should be large enough to include all overmaps ever created
        const int radius = 32;
        for( const point omp : closest_points_first( radius, point( 0, 0 ) ) ) {
            const overmap *omap = overmap_buffer.get_existing( omp.x, omp.y );
            if( omap == nullptr ) {
                if( non_existing_omt == point( 0, 0 ) ) {
                    non_existing_omt = omp;
                }
                continue;
            }
            const tripoint omtstart = omap->find_random_omt( target() );
            if( omtstart != overmap::invalid_tripoint ) {
                return omtstart + point( omp.x * OMAPX, omp.y * OMAPY );
            }
        }
    }

    while( true ) {
        popup_nowait( _( "Please wait as we build your world" ) );
        const overmap &initial_overmap = overmap_buffer.get( non_existing_omt.x, non_existing_omt.y );
        const tripoint omtstart = initial_overmap.find_random_omt( target() );
        if( omtstart != overmap::invalid_tripoint ) {
            return omtstart + point( non_existing_omt.x * OMAPX, non_existing_omt.y * OMAPY );
        }
        if( !query_yn(
                _( "The game could not create a world with a suitable starting location.\n\n"
                   "Depending on the world options, the starting location may never appear. If the problem persists, you can try another starting location, or change the world options.\n\n"
                   "Try again?" ) ) ) {
            return overmap::invalid_tripoint;
        }
        overmap_buffer.clear();
    }
}