Ejemplo n.º 1
0
void activity_handlers::forage_finish( player_activity *act, player *p )
{
    int veggy_chance = rng(1, 100);
    bool found_something = false;

    items_location loc;
    ter_id next_ter = t_null; //Just to have a default for compilers' sake
    switch( calendar::turn.get_season() ) {
    case SPRING:
        loc = "forage_spring";
        next_ter = terfind("t_underbrush_harvested_spring");
        break;
    case SUMMER:
        loc = "forage_summer";
        next_ter = terfind("t_underbrush_harvested_summer");
        break;
    case AUTUMN:
        loc = "forage_autumn";
        next_ter = terfind("t_underbrush_harvested_autumn");
        break;
    case WINTER:
        loc = "forage_winter";
        next_ter = terfind("t_underbrush_harvested_winter");
        break;
    }

    g->m.ter_set( act->placement, next_ter );

    // Survival gives a bigger boost, and Peception is leveled a bit.
    // Both survival and perception affect time to forage
    if( veggy_chance < p->skillLevel( skill_survival ) * 3 + p->per_cur - 2 ) {
        const auto dropped = g->m.put_items_from_loc( loc, p->pos(), calendar::turn );
        for( const auto &it : dropped ) {
            add_msg( m_good, _( "You found: %s!" ), it->tname().c_str() );
            found_something = true;
        }
    }

    if( one_in(10) ) {
        const auto dropped = g->m.put_items_from_loc( "trash_forest", p->pos(), calendar::turn );
        for( const auto &it : dropped ) {
            add_msg( m_good, _( "You found: %s!" ), it->tname().c_str() );
            found_something = true;
        }
    }

    if( !found_something ) {
        add_msg(_("You didn't find anything."));
    }

    ///\xrefitem Stat_Effects_Intelligence "" "" Intelligence caps survival skill gains from foraging
    // Intelligence limits the forage exp gain
    const int max_forage_skill = p->int_cur / 3 + 1;
    const int max_exp = 2 * ( max_forage_skill - p->skillLevel( skill_survival ) );
    // Award experience for foraging attempt regardless of success
    p->practice( skill_survival, rng(1, max_exp), max_forage_skill );
}
Ejemplo n.º 2
0
ter_id terfind(const std::string & id) {
    auto iter = termap.find( id );
    if( iter != termap.end() ) {
        return iter->second.loadid;
    }
    const std::string new_id = convert_terrain_type( id );
    if( new_id != id ) {
        return terfind( new_id );
    }
    debugmsg( "can't find terrain %s", id.c_str() );
    return t_null;
}
Ejemplo n.º 3
0
// We're reading in way too many entities here to mess around with creating sub-objects and
// seeking around in them, so we're using the json streaming API.
submap *mapbuffer::unserialize_submaps( const tripoint &p )
{
    // Map the tripoint to the submap quad that stores it.
    const tripoint om_addr = overmapbuffer::sm_to_omt_copy( p );
    const tripoint segment_addr = overmapbuffer::omt_to_seg_copy( om_addr );
    std::stringstream quad_path;
    quad_path << world_generator->active_world->world_path << "/maps/" <<
              segment_addr.x << "." << segment_addr.y << "." << segment_addr.z << "/" <<
              om_addr.x << "." << om_addr.y << "." << om_addr.z << ".map";

    std::ifstream fin( quad_path.str().c_str() );
    if( !fin.is_open() ) {
        // If it doesn't exist, trigger generating it.
        return NULL;
    }

    JsonIn jsin( fin );
    jsin.start_array();
    while( !jsin.end_array() ) {
        std::unique_ptr<submap> sm(new submap());
        tripoint submap_coordinates;
        jsin.start_object();
        bool rubpow_update = false;
        while( !jsin.end_object() ) {
            std::string submap_member_name = jsin.get_member_name();
            if( submap_member_name == "version" ) {
                if (jsin.get_int() < 22) {
                    rubpow_update = true;
                }
            } else if( submap_member_name == "coordinates" ) {
                jsin.start_array();
                int locx = jsin.get_int();
                int locy = jsin.get_int();
                int locz = jsin.get_int();
                jsin.end_array();
                submap_coordinates = tripoint( locx, locy, locz );
            } else if( submap_member_name == "turn_last_touched" ) {
                sm->turn_last_touched = jsin.get_int();
            } else if( submap_member_name == "temperature" ) {
                sm->temperature = jsin.get_int();
            } else if( submap_member_name == "terrain" ) {
                // TODO: try block around this to error out if we come up short?
                jsin.start_array();
                // Small duplication here so that the update check is only performed once
                if (rubpow_update) {
                    std::string ter_string;
                    item rock = item("rock", 0);
                    item chunk = item("steel_chunk", 0);
                    for( int j = 0; j < SEEY; j++ ) {
                        for( int i = 0; i < SEEX; i++ ) {
                            ter_string = jsin.get_string();
                            if (ter_string == "t_rubble") {
                                sm->ter[i][j] = termap[ "t_dirt" ].loadid;
                                sm->frn[i][j] = furnmap[ "f_rubble" ].loadid;
                                sm->itm[i][j].push_back( rock );
                                sm->itm[i][j].push_back( rock );
                            } else if (ter_string == "t_wreckage"){
                                sm->ter[i][j] = termap[ "t_dirt" ].loadid;
                                sm->frn[i][j] = furnmap[ "f_wreckage" ].loadid;
                                sm->itm[i][j].push_back( chunk );
                                sm->itm[i][j].push_back( chunk );
                            } else if (ter_string == "t_ash"){
                                sm->ter[i][j] = termap[ "t_dirt" ].loadid;
                                sm->frn[i][j] = furnmap[ "f_ash" ].loadid;
                            } else if (ter_string == "t_pwr_sb_support_l"){
                                sm->ter[i][j] = termap[ "t_support_l" ].loadid;
                            } else if (ter_string == "t_pwr_sb_switchgear_l"){
                                sm->ter[i][j] = termap[ "t_switchgear_l" ].loadid;
                            } else if (ter_string == "t_pwr_sb_switchgear_s"){
                                sm->ter[i][j] = termap[ "t_switchgear_s" ].loadid;
                            } else {
                                sm->ter[i][j] = terfind( ter_string );
                            }
                        }
                    }
                } else {
                    for( int j = 0; j < SEEY; j++ ) {
                        for( int i = 0; i < SEEX; i++ ) {
                            sm->ter[i][j] = terfind( jsin.get_string() );
                        }
                    }
                }
                jsin.end_array();
            } else if( submap_member_name == "radiation" ) {
                int rad_cell = 0;
                jsin.start_array();
                while( !jsin.end_array() ) {
                    int rad_strength = jsin.get_int();
                    int rad_num = jsin.get_int();
                    for( int i = 0; i < rad_num; ++i ) {
                        // A little array trick here, assign to it as a 1D array.
                        // If it's not in bounds we're kinda hosed anyway.
                        sm->set_radiation(0, rad_cell, rad_strength);
                        rad_cell++;
                    }
                }
            } else if( submap_member_name == "furniture" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    sm->frn[i][j] = furnmap[ jsin.get_string() ].loadid;
                    jsin.end_array();
                }
            } else if( submap_member_name == "items" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.start_array();
                    while( !jsin.end_array() ) {
                        item tmp;
                        jsin.read( tmp );

                        if( tmp.is_emissive() ) {
                            sm->update_lum_add(tmp, i, j);
                        }

                        tmp.visit_items([&sm,i,j]( item *it ) {
                            for( auto& e: it->magazine_convert() ) {
                                sm->itm[i][j].push_back( e );
                            }
                            return VisitResponse::NEXT;
                        } );

                        sm->itm[i][j].push_back( tmp );
                        if( tmp.needs_processing() ) {
                            sm->active_items.add( std::prev(sm->itm[i][j].end()), point( i, j ) );
                        }
                    }
                }
            } else if( submap_member_name == "traps" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    // TODO: jsin should support returning an id like jsin.get_id<trap>()
                    sm->trp[i][j] = trap_str_id( jsin.get_string() );
                    jsin.end_array();
                }
            } else if( submap_member_name == "fields" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    // Coordinates loop
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.start_array();
                    while( !jsin.end_array() ) {
                        int type = jsin.get_int();
                        int density = jsin.get_int();
                        int age = jsin.get_int();
                        if (sm->fld[i][j].findField(field_id(type)) == NULL) {
                            sm->field_count++;
                        }
                        sm->fld[i][j].addField(field_id(type), density, age);
                    }
                }
            } else if( submap_member_name == "graffiti" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    sm->set_graffiti( i, j, jsin.get_string() );
                    jsin.end_array();
                }
            } else if(submap_member_name == "cosmetics") {
                jsin.start_array();
                while (!jsin.end_array()) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.read(sm->cosmetics[i][j]);
                    jsin.end_array();
                }
            } else if( submap_member_name == "spawns" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    const mtype_id type = mtype_id( jsin.get_string() ); // TODO: json should know how to read an string_id
                    int count = jsin.get_int();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    int faction_id = jsin.get_int();
                    int mission_id = jsin.get_int();
                    bool friendly = jsin.get_bool();
                    std::string name = jsin.get_string();
                    jsin.end_array();
                    spawn_point tmp( type, count, i, j, faction_id, mission_id, friendly, name );
                    sm->spawns.push_back( tmp );
                }
            } else if( submap_member_name == "vehicles" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    vehicle *tmp = new vehicle();
                    jsin.read( *tmp );
                    sm->vehicles.push_back( tmp );
                }
            } else if( submap_member_name == "computers" ) {
                std::string computer_data = jsin.get_string();
                sm->comp.load_data( computer_data );
            } else if( submap_member_name == "camp" ) {
                std::string camp_data = jsin.get_string();
                sm->camp.load_data( camp_data );
            } else {
                jsin.skip_value();
            }
        }
        if( !add_submap( submap_coordinates, sm ) ) {
            debugmsg( "submap %d,%d,%d was already loaded", submap_coordinates.x, submap_coordinates.y,
                      submap_coordinates.z );
        }
    }
    if( submaps.count( p ) == 0 ) {
        debugmsg("file %s did not contain the expected submap %d,%d,%d", quad_path.str().c_str(), p.x, p.y,
                 p.z);
        return NULL;
    }
    return submaps[ p ];
}
Ejemplo n.º 4
0
void set_ter_ids() {
    t_null=terfind("t_null");
    t_hole=terfind("t_hole");
    t_dirt=terfind("t_dirt");
    t_sand=terfind("t_sand");
    t_dirtmound=terfind("t_dirtmound");
    t_pit_shallow=terfind("t_pit_shallow");
    t_pit=terfind("t_pit");
    t_pit_corpsed=terfind("t_pit_corpsed");
    t_pit_covered=terfind("t_pit_covered");
    t_pit_spiked=terfind("t_pit_spiked");
    t_pit_spiked_covered=terfind("t_pit_spiked_covered");
    t_rock_floor=terfind("t_rock_floor");
    t_grass=terfind("t_grass");
    t_metal_floor=terfind("t_metal_floor");
    t_pavement=terfind("t_pavement");
    t_pavement_y=terfind("t_pavement_y");
    t_sidewalk=terfind("t_sidewalk");
    t_concrete=terfind("t_concrete");
    t_floor=terfind("t_floor");
    t_floor_waxed=terfind("t_floor_waxed");
    t_dirtfloor=terfind("t_dirtfloor");
    t_carpet_red=terfind("t_carpet_red");
    t_carpet_yellow=terfind("t_carpet_yellow");
    t_carpet_purple=terfind("t_carpet_purple");
    t_carpet_green=terfind("t_carpet_green");
    t_linoleum_white=terfind("t_linoleum_white");
    t_linoleum_gray=terfind("t_linoleum_gray");
    t_grate=terfind("t_grate");
    t_slime=terfind("t_slime");
    t_bridge=terfind("t_bridge");
    t_utility_light=terfind("t_utility_light");
    t_wall_log_half=terfind("t_wall_log_half");
    t_wall_log=terfind("t_wall_log");
    t_wall_log_chipped=terfind("t_wall_log_chipped");
    t_wall_log_broken=terfind("t_wall_log_broken");
    t_palisade=terfind("t_palisade");
    t_palisade_gate=terfind("t_palisade_gate");
    t_palisade_gate_o=terfind("t_palisade_gate_o");
    t_wall_half=terfind("t_wall_half");
    t_wall_wood=terfind("t_wall_wood");
    t_wall_wood_chipped=terfind("t_wall_wood_chipped");
    t_wall_wood_broken=terfind("t_wall_wood_broken");
    t_wall_v=terfind("t_wall_v");
    t_wall_h=terfind("t_wall_h");
    t_concrete_v=terfind("t_concrete_v");
    t_concrete_h=terfind("t_concrete_h");
    t_wall_metal_v=terfind("t_wall_metal_v");
    t_wall_metal_h=terfind("t_wall_metal_h");
    t_wall_glass_v=terfind("t_wall_glass_v");
    t_wall_glass_h=terfind("t_wall_glass_h");
    t_wall_glass_v_alarm=terfind("t_wall_glass_v_alarm");
    t_wall_glass_h_alarm=terfind("t_wall_glass_h_alarm");
    t_reinforced_glass_v=terfind("t_reinforced_glass_v");
    t_reinforced_glass_h=terfind("t_reinforced_glass_h");
    t_bars=terfind("t_bars");
    t_wall_h_b=terfind("t_wall_h_b");
    t_wall_h_g=terfind("t_wall_h_g");
    t_wall_h_p=terfind("t_wall_h_p");
    t_wall_h_r=terfind("t_wall_h_r");
    t_wall_h_w=terfind("t_wall_h_w");
    t_wall_v_b=terfind("t_wall_v_b");
    t_wall_v_g=terfind("t_wall_v_g");
    t_wall_v_p=terfind("t_wall_v_p");
    t_wall_v_r=terfind("t_wall_v_r");
    t_wall_v_w=terfind("t_wall_v_w");
    t_door_c=terfind("t_door_c");
    t_door_b=terfind("t_door_b");
    t_door_o=terfind("t_door_o");
    t_rdoor_c=terfind("t_rdoor_c");
    t_rdoor_b=terfind("t_rdoor_b");
    t_rdoor_o=terfind("t_rdoor_o");
    t_door_locked_interior=terfind("t_door_locked_interior");
    t_door_locked=terfind("t_door_locked");
    t_door_locked_alarm=terfind("t_door_locked_alarm");
    t_door_frame=terfind("t_door_frame");
    t_mdoor_frame=terfind("t_mdoor_frame");
    t_chaingate_l=terfind("t_chaingate_l");
    t_fencegate_c=terfind("t_fencegate_c");
    t_fencegate_o=terfind("t_fencegate_o");
    t_chaingate_c=terfind("t_chaingate_c");
    t_chaingate_o=terfind("t_chaingate_o");
    t_door_boarded=terfind("t_door_boarded");
    t_door_boarded_damaged=terfind("t_door_boarded_damaged");
    t_rdoor_boarded=terfind("t_rdoor_boarded");
    t_rdoor_boarded_damaged=terfind("t_rdoor_boarded_damaged");
    t_door_metal_c=terfind("t_door_metal_c");
    t_door_metal_o=terfind("t_door_metal_o");
    t_door_metal_locked=terfind("t_door_metal_locked");
    t_door_bar_c=terfind("t_door_bar_c");
    t_door_bar_o=terfind("t_door_bar_o");
    t_door_bar_locked=terfind("t_door_bar_locked");
    t_door_glass_c=terfind("t_door_glass_c");
    t_door_glass_o=terfind("t_door_glass_o");
    t_portcullis=terfind("t_portcullis");
    t_recycler=terfind("t_recycler");
    t_window=terfind("t_window");
    t_window_taped=terfind("t_window_taped");
    t_window_domestic=terfind("t_window_domestic");
    t_window_domestic_taped=terfind("t_window_domestic_taped");
    t_window_open=terfind("t_window_open");
    t_curtains=terfind("t_curtains");
    t_window_alarm=terfind("t_window_alarm");
    t_window_alarm_taped=terfind("t_window_alarm_taped");
    t_window_empty=terfind("t_window_empty");
    t_window_frame=terfind("t_window_frame");
    t_window_boarded=terfind("t_window_boarded");
    t_window_boarded_noglass=terfind("t_window_boarded_noglass");
    t_window_reinforced=terfind("t_window_reinforced");
    t_window_reinforced_noglass=terfind("t_window_reinforced_noglass");
    t_window_enhanced=terfind("t_window_enhanced");
    t_window_enhanced_noglass=terfind("t_window_enhanced_noglass");
    t_window_stained_green=terfind("t_window_stained_green");
    t_window_stained_red=terfind("t_window_stained_red");
    t_window_stained_blue=terfind("t_window_stained_blue");
    t_rock=terfind("t_rock");
    t_fault=terfind("t_fault");
    t_paper=terfind("t_paper");
    t_rock_wall=terfind("t_rock_wall");
    t_rock_wall_half=terfind("t_rock_wall_half");
    t_tree=terfind("t_tree");
    t_tree_young=terfind("t_tree_young");
    t_tree_apple=terfind("t_tree_apple");
    t_tree_pear=terfind("t_tree_pear");
    t_tree_cherry=terfind("t_tree_cherry");
    t_tree_peach=terfind("t_tree_peach");
    t_tree_apricot=terfind("t_tree_apricot");
    t_tree_plum=terfind("t_tree_plum");
    t_tree_pine=terfind("t_tree_pine");
    t_tree_deadpine=terfind("t_tree_deadpine");
    t_underbrush=terfind("t_underbrush");
    t_shrub=terfind("t_shrub");
    t_shrub_blueberry=terfind("t_shrub_blueberry");
    t_shrub_strawberry=terfind("t_shrub_strawberry");
    t_trunk=terfind("t_trunk");
    t_root_wall=terfind("t_root_wall");
    t_wax=terfind("t_wax");
    t_floor_wax=terfind("t_floor_wax");
    t_fence_v=terfind("t_fence_v");
    t_fence_h=terfind("t_fence_h");
    t_chainfence_v=terfind("t_chainfence_v");
    t_chainfence_h=terfind("t_chainfence_h");
    t_chainfence_posts=terfind("t_chainfence_posts");
    t_fence_post=terfind("t_fence_post");
    t_fence_wire=terfind("t_fence_wire");
    t_fence_barbed=terfind("t_fence_barbed");
    t_fence_rope=terfind("t_fence_rope");
    t_railing_v=terfind("t_railing_v");
    t_railing_h=terfind("t_railing_h");
    t_marloss=terfind("t_marloss");
    t_fungus_floor_in=terfind("t_fungus_floor_in");
    t_fungus_floor_sup=terfind("t_fungus_floor_sup");
    t_fungus_floor_out=terfind("t_fungus_floor_out");
    t_fungus_wall=terfind("t_fungus_wall");
    t_fungus_wall_v=terfind("t_fungus_wall_v");
    t_fungus_wall_h=terfind("t_fungus_wall_h");
    t_fungus_mound=terfind("t_fungus_mound");
    t_fungus=terfind("t_fungus");
    t_shrub_fungal=terfind("t_shrub_fungal");
    t_tree_fungal=terfind("t_tree_fungal");
    t_tree_fungal_young=terfind("t_tree_fungal_young");
    t_water_sh=terfind("t_water_sh");
    t_water_dp=terfind("t_water_dp");
    t_swater_sh=terfind("t_swater_sh");
    t_swater_dp=terfind("t_swater_dp");
    t_water_pool=terfind("t_water_pool");
    t_sewage=terfind("t_sewage");
    t_lava=terfind("t_lava");
    t_sandbox=terfind("t_sandbox");
    t_slide=terfind("t_slide");
    t_monkey_bars=terfind("t_monkey_bars");
    t_backboard=terfind("t_backboard");
    t_gas_pump=terfind("t_gas_pump");
    t_gas_pump_smashed=terfind("t_gas_pump_smashed");
    t_atm=terfind("t_atm");
    t_generator_broken=terfind("t_generator_broken");
    t_missile=terfind("t_missile");
    t_missile_exploded=terfind("t_missile_exploded");
    t_radio_tower=terfind("t_radio_tower");
    t_radio_controls=terfind("t_radio_controls");
    t_console_broken=terfind("t_console_broken");
    t_console=terfind("t_console");
    t_gates_mech_control=terfind("t_gates_mech_control");
    t_gates_control_concrete=terfind("t_gates_control_concrete");
    t_barndoor=terfind("t_barndoor");
    t_palisade_pulley=terfind("t_palisade_pulley");
    t_sewage_pipe=terfind("t_sewage_pipe");
    t_sewage_pump=terfind("t_sewage_pump");
    t_centrifuge=terfind("t_centrifuge");
    t_column=terfind("t_column");
    t_vat=terfind("t_vat");
    t_cvdbody=terfind("t_cvdbody");
    t_cvdmachine=terfind("t_cvdmachine");
    t_stairs_down=terfind("t_stairs_down");
    t_stairs_up=terfind("t_stairs_up");
    t_manhole=terfind("t_manhole");
    t_ladder_up=terfind("t_ladder_up");
    t_ladder_down=terfind("t_ladder_down");
    t_slope_down=terfind("t_slope_down");
    t_slope_up=terfind("t_slope_up");
    t_rope_up=terfind("t_rope_up");
    t_manhole_cover=terfind("t_manhole_cover");
    t_card_science=terfind("t_card_science");
    t_card_military=terfind("t_card_military");
    t_card_reader_broken=terfind("t_card_reader_broken");
    t_slot_machine=terfind("t_slot_machine");
    t_elevator_control=terfind("t_elevator_control");
    t_elevator_control_off=terfind("t_elevator_control_off");
    t_elevator=terfind("t_elevator");
    t_pedestal_wyrm=terfind("t_pedestal_wyrm");
    t_pedestal_temple=terfind("t_pedestal_temple");
    t_rock_red=terfind("t_rock_red");
    t_rock_green=terfind("t_rock_green");
    t_rock_blue=terfind("t_rock_blue");
    t_floor_red=terfind("t_floor_red");
    t_floor_green=terfind("t_floor_green");
    t_floor_blue=terfind("t_floor_blue");
    t_switch_rg=terfind("t_switch_rg");
    t_switch_gb=terfind("t_switch_gb");
    t_switch_rb=terfind("t_switch_rb");
    t_switch_even=terfind("t_switch_even");
    t_covered_well=terfind("t_covered_well");
    t_water_pump=terfind("t_water_pump");
    t_open_air=terfind("t_open_air");
    t_plut_generator = terfind("t_plut_generator");
};
Ejemplo n.º 5
0
void activity_handlers::forage_finish( player_activity *act, player *p )
{
    int veggy_chance = rng(1, 100);
    bool found_something = false;

    if( one_in(12) ) {
        add_msg(m_good, _("You found some trash!"));
        g->m.put_items_from_loc( "trash_forest", p->pos3(), calendar::turn );
        found_something = true;
    }
    items_location loc;
    ter_id next_ter = t_null; //Just to have a default for compilers' sake
    switch (calendar::turn.get_season() ) {
    case SPRING:
        loc = "forage_spring";
        next_ter = terfind("t_underbrush_harvested_spring");
        break;
    case SUMMER:
        loc = "forage_summer";
        next_ter = terfind("t_underbrush_harvested_summer");
        break;
    case AUTUMN:
        loc = "forage_autumn";
        next_ter = terfind("t_underbrush_harvested_autumn");
        break;
    case WINTER:
        loc = "forage_winter";
        next_ter = terfind("t_underbrush_harvested_winter");
        break;
    }
    
    // Compromise: Survival gives a bigger boost, and Peception is leveled a bit.
    if( veggy_chance < ((p->skillLevel("survival") * 1.5) + ((p->per_cur / 2 - 4) + 3)) ) {                
        // Returns zero if location has no defined items.
        int cnt = g->m.put_items_from_loc( loc, p->pos3(), calendar::turn );
        if( cnt > 0 ) {
            add_msg(m_good, _("You found something!"));
            g->m.ter_set( act->placement, next_ter );
            found_something = true;
        }
    } else {
        if( one_in(2) ) {
            g->m.ter_set( act->placement, next_ter );
        }
    }
    if( !found_something ) {
        add_msg(_("You didn't find anything."));
    }

    //Determinate maximum level of skill attained by foraging using ones intelligence score
    int max_forage_skill = 0;
    if( p->int_cur < 4 ) {
        max_forage_skill = 1;
    } else if( p->int_cur < 6 ) {
        max_forage_skill = 2;
    } else if( p->int_cur < 8 ) {
        max_forage_skill = 3;
    } else if( p->int_cur < 11 ) {
        max_forage_skill = 4;
    } else if( p->int_cur < 15 ) {
        max_forage_skill = 5;
    } else if( p->int_cur < 20 ) {
        max_forage_skill = 6;
    } else if( p->int_cur < 26 ) {
        max_forage_skill = 7;
    } else if( p->int_cur > 25 ) {
        max_forage_skill = 8;
    }

    const int max_exp {(max_forage_skill * 2) - (p->skillLevel("survival") * 2)};
    //Award experience for foraging attempt regardless of success
    p->practice("survival", rng(1, max_exp), max_forage_skill);
}