Esempio n. 1
0
void player_activity::do_turn( player *p )
{
    switch( type ) {
        case ACT_WAIT:
        case ACT_WAIT_NPC:
        case ACT_WAIT_WEATHER:
            // Based on time, not speed
            moves_left -= 100;
            p->rooted();
            p->pause();
            break;
        case ACT_PICKAXE:
            // Based on speed, not time
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            activity_handlers::pickaxe_do_turn( this, p );
            break;
        case ACT_BURROW:
            // Based on speed, not time
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            activity_handlers::burrow_do_turn( this, p );
            break;
        case ACT_AIM:
            if( index == 0 ) {
                if( !p->weapon.is_gun() ) {
                    // We lost our gun somehow, bail out.
                    type = ACT_NULL;
                    break;
                }

                g->m.build_map_cache( g->get_levz() );
                g->plfire();
            }
            break;
        case ACT_GAME:
            // Takes care of u.activity.moves_left
            activity_handlers::game_do_turn( this, p );
            break;
        case ACT_VIBE:
            // Takes care of u.activity.moves_left
            activity_handlers::vibe_do_turn( this, p );
            break;
        case ACT_REFILL_VEHICLE:
            type = ACT_NULL; // activity is not used anymore.
            break;
        case ACT_PULP:
            // does not really use u.activity.moves_left, stops itself when finished
            activity_handlers::pulp_do_turn( this, p );
            break;
        case ACT_FISH:
            // Based on time, not speed--or it should be
            // (Being faster doesn't make the fish bite quicker)
            moves_left -= 100;
            p->rooted();
            p->pause();
            break;
        case ACT_DROP:
            activity_on_turn_drop();
            break;
        case ACT_STASH:
            activity_on_turn_stash();
            break;
        case ACT_PICKUP:
            activity_on_turn_pickup();
            break;
        case ACT_MOVE_ITEMS:
            activity_on_turn_move_items();
            break;
        case ACT_ADV_INVENTORY:
            p->cancel_activity();
            advanced_inv();
            break;
        case ACT_ARMOR_LAYERS:
            p->cancel_activity();
            p->sort_armor();
            break;
        case ACT_START_FIRE:
            moves_left -= 100; // based on time
            if( p->i_at(
                    position ).has_flag( "LENS" ) ) { // if using a lens, handle potential changes in weather
                activity_handlers::start_fire_lens_do_turn( this, p );
            }
            p->rooted();
            p->pause();
            break;
        case ACT_OPEN_GATE:
            // Based on speed, not time
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            break;
        case ACT_FILL_LIQUID:
            activity_handlers::fill_liquid_do_turn( this, p );
            break;
        case ACT_ATM:
            iexamine::atm( *p, p->pos() );
            break;
        case ACT_START_ENGINES:
            moves_left -= 100;
            p->rooted();
            p->pause();
            break;
        case ACT_OXYTORCH:
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            if( values[0] > 0 ) {
                activity_handlers::oxytorch_do_turn( this, p );
            }
            break;
        case ACT_CRACKING:
            if( !( p->has_amount( "stethoscope", 1 ) || p->has_bionic( "bio_ears" ) ) ) {
                // We lost our cracking tool somehow, bail out.
                type = ACT_NULL;
                break;
            }
            // Based on speed, not time
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            p->practice( skill_id( "mechanics" ), 1 );
            break;
        case ACT_REPAIR_ITEM: {
            // Based on speed * detail vision
            const int effective_moves = p->moves / p->fine_detail_vision_mod();
            if( effective_moves <= moves_left ) {
                moves_left -= effective_moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left * p->fine_detail_vision_mod();
                moves_left = 0;
            }
        }

        break;

        case ACT_BUTCHER:
            // Drain some stamina
            p->mod_stat( "stamina", -20.0f * p->stamina / p->get_stamina_max() );
            // Based on speed, not time
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            break;

        default:
            // Based on speed, not time
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
    }

    if( is_complete() ) {
        finish( p );
    }
}
Esempio n. 2
0
void player_activity::do_turn( player *p )
{
    switch (type) {
        case ACT_WAIT:
        case ACT_WAIT_WEATHER:
            // Based on time, not speed
            moves_left -= 100;
            p->rooted();
            p->pause();
            break;
        case ACT_PICKAXE:
            // Based on speed, not time
            moves_left -= p->moves;
            p->moves = 0;
            activity_handlers::pickaxe_do_turn( this, p );
            break;
        case ACT_BURROW:
            // Based on speed, not time
            moves_left -= p->moves;
            p->moves = 0;
            activity_handlers::burrow_do_turn( this, p );
            break;
        case ACT_AIM:
            if( index == 0 ) {
                if( !p->weapon.is_gun() ) {
                    // We lost our gun somehow, bail out.
                    type = ACT_NULL;
                    break;
                }
                g->m.build_map_cache();
                g->plfire(false);
            }
            break;
        case ACT_GAME:
            // Takes care of u.activity.moves_left
            activity_handlers::game_do_turn( this, p );
            break;
        case ACT_VIBE:
            // Takes care of u.activity.moves_left
            activity_handlers::vibe_do_turn( this, p );
            break;
        case ACT_REFILL_VEHICLE:
            // Takes care of u.activity.moves_left
            activity_handlers::refill_vehicle_do_turn( this, p );
            break;
        case ACT_PULP:
            // does not really use u.activity.moves_left, stops itself when finished
            activity_handlers::pulp_do_turn( this, p );
            break;
        case ACT_FISH:
            // Based on time, not speed--or it should be
            // (Being faster doesn't make the fish bite quicker)
            moves_left -= 100;
            p->rooted();
            p->pause();
            break;
        case ACT_DROP:
            activity_on_turn_drop();
            break;
        case ACT_STASH:
            activity_on_turn_stash();
            break;
        case ACT_PICKUP:
            activity_on_turn_pickup();
            break;
        case ACT_MOVE_ITEMS:
            activity_on_turn_move_items();
            break;
        case ACT_ADV_INVENTORY:
            p->cancel_activity();
            advanced_inv();
            break;
        case ACT_ARMOR_LAYERS:
            p->cancel_activity();
            p->sort_armor();
            break;
        case ACT_START_FIRE:
            moves_left -= 100; // based on time
            if (p->i_at(position).has_flag("LENS")) { // if using a lens, handle potential changes in weather
                activity_handlers::start_fire_lens_do_turn( this, p );
            }
            p->rooted();
            p->pause();
            break;
        case ACT_FILL_LIQUID:
            activity_handlers::fill_liquid_do_turn( this, p );
            break;
        case ACT_ATM:
            // Based on speed, not time
            if (p->moves <= moves_left) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            iexamine::atm(p, nullptr, 0, 0);
            break;
        case ACT_START_ENGINES:
            moves_left -= 100;
            p->rooted();
            p->pause();
            break;
        case ACT_OXYTORCH:
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
            if( values[0] > 0 ) {
                activity_handlers::oxytorch_do_turn( this, p );
            }
            break;
        default:
            // Based on speed, not time
            if( p->moves <= moves_left ) {
                moves_left -= p->moves;
                p->moves = 0;
            } else {
                p->moves -= moves_left;
                moves_left = 0;
            }
    }

    if (is_complete()) {
        finish( p );
    }
}