Example #1
0
/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn,
                                     const tripoint &location )
{
    const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 );

    if ( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    rainfall_data rainfall = get_rainfall( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( rainfall.rain_amount > 0 ) {
        // This is kinda weird: we're dumping a "block" of water all at once
        // but the old formula ( rain_turns / turn_per_charge(total_amount) ) resulted in
        // water being produced at quadratic rate rather than linear with time
        const int rain = 1.0 / tr.funnel_turns_per_charge( rainfall.rain_amount );
        it.add_rain_to_container( false, rain );
    }

    if( rainfall.acid_amount > 0 ) {
        const int acid = 1.0 / tr.funnel_turns_per_charge( rainfall.acid_amount );
        it.add_rain_to_container( true, acid );
    }
}
Example #2
0
/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn,
                                     const tripoint &location )
{
    const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 );

    if ( startturn > endturn || !tr.is_funnel() ) {
        return;
    }
    it.bday = endturn; // bday == last fill check
    int rain_amount = 0;
    int acid_amount = 0;
    int rain_turns = 0;
    int acid_turns = 0;
    for( calendar turn(startturn); turn < endturn; turn += 10) {
        // TODO: Z-level weather
        switch(g->weatherGen.get_weather_conditions(point(location.x, location.y), turn)) {
        case WEATHER_DRIZZLE:
            rain_amount += 4;
            rain_turns++;
            break;
        case WEATHER_RAINY:
        case WEATHER_THUNDER:
        case WEATHER_LIGHTNING:
            rain_amount += 8;
            rain_turns++;
            break;
        case WEATHER_ACID_DRIZZLE:
            acid_amount += 4;
            acid_turns++;
            break;
        case WEATHER_ACID_RAIN:
            acid_amount += 8;
            acid_turns++;
            break;
        default:
            break;
        }
    }

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( rain_amount > 0 ) {
        int rain = rain_turns / tr.funnel_turns_per_charge( rain_amount );
        it.add_rain_to_container( false, rain );
    }

    if( acid_amount > 0 ) {
        int acid = acid_turns / tr.funnel_turns_per_charge( acid_amount );
        it.add_rain_to_container( true, acid );
    }
}
Example #3
0
/**
 * Main routine for filling funnels from weather effects.
 */
void fill_funnels(int rain_depth_mm_per_hour, bool acid, const trap &tr)
{
    const double turns_per_charge = tr.funnel_turns_per_charge(rain_depth_mm_per_hour);
    // Give each funnel on the map a chance to collect the rain.
    const auto &funnel_locs = g->m.trap_locations( tr.loadid );
    for( auto loc : funnel_locs ) {
        int maxcontains = 0;
        auto items = g->m.i_at( loc );
        if (one_in(turns_per_charge)) { // todo; fixme. todo; fixme
            //add_msg("%d mm/h %d tps %.4f: fill",int(calendar::turn),rain_depth_mm_per_hour,turns_per_charge);
            // This funnel has collected some rain! Put the rain in the largest
            // container here which is either empty or contains some mixture of
            // impure water and acid.
            auto container = items.end();
            for( auto candidate_container = items.begin(); candidate_container != items.end();
                 ++candidate_container ) {
                if ( candidate_container->is_funnel_container( maxcontains ) ) {
                    container = candidate_container;
                }
            }

            if( container != items.end() ) {
                container->add_rain_to_container(acid, 1);
                container->bday = int(calendar::turn);
            }
        }
    }
}
Example #4
0
/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, int startturn, int endturn,
                                     const tripoint &location )
{
    if( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    auto data = sum_conditions( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( data.rain_amount > 0 ) {
        const int rain = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.rain_amount ), 1.0f );
        it.add_rain_to_container( false, rain );
        // add_msg(m_debug, "Retroactively adding %d water from turn %d to %d", rain, startturn, endturn);
    }

    if( data.acid_amount > 0 ) {
        const int acid = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.acid_amount ), 1.0f );
        it.add_rain_to_container( true, acid );
    }
}
Example #5
0
/**
 * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point.
 */
void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn,
                                     const tripoint &location )
{
    const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 );

    if ( startturn > endturn || !tr.is_funnel() ) {
        return;
    }

    it.bday = endturn; // bday == last fill check
    auto data = sum_conditions( startturn, endturn, location );

    // Technically 0.0 division is OK, but it will be cleaner without it
    if( data.rain_amount > 0 ) {
        const int rain = 1.0 / tr.funnel_turns_per_charge( data.rain_amount );
        it.add_rain_to_container( false, rain );
    }

    if( data.acid_amount > 0 ) {
        const int acid = 1.0 / tr.funnel_turns_per_charge( data.acid_amount );
        it.add_rain_to_container( true, acid );
    }
}